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
| from pwn import *
context.log_level = 'debug' context.terminal=['tmux', 'splitw', '-h'] prog = './'
p = process(prog) libc = ELF("/lib/x86_64-linux-gnu/libc-2.27.so")
def debug(addr,PIE=True): debug_str = "" if PIE: text_base = int(os.popen("pmap {}| awk '{{print $1}}'".format(p.pid)).readlines()[1], 16) for i in addr: debug_str+='b *{}\n'.format(hex(text_base+i)) gdb.attach(p,debug_str) else: for i in addr: debug_str+='b *{}\n'.format(hex(i)) gdb.attach(p,debug_str)
def dbg(): gdb.attach(p)
s = lambda data :p.send((data)) sa = lambda delim,data :p.sendafter(str(delim), (data)) sl = lambda data :p.sendline((data)) sla = lambda delim,data :p.sendlineafter(str(delim), (data)) r = lambda numb=4096 :p.recv(numb) ru = lambda delims, drop=True :p.recvuntil(delims, drop) it = lambda :p.interactive() uu32 = lambda data :u32(data.ljust(4, '\0')) uu64 = lambda data :u64(data.ljust(8, '\0')) bp = lambda bkp :pdbg.bp(bkp) li = lambda str1,data1 :log.success(str1+'========>'+hex(data1))
def dbgc(addr): gdb.attach(p,"b*" + hex(addr) +"\n c")
def lg(s,addr): print('\033[1;31;40m%20s-->0x%x\033[0m'%(s,addr))
sh_x86_18="\x6a\x0b\x58\x53\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\xcd\x80" sh_x86_20="\x31\xc9\x6a\x0b\x58\x51\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\xcd\x80" sh_x64_21="\xf7\xe6\x50\x48\xbf\x2f\x62\x69\x6e\x2f\x2f\x73\x68\x57\x48\x89\xe7\xb0\x3b\x0f\x05"
def choice(idx): sla("Your choice: ",str(idx))
def add(idx,sz): choice(1) sla("Index: ",idx) sla("Size: ",sz)
def delete(idx): choice(4) sla("Index: ",idx)
def show(idx): choice(3) sla("Index: ",idx)
def edit(idx,con): choice(2) sla("Index: ",idx) sa("Content: ",con)
def exp():
it() if __name__ == '__main__': exp()
|