← Back to Writeups
CUSTOMEasyCrypto

Polyglot

XESXOR9/2/20264 min read
#crypto#custom#easy#base64_decode#hex_decode#multi_encoding#unicode_escape_decode

Polyglot

Platform: CUSTOM | Category: Crypto | Type: Challenge | Difficulty: Easy | OS: N/A | **Author: XESXOR Techniques: base64_decode, hex_decode, multi_encoding, unicode_escape_decode

Summary

Walkthrough of the CUSTOM Crypto Polyglot. Task: Decode a file containing data in three encoding formats (hex, unicode escape, base64). Solution: Sequentially decode each format and concatenate the parts to get the flag.

Description

Задали тут выучить стих на нескольких языках, только я такие раньше не встречал.

(Translation: "I was asked to learn a poem in several languages, but I've never seen such languages before.")

Files: polyglot.txt

Analysis

The file contains three lines in different encoding formats — this is the "several languages" (polyglot):

42 65 6e 65 61 74 68 20 74 68 65 20 73 6b 79 20 73 6f 20 66 61 73 74 20 61 6e 64 20 62 6c 75 65 2c 0a 54 68 65 20 67 65 6e 74 6c 65 20 77 69 6e 64 73 20 69 6e 20 77 68 69 73 70 65 72 73 20 66 6c 65 77 2c 0a 54 68 65 20 73 74 61 72 73 20 61 62 6f 76 65 2c 20 61 20 73 68 69 6e 69 6e 67 20 6c 69 67 68 74 2c 0a 47 75 69 64 65 20 74 68 65 20 73 6f 75 6c 20 74 68 72 6f 75 67 68 20 64 61 72 6b 65 73 74 20 6e 69 67 68 74 2e 0a 44 55 43 4b 45 52 5a 7b 34 77 33 73 30 6d 65	
\u005F\u0063\u0030\u006D\u0070\u0075\u0074\u0033\u0072
XzNuYzBkMW5nIX0=

‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

Recognized formats:

LineFormatIndicators
1Hex (hexadecimal)Pairs of characters 0-9, a-f separated by spaces
2Unicode escapePattern \uXXXX
3Base64Characters A-Za-z0-9+/, ends with =

Solution

Part 1: Hex Decoding

python
hex_data = "42 65 6e 65 61 74 68 20 74 68 65 20 73 6b 79 20 73 6f 20 66 61 73 74 20 61 6e 64 20 62 6c 75 65 2c 0a 54 68 65 20 67 65 6e 74 6c 65 20 77 69 6e 64 73 20 69 6e 20 77 68 69 73 70 65 72 73 20 66 6c 65 77 2c 0a 54 68 65 20 73 74 61 72 73 20 61 62 6f 76 65 2c 20 61 20 73 68 69 6e 69 6e 67 20 6c 69 67 68 74 2c 0a 47 75 69 64 65 20 74 68 65 20 73 6f 75 6c 20 74 68 72 6f 75 67 68 20 64 61 72 6b 65 73 74 20 6e 69 67 68 74 2e 0a 44 55 43 4b 45 52 5a 7b 34 77 33 73 30 6d 65"
part1 = bytes.fromhex(hex_data.replace(" ", "")).decode('utf-8')
print(part1)

‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

Result:

Beneath the sky so fast and blue,
The gentle winds in whispers flew,
The stars above, a shining light,
Guide the soul through darkest night.
DUCKERZ{4w3s0me

Part 2: Unicode Escape Decoding

python
unicode_data = r"\u005F\u0063\u0030\u006D\u0070\u0075\u0074\u0033\u0072"
part2 = unicode_data.encode().decode('unicode_escape')
print(part2)  # _c0mput3r

Part 3: Base64 Decoding

python
import base64
part3 = base64.b64decode("XzNuYzBkMW5nIX0=").decode('utf-8')
print(part3)  # _3nc0d1ng!}

‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

Full Solution Script

python
#!/usr/bin/env python3
"""
Polyglot - duckerz CTF
Multi-encoding challenge: Hex + Unicode escape + Base64
"""
import base64

# Part 1: Hex decode
hex_data = "42 65 6e 65 61 74 68 20 74 68 65 20 73 6b 79 20 73 6f 20 66 61 73 74 20 61 6e 64 20 62 6c 75 65 2c 0a 54 68 65 20 67 65 6e 74 6c 65 20 77 69 6e 64 73 20 69 6e 20 77 68 69 73 70 65 72 73 20 66 6c 65 77 2c 0a 54 68 65 20 73 74 61 72 73 20 61 62 6f 76 65 2c 20 61 20 73 68 69 6e 69 6e 67 20 6c 69 67 68 74 2c 0a 47 75 69 64 65 20 74 68 65 20 73 6f 75 6c 20 74 68 72 6f 75 67 68 20 64 61 72 6b 65 73 74 20 6e 69 67 68 74 2e 0a 44 55 43 4b 45 52 5a 7b 34 77 33 73 30 6d 65"
part1 = bytes.fromhex(hex_data.replace(" ", "")).decode('utf-8')
‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

# Part 2: Unicode escape decode
unicode_data = r"\u005F\u0063\u0030\u006D\u0070\u0075\u0074\u0033\u0072"
part2 = unicode_data.encode().decode('unicode_escape')

# Part 3: Base64 decode
part3 = base64.b64decode("XzNuYzBkMW5nIX0=").decode('utf-8')

# Extract flag from part1 (last line contains flag start)
flag_start = part1.split('\n')[-1]  # DUCKERZ{4w3s0me
flag = flag_start + part2 + part3

print(f"Part 1 (hex): {repr(part1)}")
print(f"Part 2 (unicode): {part2}")
print(f"Part 3 (base64): {part3}")
print(f"\nFlag: {flag}")

‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

Notes

  • Decoding order matters — flag parts are sequential
  • Hex part contains "distraction" text (poem) + flag start
  • Leetspeak in flag: 4w3s0me = awesome, c0mput3r = computer, 3nc0d1ng = encoding ‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

Key Takeaways / Lessons

  • Mastering base64_decode, hex_decode, multi_encoding, unicode_escape_decode was key to this challenge.
  • Always check for common misconfigurations and verify assumptions.

Crafted by XESXOR Research • 2026-01-09 • CUSTOM • Polyglot • Difficulty: Easy