Last active
December 10, 2020 20:29
-
-
Save captain-woof/477c11da645b5917cc54e6829fbf090f to your computer and use it in GitHub Desktop.
TryHackMe - Anonymous Playground - Password Decode Script
This file contains hidden or 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
| #!/usr/bin/python3 | |
| encoded = "ENCODED STRING HERE" | |
| all_alpha = "" # String of all lowercase english alphabets | |
| for i in range(ord('a'),ord('z')+1): | |
| all_alpha += chr(i) | |
| print("Encoded => " + encoded) | |
| print("All alphabets => " + all_alpha) | |
| print("Decoded => ",end="") | |
| # This loop iterates over all PAIRS of the alphabets, ignoring the '::' | |
| for i in range(0,len(encoded),2): | |
| first_char = encoded[i] # Since the first char in all pairs is lowercase | |
| second_char = encoded[i+1].lower() # Since the second char in all pairs is uppercase | |
| if first_char == ':': | |
| print(":",end="") | |
| continue | |
| first_alpha_position = ord(first_char) - ord('a') + 1 | |
| second_alpha_position = ord(second_char) - ord('a') + 1 | |
| decoded_alpha_position = (first_alpha_position + second_alpha_position) % 26 # The modulo operation takes care of the "imagine the list of alphabets arranged in a circular loop" part I was talking about | |
| decoded_alpha = all_alpha[decoded_alpha_position - 1] # Array indexes start at 0, yes? | |
| print(decoded_alpha,end="") | |
| print("") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment