TerrificTable55

Untitled

Mar 24th, 2022
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.90 KB | None | 0 0
  1. import random
  2.  
  3.  
  4. class Operations:
  5.     def AND(self, x, y):
  6.         return True if (x and y) else False
  7.  
  8.     def OR(self, x, y):
  9.         return True if (x or y) else False
  10.  
  11.     def NOT(self, a):
  12.         return True if not (a) else False
  13.  
  14.     def NAND(self, x, y):
  15.         return True if not (x and y) else False
  16.  
  17.     def NOR(self, x, y):
  18.         return True if (not x and not y) else False
  19.  
  20.     def XOR(self, x, y):
  21.         return True if (x ^ y) else False
  22.  
  23.  
  24. def output(inp):
  25.     arr = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"]
  26.     out = []
  27.  
  28.     for i in range(len(inp)):
  29.         if int(inp[i]) == 1:
  30.             out.append(arr[i])
  31.  
  32.     return "".join(out)
  33.  
  34.  
  35. def crack(A, B, C, D, E, F, G, H, I, J):
  36.     a, b, b_1, b_2, c_1, c_2, d, d_1, d_2 = 0, 0, 0, 0, 0, 0, 0, 0, 0
  37.  
  38.     op = Operations()
  39.  
  40.     # ----------------- A..F ----------------
  41.     # A, B
  42.     if op.NOR(A, op.NOT(B)):
  43.         a = 1
  44.  
  45.     # C, D, E, F
  46.     if op.OR(op.NOT(C), D):
  47.         b_1 = 1
  48.     if op.NOR(E, op.NOT(F)):
  49.         b_2 = 1
  50.  
  51.     if op.NOR(b_1, b_2):
  52.         b = 1
  53.  
  54.     # AB, CDEF
  55.     if op.AND(a, b):
  56.         a = 1
  57.     else:
  58.         a = 0
  59.     # ---------------------------------------
  60.  
  61.     # ----------------- G..J ----------------
  62.     if op.NOR(G, H):
  63.         c_1 = 1
  64.     if op.XOR(H, I):
  65.         c_2 = 1
  66.  
  67.     if op.AND(c_1, c_2):
  68.         d_1 = 1
  69.     if op.AND(I, J):
  70.         d_2 = 1
  71.  
  72.     if op.AND(d_1, d_2):
  73.         d = 1
  74.     # ---------------------------------------
  75.  
  76.     # ----------------- FINAL ---------------
  77.     if op.AND(a, d):
  78.         print(
  79.             f"{A}{B}{C}{D}{E}{F}{G}{H}{I}{J}\n" +
  80.             "CTF{" + f"{output([A, B, C, D, E, F, G, H, I, J])}" + "}")
  81.         return True
  82.     return False
  83.  
  84.  
  85. def rnd():
  86.     return random.randint(0, 1)
  87.  
  88.  
  89. while 1:
  90.     if crack(rnd(), rnd(), rnd(), rnd(), rnd(), rnd(), rnd(), rnd(), rnd(), rnd()):
  91.         break
  92.  
Advertisement
Add Comment
Please, Sign In to add comment