← Back to Writeups
CUSTOMEasyCrypto

Anime Track Cipher

XESXOR9/2/20263 min read
#crypto#custom#easy#known-plaintext-attack-using-f#pattern-recognition-from-song-#substitution-cipher-frequency-

Anime Track Cipher

Platform: CUSTOM | Category: Crypto | Type: Challenge | Difficulty: Easy | OS: N/A | **Author: XESXOR Techniques: Known plaintext attack using flag format, Pattern recognition from song lyrics, Substitution cipher frequency analysis

Summary

Walkthrough of the CUSTOM Crypto Anime Track Cipher. Task: decrypt song lyrics encrypted with substitution cipher. Solution: known plaintext attack using flag format CODEBY{} to build substitution table, then identify song as Running in the 90s from Ini

Description

Мой друг сказал что пришел на почту текст его любимого трека из его любимого аниме. Но кто же знал что он решит приколоться и зашифрует его...

Task: decrypt the song lyrics and find the flag.

Analysis

  1. File cypher.txt contains encrypted song lyrics with the flag at the end
  2. Encrypted flag: gwrndq{1b1a1xy_r_xn86_r0s1ea0}
  3. Flag format: CODEBY{...} - this gives us the initial character mapping

Building mapping from flag format

gwrndq → CODEBY
g → c
w → o  
r → d
n → e
d → b
q → y

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

Song identification

The encrypted text is the song "Running in the 90's" from the anime Initial D.

Using the known song lyrics as plaintext, we can build the complete substitution table.

Solution

Complete substitution table

python
mapping = {
    'a': 't', 'b': 'n', 'c': 'w', 'd': 'b', 'e': 'f', 'g': 'c',
    'i': 'k', 'j': 'm', 'k': 'i', 'l': 's', 'm': 'g', 'n': 'e',
    'o': 'u', 'p': 'p', 'q': 'y', 'r': 'd', 's': 'r', 't': 'j',
    'u': 'h', 'v': 'v', 'w': 'o', 'x': 'a', 'y': 'l', 'z': 'x'
}

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

Decryption script

python
#!/usr/bin/env python3

cipher_flag = "gwrndq{1b1a1xy_r_xn86_r0s1ea0}"

# Substitution mapping (cipher -> plain)
mapping = {
    'a': 't', 'b': 'n', 'c': 'w', 'd': 'b', 'e': 'f', 'g': 'c',
    'i': 'k', 'j': 'm', 'k': 'i', 'l': 's', 'm': 'g', 'n': 'e',
    'o': 'u', 'p': 'p', 'q': 'y', 'r': 'd', 's': 'r', 't': 'j',
    'u': 'h', 'v': 'v', 'w': 'o', 'x': 'a', 'y': 'l', 'z': 'x'
}

result = ""
for c in cipher_flag:
    if c.lower() in mapping:
        result += mapping[c.lower()]
    else:
        result += c
‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

print(f"Decrypted: {result}")
# Output: codeby{REDACTED}
print(f"Flag: CODEBY{{{result[7:-1]}}}")

Decryption

gwrndq{1b1a1xy_r_xn86_r0s1ea0}
      ↓
CODEBY{REDACTED}

Theory

Substitution Cipher - one of the oldest encryption methods, where each letter of the alphabet is replaced by another letter according to a fixed table.

Known Plaintext Attack - a cryptanalysis method where the attacker knows part of the plaintext and the corresponding ciphertext. In this case:

  • Known: gwrndq = CODEBY (flag format)
  • This gives 6 character pairs to start building the table ‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

Files

  • task.zip → cypher.txt - encrypted lyrics of "Running in the 90's" ‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

Key Takeaways / Lessons

  • Mastering Known plaintext attack using flag format, Pattern recognition from song lyrics, Substitution cipher frequency analysis was key to this challenge.
  • Always check for common misconfigurations and verify assumptions.

Crafted by XESXOR Research • 2025-12-30 • CUSTOM • Anime Track Cipher • Difficulty: Easy