Introduction
-
Finding Flags (2 points)
Answer::
crypto{y0ur_f1rst_fl4g}
-
Great Snakes (3 points)
The given Python script has the following code:
#!/usr/bin/env python3 import sys # import this if sys.version_info.major == 2: print("You are running Python 2, which is no longer supported. Please update to Python 3.") ords = [81, 64, 75, 66, 70, 93, 73, 72, 1, 92, 109, 2, 84, 109, 66, 75, 70, 90, 2, 92, 79] print("Here is your flag:") print("".join(chr(o ^ 0x32) for o in ords))
Running the script gives us the flag:
crypto{z3n_0f_pyth0n}
-
ASCII (5 points)
Solution:
print(''.join([chr(int(x)) for x in [99, 114, 121, 112, 116, 111, 123, 65, 83, 67, 73, 73, 95, 112, 114, 49, 110, 116, 52, 98, 108, 51, 125]]))
Answer::
crypto{ASCII_pr1nt4bl3}
-
Hex (5 points)
Solution:
bytes.fromhex('63727970746f7b596f755f77696c6c5f62655f776f726b696e675f776974685f6865785f737472696e67735f615f6c6f747d')
Answer::
crypto{You_will_be_working_with_hex_strings_a_lot}
-
Base64 (10 points)
Solution:
import base64 data_bytes = bytes.fromhex('72bca9b68fc16ac7beeb8f849dca1d8a783e8acf9679bf9269f7bf') data_base64 = base64.b64encode(data_bytes) print(data_base64.decode('utf-8'))
Answer::
crypto/Base+64+Encoding+is+Web+Safe/
-
Bytes and Big Integers (10 points)
Solution:
# python3 -m pip install pycryptodome from Crypto.Util.number import * long_to_bytes(11515195063862318899931685488813747395775516287289682636499965282714637259206269)
Answer::
crypto{3nc0d1n6_4ll_7h3_w4y_d0wn}
-
XOR Starter (10 points)
Solution:
string = 'label' chars = [ord(c) for c in string] key = 13 encrypted = [chr(c ^ key) for c in chars] print(''.join(encrypted))
Answer::
crypto{aloha}
-
XOR Properties (15 points)
We are given the following information:
Commutative: A ⊕ B = B ⊕ A Associative: A ⊕ (B ⊕ C) = (A ⊕ B) ⊕ C Identity: A ⊕ 0 = A Self-Inverse: A ⊕ A = 0 KEY1 = a6c8b6733c9b22de7bc0253266a3867df55acde8635e19c73313 KEY2 ^ KEY1 = 37dcb292030faa90d07eec17e3b1c6d8daf94c35d4c9191a5e1e KEY2 ^ KEY3 = c1545756687e7573db23aa1c3452a098b71a7fbf0fddddde5fc1 FLAG ^ KEY1 ^ KEY3 ^ KEY2 = 04ee9855208a2cd59091d04767ae47963170d1660df7f56f5f
Solution:
import operator # Source: https://stackoverflow.com/a/66662724/6456163 xor = lambda a, b: bytes(map(operator.xor, a, b)) key1 = bytes.fromhex('a6c8b6733c9b22de7bc0253266a3867df55acde8635e19c73313') key2 = xor(bytes.fromhex('37dcb292030faa90d07eec17e3b1c6d8daf94c35d4c9191a5e1e'), key1) key3 = xor(bytes.fromhex('c1545756687e7573db23aa1c3452a098b71a7fbf0fddddde5fc1'), key2) flag = xor(xor(xor(bytes.fromhex('04ee9855208a2cd59091d04767ae47963170d1660df7f56f5f'), key1), key2), key3) print(flag.decode('utf-8'))
Answer::
crypto{x0r_i5_ass0c1at1v3}
-
Favourite byte (20 points)
Solution:
# decode hex string to bytes ciphertext = bytes.fromhex("73626960647f6b206821204f21254f7d694f7624662065622127234f726927756d") # try all possible byte values for the key for key in range(256): # initialize an empty list to store the decrypted message decrypted = [] # xor the ciphertext with the key byte for byte in ciphertext: decrypted.append(byte ^ key) # try to print the decrypted message as a string try: print("Key:", key, "Message:", bytes(decrypted).decode()) except: pass
The answer was found for key
16
:crypto{0x10_15_my_f4v0ur173_by7e}
-
You either know, XOR you don't (30 points)