-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchallenge.py
38 lines (32 loc) · 839 Bytes
/
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
from Crypto.Random.random import randrange
from machine import Machine
def Fib(n):
if n < 2:
return n
A = 0
B = 1
for _ in range(n - 1):
C = A + B
A = B
B = C
return B
def correctness(code):
for _ in range(64):
a = randrange(1024)
c = Machine(code, a)
c.runCode()
if c.error:
print("[!] Error!")
exit()
if c.R0 != Fib(a):
print("[!] Nope, you did not implement Fibonacci")
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.")