Skip to content
Agentmart
Submit a tool

ctf-crypto-historical

CTF historical cipher attacks.

Skill by Yoraexe

IndexedMIT★ 1
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/yoraexe-ctf-crypto-historical

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

CTF historical cipher attacks. Lorenz SZ40/42 (Tunny) delta attack with known plaintext, ITA2/Baudot encoding, book cipher brute force. Triggers: 'lorenz cipher', 'tunny', 'ita2', 'baudot', 'book cipher', 'historical cipher', 'ww2 cipher', 'lorenz attack', 'wheel cipher', 'chi psi motor'.

Use cases: finance

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/ctf-crypto-historical

What's inside

Skill name
ctf-crypto-historical
Description
CTF historical cipher attacks. Lorenz SZ40/42 (Tunny) delta attack with known plaintext, ITA2/Baudot encoding, book cipher brute force. Triggers: 'lorenz cipher', 'tunny', 'ita2', 'baudot', 'book cipher', 'historical cipher', 'ww2 cipher', 'lorenz attack', 'wheel cipher', 'chi psi motor'.
License
MIT
Instructions
240 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

# CTF Crypto — Historical Ciphers

Lorenz SZ40/42 (Tunny), ITA2/Baudot, book cipher.

---

## Phase 1: Lorenz SZ40/42 (Tunny) Attack

```python
# Lorenz machine: 12 wheels encrypting 5-bit ITA2/Baudot characters
# Encryption: ciphertext[i] = plaintext[i] XOR chi[i] XOR psi[i]
#
# Wheel periods:
# χ (chi): 41, 31, 29, 26, 23 — advance every step
# Ψ (psi): 43, 47, 51, 53, 59 — advance only when μ37=1
# μ61: period 61 — advances every step, controls μ37 stepping
# μ37: period 37 — advances only when μ61=1, controls Ψ stepping

CHI_PERIODS = [41, 31, 29, 26, 23]
PSI_PERIODS = [43, 47, 51, 53, 59]

def delta_attack(plaintext_bits_list, ciphertext_bits_list, num_bits):
    """Recover chi wheels via delta (Δ) method with known plaintext."""
    
    # Step 1: Get keystream from known plaintext
    key_stream = [pt ^ ct for pt, ct in zip(plaintext_bits_list, ciphertext_bits_list)]
    N = len(key_stream)
    
    # Step 2: Compute delta keystream
    # delta_k = delta_chi XOR delta_psi
    # Since psi steps only ~25% of the time, delta_k BIASES toward delta_chi
    delta_k = [key_stream[i] ^ key_stream[i+1] for i in range(N-1)]
    
    # Step 3: Recover delta_chi via majority vote at each wheel phase
    recovered_chi = []
    for bit in range(5):
        P = CHI_PERIODS[bit]
        delta_k_bit = [(delta_k[i] >> bit) & 1 for i in range(len(delta_k))]
        
        delta_chi = []
        for phase in range(P):
            vals = [delta_k_bit[i] for i in range(phase, len(delta_k_bit), P)]
            delta_chi.append(1 if sum(vals) > len(vals)/2 else 0)
        
        # Step 4: Integrate to get chi (2 candidates: start 0 or 1)
        chi_candidates = []
        for start in [0, 1]:
            chi = [start]
            for i in range(P-1):
                chi.append(chi[-1] ^ delta_chi[i])
            chi_candidates.append(chi)
        
        recovered_chi.append(chi_candidates)
    
    return recovered_chi

def brute_force_lorenz(recovered_chi, ciphertext_5bit, known_plaintext_prefix):
    """Brute force remaining wheel starting positions."""
    
    # Total candidates: 2^5 (chi starts) × 61×37 (μ positions) × 2^5 (psi starts)
    # = ~2.3M — trivially brutable
    
    from itertools import product
    
    for chi_starts in product([0, 1], repeat=5):
        # Build chi sequence using recovered wheels + start position
        # Decrypt ciphertext
        # Check if decrypted prefix matches known plaintext
        pass
```

---

## Phase 2: ITA2/Baudot Encoding

```python
# Standard ITA2 (5-bit character encoding used in Lorenz challenges):

ITA2_CODE = {
    'A': 0b00011, 'B': 0b10011, 'C': 0b01110, 'D': 0b10010,
    'E': 0b10000, 'F': 0b10110, 'G': 0b01011, 'H': 0b00101,
    'I': 0b01100, 'J': 0b11010, 'K': 0b11110, 'L': 0b01001,
    'M': 0b00111, 'N': 0b00110, 'O': 0b00011, 'P': 0b01101,
    'Q': 0b11101, 'R': 0b01010, 'S': 0b10100, 'T': 0b00001,
    'U': 0b11100, 'V': 0b01111, 'W': 0b11001, 'X': 0b10111,
    'Y': 0b10101, 'Z': 0b10001,
    ' ': 0b00100, '\n': 0b00010, '\r': 0b01000,
    # Special: LTRS=0b11111, FIGS=0b11011
}

ITA2_DECODE = {v: k for k, v in ITA2_CODE.items()}

def baudot_decode(bits_5):
    """Decode 5-bit ITA2 code to character."""
    code = int(''.join(map(str, bits_5)), 2)
    return ITA2_DECODE.get(code, f'[{code:05b}]')

def text_to_baudot(text):
    """Convert text to 5-bit ITA2 codes."""
    return [ITA2_CODE[c] for c in text.upper() if c in ITA2_CODE]

# XOR operation on 5-bit ITA2 characters:
def xor_5bit(a, b):
    return a ^ b
```

---

## Phase 3: Book Cipher Brute Force

```python
# Pattern: password = positions in book text, encoded as "steps forward"
# Given: cipher_distances (list of integer steps), reference book text
# Attack: brute force starting position, filter by valid charset

def crack_book_cipher(cipher_distances, book_text, valid_chars=None):
    """Brute force book cipher starting position."""
    if valid_chars is None:
        import string

From Yoraexe/ceobe, MIT.

Signals

Stars
1
Forks
1
Open issues
0
Last commit (this folder)
Jul 17, 2026 (3 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from Yoraexe

Cite this page

ctf-crypto-historical skill. Agent Mart. https://agentmart.dev/skills/yoraexe-ctf-crypto-historical (last updated 2026-10-24)