Created
December 7, 2022 05:52
-
-
Save recluze/dcaff7e60fbcac1f7425a1f8f9c69de7 to your computer and use it in GitHub Desktop.
CTF for CyberHub and Programming Club (2022-12)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Capture the Flag - Cypto Beginners - Basic Cypher | |
# authors: Nauman (recluze) / Sohail | |
# Effat University, Jeddah, KSA | |
# Information availble to perform cryptanalysis: | |
# - Message is in the English language | |
# - Message is approximately (but not exactly) 10 words long | |
cypher_text = "1012,981,924,968,980,985,974,985,914,924,1023,979,978,987,974,989,968,969,976,989,968,981,979,978,975,924,979,978,924,984,985,991,974,965,972,968,981,978,987,924,968,980,985,924,983,985,965,925,924,1012,985,974,985,923,975,924,965,979,969,974,924,986,976,989,987,902,924,906,907,909,990,901,906,900,989,911,986,985,904,908,910,901,900,901,910,906,909,986,910,984,905,909,991,990,991,901,908,904,906,985,909,990,901,989,904,905,910" | |
key = 1 | |
def decrypt(msg, key): | |
decrypted_message = "" | |
for c in msg.split(","): # each character gets decrypted separately | |
if c.strip() == "": continue | |
c_bin = int(c) | |
c_decrypted = c_bin ^ key | |
c_decrypted = chr(c_decrypted) | |
decrypted_message += c_decrypted | |
return decrypted_message | |
if __name__ == "__main__": | |
for key in range(10_000): | |
decrypted = decrypt(cypher_text, key) | |
# add a check here to "detect" if the key is the rigth one! | |
if True: | |
print(decrypted) | |
break | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment