Новогоднее письмо (New Year Letter)
Новогоднее письмо (New Year Letter)
Platform: hackerlab | Category: Crypto | Type: Challenge | Difficulty: Medium | OS: NA | Author: XESXOR | Date: 2026-01-02 | Status: Solved Techniques: binascii module for UU decoding, Python code deobfuscation, UUencode recognition from file structure
Summary
Task: Decode an obfuscated Python script and encoded flag.txt file. Solution: Recognized UUencode format from M-prefixed lines and 45-byte chunks, decoded using binascii.a2b_uu().
Новогоднее письмо (New Year Letter) — hackerlab
Description
Кажется, что на Новый Год кто-то прислал Вам подарок! Проверьте почту!
Files: task.zip (contains task.py and flag.txt)
Analysis
1. Obfuscated Python Script (task.py)
python read-only • copy allowedI=isinstance D=None import sys,os,binascii as J def A(in_file,out_file,name=D,mode=D,*,backtick=False): # ... obfuscated code ... while len(G)>0:C.write(J.some_func(G,backtick=backtick));G=A.read(45) # ... if __name__=='__main__':B='input.txt';C='flag.txt';E='tmp.txt';F=438;A(B,C,name=E,mode=F,backtick=True)
Key observations:
- Uses
binasciimodule (imported as J) - Parameter
backtick=True— specific to UUencode (b2a_uufunction) - Reads 45 bytes at a time — standard UUencode chunk size
2. Encoded Data (flag.txt)
MT*$@T)W0OM"RT8O0O"#0D]"^T+30OM"\+"#1@]"RT+#0MM"PT+70O-&+T+4@
MT+C0L]&`T+[0NM"X(-"_T+O0OM&)T+#0M-"ZT+@@(M"8T+/1@-&+(-":T+[0
...
UUencode indicators:
- Lines start with 'M' — marker for 45-byte encoded lines
- Characters in ASCII range 32-96 (space to backtick)
- Standard UUencode format structure
Solution
python read-only • copy allowed#!/usr/bin/env python3 """ Новогоднее письмо (New Year Letter) - UUencode decoder """ import binascii def decode_uuencode(filename): """Decode UUencoded file using binascii.a2b_uu()""" with open(filename, 'r') as f: lines = f.readlines() decoded = b'' for line in lines: line = line.rstrip('\n') if line: try: decoded += binascii.a2b_uu(line) except binascii.Error as e: print(f"Warning: {e} on line: {line[:20]}...") continue return decoded # Decode the file result = decode_uuencode('flag.txt') print(result.decode('utf-8'))
Result
Decoded message — a New Year greeting:
С Новым Годом, уважаемые игроки площадки "Игры Кодебай"!
Мы хотим поздравить Вас с Наступающим Новым Годом, а также подарить флаг к этому заданию - CODEBY{REDACTED}!
...
Theory: UUencode
UUencode (Unix-to-Unix encoding) — a method for encoding binary data into ASCII text:
-
Line format: First character indicates the length of decoded data
- 'M' = chr(32 + 45) = 45 bytes (maximum)
- Last line is usually shorter
-
Encoding: 3 bytes → 4 ASCII characters (32-95 or with backtick)
-
Python binascii:
binascii.b2a_uu(data, backtick=True)— encodingbinascii.a2b_uu(line)— decoding
Notes
The flag uu_3n_c0d3 — leetspeak for "uu_encode", confirming the UUencode technique.