Last active
January 19, 2022 18:34
-
-
Save nick3499/7eb6f732e05d9d23850df0afaeadb9a5 to your computer and use it in GitHub Desktop.
crackme-py
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
#!/bin/python3 | |
'''Encode or decode ROT47''' | |
# Any spaces are left unchanged. | |
def rot47(string): | |
'''Encode/decode string.''' | |
enc_dec = '' # string encoded/decoded to/from ROT47 | |
for char in string: | |
ascii_code = ord(char) # convert character to ASCII code number | |
if 33 <= ascii_code <= 79: | |
enc_dec += chr(ascii_code + 47) | |
elif 80 <= ascii_code <= 126: | |
enc_dec += chr(ascii_code - 47) | |
else: | |
enc_dec += char | |
return enc_dec | |
if __name__ == '__main__': | |
print(rot47(input('Enter string: '))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
picoCTF: crackme-py
Get Python Script
Decode a Variable
In order to find the
picoCTF
flag, decode the value of thebezos_cc_secret
fromcrackme.py
using the ROT47 cipher.Encoder/Decoder Script
rot47(s)
both encodes and decodes ROT47, while any spaces will be left unchanged.Simplified Chained Comparisons
pylint
suggests the use of arbitrarily chained comparisons.References