← Back to Writeups
CUSTOMEasyCrypto

ABA ABA?

XESXOR9/2/20263 min read
#crypto#custom#easy#bacon_decode#pattern_recognition

ABA ABA?

Platform: CUSTOM | Category: Crypto | Type: Challenge | Difficulty: Easy | OS: N/A | **Author: XESXOR Techniques: bacon_decode, pattern_recognition

Summary

Walkthrough of the CUSTOM Crypto ABA ABA?. Task: Decode a message consisting only of A and B characters. Solution: Recognize the Bacon cipher from the task name hint, split A/B sequences into 5-character groups preserving structural delimiters

Description

BAABAAAAAB{AAAABAAAAAAAABAABBABABBAA_ABAAABAAAB_BAABAAAAAABAAABBAABABABBA}

Flag format: TB{...}

Analysis

  1. The task name "ABA ABA?" is a strong hint towards the Bacon cipher (Francis Bacon's biliteral cipher)
  2. The encoded message consists entirely of letters A and B, plus structural characters {, }, _ — exactly what a Bacon cipher produces
  3. The flag format structure is preserved: prefix BAABAAAAAB, then {...} with underscore-separated parts inside
  4. Bacon cipher encodes each letter as a 5-character sequence of A's and B's
  5. Splitting the A/B content into 5-character groups:
    • Prefix: BAABA AAAAB → should decode to T B (matching flag format TB)
    • This confirms the classic 24-letter Bacon variant (I=J, U=V merged) ‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

Solution

Key Insight

The Bacon cipher (invented by Francis Bacon in 1605) is a biliteral cipher that encodes each letter using a 5-bit binary-like representation with two symbols (traditionally a and b). The classic variant uses a 24-letter alphabet where I/J and U/V are merged. Each group of 5 A/B characters maps to one plaintext letter.

Decoding Table (Classic 24-letter Bacon)

A=AAAAA  B=AAAAB  C=AAABA  D=AAABB  E=AABAA  F=AABAB
G=AABBA  H=AABBB  I/J=ABAAA  K=ABAAB  L=ABABA  M=ABABB
N=ABBAA  O=ABBAB  P=ABBBA  Q=ABBBB  R=BAAAA  S=BAAAB
T=BAABA  U/V=BAABB  W=BABAA  X=BABAB  Y=BABBA  Z=BABBB

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

Step-by-step Decoding

Splitting on structural characters {, }, _ and decoding each part:

EncodedGroupsDecoded
BAABAAAAABBAABA AAAABT B
AAAABAAAAAAAABAABBABABBAAAAAAB AAAAA AAABA ABBAB ABBAAB A C O N
ABAAABAAABABAAA BAAABI S
BAABAAAAAABAAABBAABABABBABAABA AAAAA BAAAB BAABA BABBAT A S T Y

Reassembled: TB{REDACTED}

Solve Script

python
#!/usr/bin/env python3
import re

BACON_24 = {
    'AAAAA': 'A', 'AAAAB': 'B', 'AAABA': 'C', 'AAABB': 'D',
    'AABAA': 'E', 'AABAB': 'F', 'AABBA': 'G', 'AABBB': 'H',
    'ABAAA': 'I', 'ABAAB': 'K', 'ABABA': 'L', 'ABABB': 'M',
    'ABBAA': 'N', 'ABBAB': 'O', 'ABBBA': 'P', 'ABBBB': 'Q',
    'BAAAA': 'R', 'BAAAB': 'S', 'BAABA': 'T', 'BAABB': 'U',
    'BABAA': 'W', 'BABAB': 'X', 'BABBA': 'Y', 'BABBB': 'Z',
}
‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

encoded = "BAABAAAAAB{AAAABAAAAAAAABAABBABABBAA_ABAAABAAAB_BAABAAAAAABAAABBAABABABBA}"

def decode_bacon(text):
    clean = ''.join(c for c in text if c in 'AB')
    return ''.join(BACON_24.get(clean[i:i+5], '?') for i in range(0, len(clean), 5))

# Split on structural characters, decode A/B parts, keep delimiters
parts = re.split(r'([{}_])', encoded)
result = ''.join(p if p in '{}_' else decode_bacon(p) for p in parts)
print(result)  # TB{REDACTED}

Output

TB{REDACTED}

Lessons Learned

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

  1. The Bacon cipher is a 5-bit encoding scheme — each letter maps to a unique 5-character A/B sequence
  2. The classic 24-letter variant merges I/J and U/V (important to know which variant is used)
  3. Task names in CTFs often contain direct hints — "ABA ABA?" is practically spelling out the cipher name
  4. When structural characters like {} and _ are preserved in the ciphertext, split on them first and decode each segment independently ‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

Key Takeaways / Lessons

  • Mastering bacon_decode, pattern_recognition was key to this challenge.
  • Always check for common misconfigurations and verify assumptions.

Crafted by XESXOR Research • 2026-02-14 • CUSTOM • ABA ABA? • Difficulty: Easy