-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchallenge.py
50 lines (40 loc) · 1.12 KB
/
challenge.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import time
from Crypto.Random.random import randrange
from machine import Machine
def correctness(code):
a = 1+randrange(65535)
coin = 1
c = Machine(code, a, a+a)
c.runCode()
if c.error:
print("[!] Error!")
exit()
if c.R0 != coin:
print("[!] Nope, you did not implement a comparison")
exit()
for _ in range(63):
a = randrange(65536)
b = a
while a == b:
b = randrange(65536)
coin = randrange(2)
if coin == 0:
c = Machine(code, a, a)
else:
c = Machine(code, a, b)
c.runCode()
if c.error:
print("[!] Error!")
exit()
if c.R0 != coin:
print("[!] Nope, you did not implement a comparison")
exit()
flag = open("flag.txt").read().strip()
print(f"[+] Congrats! Here is the flag: {flag}")
if __name__ == "__main__":
try:
print("Enter your bytecode in hexadecimal:")
code = input(">>> ")
correctness(code)
except:
print("Please check your inputs.")