← Back to Writeups
CUSTOMEasyCrypto

@bash — Atbash Cipher

XESXOR9/10/20261 min read
#crypto#custom#easy#atbash_decryption#linux

@bash — Atbash Cipher

Platform: spbctf | Category: Crypto | Type: Challenge | Difficulty: Easy | OS: Linux | Author: XESXOR | Date: 2026-03-08 | Status: Solved Techniques: atbash_decryption

Summary

Task: Decode Atbash-encrypted text with flag format. Solution: Apply Atbash cipher decryption (A↔Z substitution) to reveal the flag.

@bash — Crypto Kids 2.0

Description

Decode the text: HKyXGU{olo_gsrh_rh_zgyzhs}

Analysis

The task name "@bash" is a hint at the Atbash cipher. Atbash is a simple substitution cipher where each letter is replaced with its "mirror" in the alphabet:

  • A ↔ Z
  • B ↔ Y
  • C ↔ X
  • etc.

Solution

python
#!/usr/bin/env python3
def atbash(text):
    result = []
    for c in text:
        if c.isalpha():
            base = ord('A') if c.isupper() else ord('a')
            result.append(chr(base + 25 - (ord(c) - base)))
        else:
            result.append(c)
    return ''.join(result)
‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

ciphertext = "HKyXGU{olo_gsrh_rh_zgyzhs}"
print(atbash(ciphertext))
# Output: SPbCTF{REDACTED}

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