Bruh...
Luckily, no background knowledge required for this challenge! Except, basic knowledge of Python programming and data types such as lists and dictionaries.
Copy char_map = {
'a': 'z',
'b': 'y',
'c': 'x',
'C': 'X',
'd': 'w',
'e': 'v',
'f': 'u',
'F': 'U',
'g': 't',
'h': 's',
'i': 'r',
'j': 'q',
'k': 'p',
'l': 'o',
'm': 'n',
'n': 'm',
'o': 'l',
'p': 'k',
'q': 'j',
'r': 'i',
's': 'h',
't': 'g',
'T': 'G',
'u': 'f',
'v': 'e',
'w': 'd',
'x': 'c',
'y': 'b',
'z': 'a',
'{': '{',
'}': '}',
' ': 'cc',
'!': 'dd',
'?': 'ee',
'.': 'ff',
',': 'gg',
"'": 'hh',
'"': 'ii',
':': 'jj',
';': 'kk',
'-': 'll',
'_': '_',
'+': 'nn',
'=': 'oo',
'/': 'pp',
'\\': 'qq',
'|': 'rr',
'1': '1',
'0': '0',
}
def encrypt_text(text):
encrypted_text = ''
for c in text:
encrypted_text += char_map[c]
return encrypted_text
def generate_flag():
flag = 'flag'
return encrypt_text(flag)
So, it seems like there's a very interesting character mapping going on with the char_map
dictionary.
You can decode this by hand, manually mapping each character to the correct letter, or you can copy paste the same list and remap it backwards!
Copy char_map = {
'a': 'z',
'b': 'y',
'c': 'x',
'C': 'X',
'd': 'w',
'e': 'v',
'f': 'u',
'F': 'U',
'g': 't',
'h': 's',
'i': 'r',
'j': 'q',
'k': 'p',
'l': 'o',
'm': 'n',
'n': 'm',
'o': 'l',
'p': 'k',
'q': 'j',
'r': 'i',
's': 'h',
't': 'g',
'T': 'G',
'u': 'f',
'v': 'e',
'w': 'd',
'x': 'c',
'y': 'b',
'z': 'a',
'{': '{',
'}': '}',
' ': 'cc',
'!': 'dd',
'?': 'ee',
'.': 'ff',
',': 'gg',
"'": 'hh',
'"': 'ii',
':': 'jj',
';': 'kk',
'-': 'll',
'_': '_',
'+': 'nn',
'=': 'oo',
'/': 'pp',
'\\': 'qq',
'|': 'rr',
'1': '1',
'0': '0',
}
def decrypt_text(text: str):
decrypted_text = ''
while len(text) > 0:
for k, v in char_map.items():
if text.startswith(v):
decrypted_text += k
text = text[len(v):]
break
return decrypted_text
enc = "XGU101{dsb_wlvh_gsrh_xszoovmtv_vcrhg_yil}"
print(decrypt_text(enc))
# CTF101{why_does_this_challenge_exist_bro}