[rev] Binary Conspicuous Digits

📌 Intro
This program outputs some conspicuous binary digits. See if you can find out what they mean...
🔬 Analysis
# encrypt.py #!/usr/bin/env python3 flag = 'wxmctf{REDACTED}' encoded = '' for c in flag: encoded += ''.join(map( lambda x: format(int(x), 'b').zfill(4), str(ord(c)).zfill(3) )) with open('output.txt', 'w') as output: output.write(encoded)
위 코드를 보면 flag 문자에 대해 다음과 같은 작업을 수행한다.
1. str(ord(c)).zfill(3) : 문자의 ASCII값을 문자열로 변환하고, 3자리 숫자가 되도록 앞에 0을 채운다.
print(str(ord('w')).zfill(3)) # 119
2. lambda x: format(int(x), 'b').zfill(4) : 각 숫자를 이진수로 변환한다. 각 이진수는 4자리가 되도록 앞에 0을 채운다.
lambda x: format(int('1'), 'b').zfill(4) # 0001
즉, "w" 문자는 000100011001문자로 변환된다.
🎉 Exploit
역연산 코드를 작성하면 다음과 같이 작성할 수 있다.
with open('output.txt', 'r') as input_file: encoded = input_file.read() decoded = '' i = 0 while i < len(encoded): binary_char = encoded[i:i+12] ascii_value = 0 for j in range(0, 12, 4): digit = int(binary_char[j:j+4], 2) ascii_value = ascii_value * 10 + digit decoded += chr(ascii_value) i += 12 print(decoded)
🚩 Flag
wxmctf{B1nary_R3v3rs1ng_4t_1ts_F1n3st}
'🚩 CTF Writeup > WxMCTF '24' 카테고리의 다른 글
[web] Nuclear Launch Codes (0) | 2024.03.11 |
---|---|
[web] Walmart! (0) | 2024.03.11 |
[Web] Brawl: The Heist (0) | 2024.03.11 |
댓글
이 글 공유하기
다른 글
-
[web] Nuclear Launch Codes
[web] Nuclear Launch Codes
2024.03.11📌 Intro Blind SQL Injection MGCI's cybersecurity club has hired you to test their site security for nuclear launch codes. Unfortunately, they forgot to give you any log-in credentials, and they haven't implemented registration features yet! Can you find the nuclear launch codes? 🔬 Analysis # app.py @app.route('/login_username', methods=['POST']) def login(): username = request.form['username'] c… -
[web] Walmart!
[web] Walmart!
2024.03.11이 글은 보호되어 있습니다. -
[Web] Brawl: The Heist
[Web] Brawl: The Heist
2024.03.11📌 Intro parameter pollution 과 관련된 문제 After getting all of his brawlers to 500 trophies, Eatingfood has found himself in a pickle - there is a Fang on the opposing team every other match and he can no longer play the game! Luckily, he has a plan - to get enough gems to buy every brawler and hypercharge so he can get back to mindlessly mashing buttons and winning. Not wanting to wait and earn gems…
댓글을 사용할 수 없습니다.