2021-05-01 10:05:21 +00:00
|
|
|
#!/usr/bin/env python3
|
2021-06-10 10:40:48 +00:00
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
import sys, pathlib
|
|
|
|
sys.path.append(str(pathlib.Path(__file__).resolve().parents[1]))
|
2021-05-01 10:05:21 +00:00
|
|
|
|
|
|
|
import argparse, pathlib
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(description='Run a Mach-O payload under the hypervisor')
|
2021-05-13 10:02:35 +00:00
|
|
|
parser.add_argument('-s', '--symbols', type=pathlib.Path)
|
2021-05-01 10:05:21 +00:00
|
|
|
parser.add_argument('payload', type=pathlib.Path)
|
2021-05-08 18:18:08 +00:00
|
|
|
parser.add_argument('boot_args', default=[], nargs="*")
|
2021-05-01 10:05:21 +00:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
2021-06-10 10:40:48 +00:00
|
|
|
from m1n1.proxy import *
|
|
|
|
from m1n1.proxyutils import *
|
|
|
|
from m1n1.utils import *
|
|
|
|
from m1n1.hv import HV
|
2021-05-01 10:05:21 +00:00
|
|
|
|
|
|
|
iface = UartInterface()
|
|
|
|
p = M1N1Proxy(iface, debug=False)
|
|
|
|
bootstrap_port(iface, p)
|
|
|
|
u = ProxyUtils(p, heap_size = 128 * 1024 * 1024)
|
|
|
|
|
|
|
|
hv = HV(iface, p, u)
|
|
|
|
|
|
|
|
hv.init()
|
2021-05-08 18:18:08 +00:00
|
|
|
|
|
|
|
if len(args.boot_args) > 0:
|
|
|
|
boot_args = " ".join(args.boot_args)
|
|
|
|
hv.set_bootargs(boot_args)
|
|
|
|
|
2021-05-13 10:02:35 +00:00
|
|
|
symfile = None
|
|
|
|
if args.symbols:
|
|
|
|
symfile = args.symbols.open("rb")
|
|
|
|
hv.load_macho(args.payload.open("rb"), symfile=symfile)
|
2021-05-01 10:05:21 +00:00
|
|
|
hv.start()
|