Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- class Operations:
- def AND(self, x, y):
- return True if (x and y) else False
- def OR(self, x, y):
- return True if (x or y) else False
- def NOT(self, a):
- return True if not (a) else False
- def NAND(self, x, y):
- return True if not (x and y) else False
- def NOR(self, x, y):
- return True if (not x and not y) else False
- def XOR(self, x, y):
- return True if (x ^ y) else False
- def output(inp):
- arr = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"]
- out = []
- for i in range(len(inp)):
- if int(inp[i]) == 1:
- out.append(arr[i])
- return "".join(out)
- def crack(A, B, C, D, E, F, G, H, I, J):
- a, b, b_1, b_2, c_1, c_2, d, d_1, d_2 = 0, 0, 0, 0, 0, 0, 0, 0, 0
- op = Operations()
- # ----------------- A..F ----------------
- # A, B
- if op.NOR(A, op.NOT(B)):
- a = 1
- # C, D, E, F
- if op.OR(op.NOT(C), D):
- b_1 = 1
- if op.NOR(E, op.NOT(F)):
- b_2 = 1
- if op.NOR(b_1, b_2):
- b = 1
- # AB, CDEF
- if op.AND(a, b):
- a = 1
- else:
- a = 0
- # ---------------------------------------
- # ----------------- G..J ----------------
- if op.NOR(G, H):
- c_1 = 1
- if op.XOR(H, I):
- c_2 = 1
- if op.AND(c_1, c_2):
- d_1 = 1
- if op.AND(I, J):
- d_2 = 1
- if op.AND(d_1, d_2):
- d = 1
- # ---------------------------------------
- # ----------------- FINAL ---------------
- if op.AND(a, d):
- print(
- f"{A}{B}{C}{D}{E}{F}{G}{H}{I}{J}\n" +
- "CTF{" + f"{output([A, B, C, D, E, F, G, H, I, J])}" + "}")
- return True
- return False
- def rnd():
- return random.randint(0, 1)
- while 1:
- if crack(rnd(), rnd(), rnd(), rnd(), rnd(), rnd(), rnd(), rnd(), rnd(), rnd()):
- break
Advertisement
Add Comment
Please, Sign In to add comment