forked from emilytouchingcomputers/CTFium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
33 lines (28 loc) · 1.04 KB
/
run.py
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
#!/usr/bin/python3 -u
import random
import signal
import string
import subprocess
import sys
def random_string(n):
return ''.join(random.choice(string.ascii_lowercase) for _ in range(n))
def check_pow(bits):
r = random_string(10)
print(f"hashcash -mb{bits} {r}")
solution = input("Solution: \n").strip()
if subprocess.call(["hashcash", f"-cdb{bits}", "-r", r, solution],
cwd="/tmp",
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL) != 0:
raise Exception("Invalid PoW")
check_pow(25)
port = random.randint(1024, 65535)
print(f"IPMI over lan will be listening on port {port}\n")
subprocess.call(["./qemu-system-arm",
"-monitor", "/dev/null",
"-m", "128M",
"-M", "romulus-bmc",
"-drive", "file=./content,format=raw,if=mtd,readonly",
"-net", "nic",
"-net", f"user,hostfwd=udp::{port}-:623",
"-nographic"], stdin=subprocess.DEVNULL, timeout=200)