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 51 52 53 54 55
| import hashlib
def isPrime(n): if n < 2: return 0 for i in range(2, n - 1): if n % i == 0: return 0 return 1
def xordecrypt(key): str = "0rays" circle = 0 flag = "" for i in range(len(key)): flag = flag + chr(key[i] ^ ord(str[circle])) circle = (circle + 1) ^ 5 flag = "CBCTF{" + flag + "}" t = hashlib.sha256() t.update(flag.encode()) finalflag = t.hexdigest() if finalflag == "15c4ac7645546a1ef8141441b48e1824954fdbb159bf96400061b17db1af9edf": print(flag) exit(0)
def recursion(key2, i): key = key2.copy() if (i % 8) != 0: key[i] = (key[i] - key[i - 1] % (i % 8)) ^ (key[i - 1] // (i % 8)) else: key[i] = (key[i] - key[i + 7] % 8) ^ (key[i + 7] // 8) if i != 0: decrypt(key, i - 1) else: xordecrypt(key)
def decrypt(key1, i): key = key1.copy() for j in range(2, key[i] - 2): if key[i] % j == 0 and isPrime(j) and isPrime(key[i] // j): key[i] = j + key[i] // j break key[i] = key[i] + 2 recursion(key, i) key[i] = key[i] + 1 recursion(key, i)
key = [309, 1981, 2823, 6979, 28339, 39487, 33035, 283711, 623, 4109, 23551, 54761, 67985, 231149, 499603, 1354567, 213, 2651, 22559, 52549, 484663, 290793, 532213, 1746643] decrypt(key, 23)
|