This is an amazing challenge that includes a very interesting technique that I discovered back when I was learning JavaScript.
Apparently, you can assign chinese characters to overwrite the naming convention for built-in functions.
So for example, you can overwrite the built-in console.log function and rename it to print, so the python users won't get brain damage from coding in JS.
Function Overwrite Example 1
const print = console.log
print("hi")
You can even take this a step further, and assign chinese characters.
Function Overwrite Example 2
const 打印 = console.log;
打印("hi")
Now, technically we can replace every single built-in function in JavaScript with your own characters. However, I have yet to find a way to replace the if keyword with 如果, please help.
Also, I also remembered that you can assign your own variables to initialize a for-loop, so I made this monstrosity.
for (let 我 = 0; 我 < 大批.length; 我++)
And, string type characters retain their methods, so you can call the length() method on them!
The solution is to manually translate each function while taking reference to the function definitions mentioned above, or you can chuck the whole script into ChatGPT and have it automate the translation for you!
Anyway, here's the solution :}
main.py
def unmonkey(text):
if not isinstance(text, str):
return
result = []
for char in text:
char_code = ord(char)
new_char_code = char_code - 1
new_char = chr(new_char_code)
result.append(new_char)
return ''.join(result)
with open("enc.txt", "r", encoding="utf-8") as f:
enc = f.read().strip()
flag = unmonkey(enc)
print(flag)
# 羽翔吃了我的作业...我该怎么办...哦好吧这是标志: CTF101{alden_a7e_My_hOm3wOrk}