Skip to content
Agentmart
Submit a tool

ctf-crypto-prng

CTF PRNG attacks.

Skill by Yoraexe

IndexedMIT★ 1
Write a review

Chalk Labs

Need help deploying ctf-crypto-prng?

Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.

Book a call

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-prng

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 PRNG attacks. Mersenne Twister state recovery, time-seeded PRNG brute force, LCG parameter recovery, V8 Math.random XorShift128+ Z3 solver, GF(2) matrix approach. Triggers: 'prng attack', 'mersenne twister', 'random seed', 'predictable random', 'lcg attack', 'math.random crack', 'random state recovery', 'prng prediction', 'twister untemper'.

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-prng

What's inside

Skill name
ctf-crypto-prng
Description
CTF PRNG attacks. Mersenne Twister state recovery, time-seeded PRNG brute force, LCG parameter recovery, V8 Math.random XorShift128+ Z3 solver, GF(2) matrix approach. Triggers: 'prng attack', 'mersenne twister', 'random seed', 'predictable random', 'lcg attack', 'math.random crack', 'random state recovery', 'prng prediction', 'twister untemper'.
License
MIT
Instructions
250 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

# CTF Crypto — PRNG Attacks

Mersenne Twister state recovery, time-seeded brute force, LCG, V8 Math.random.

---

## Phase 1: Identify PRNG Type

```python
# Python random (Mersenne Twister):
import random
# Generated: random.random(), random.randint(), random.choice()
# Internal state: 624 32-bit integers

# C rand() (LCG):
# state = state * 1103515245 + 12345
# output = (state >> 16) & 0x7fff

# JavaScript Math.random (V8 XorShift128+):
# 128-bit state, outputs doubles

# Custom PRNG (identify from source):
# LCG: x[n+1] = (a*x[n] + c) mod m
# LFSR: shift register with XOR taps
```

---

## Phase 2: Mersenne Twister State Recovery

```python
# Need: 624 consecutive 32-bit outputs (from random.getrandbits(32))

def untemper(y):
    """Reverse the Mersenne Twister temper operation."""
    # Inverse of y ^= y >> 18:
    y ^= y >> 18
    # Inverse of y ^= (y << 15) & 0xefc60000:
    y ^= (y << 15) & 0xefc60000
    # Inverse of y ^= (y << 7) & 0x9d2c5680:
    y ^= (y << 7) & 0x9d2c5680
    y ^= (y << 14) & (0x9d2c5680 & (0x9d2c5680 << 7))
    # Inverse of y ^= y >> 11:
    y ^= y >> 11
    y ^= y >> 22
    return y & 0xFFFFFFFF

# Collect 624 outputs from target:
outputs = [int(input(f"Output {i}: "), 16) for i in range(624)]

# Recover internal state:
state = [untemper(y) for y in outputs]

# Reconstruct random module state:
import random

# Inject recovered state:
state_formatted = [3, *state, 624]
random.setstate((3, tuple(state_formatted), None))

# Now predict all future outputs:
print("Next:", random.getrandbits(32))
print("Next:", random.getrandbits(32))
```

---

## Phase 3: Time-Seeded PRNG Brute Force

```python
import random, time, ctypes

# UNIX timestamp seeded:
TARGET_TOKENS = [...]    # observed tokens from target

def crack_seed_unix(tokens, window=3600):
    """Try timestamps in a window around now."""
    now = int(time.time())
    
    for seed in range(now - window, now + 1):
        random.seed(seed)
        candidate_tokens = [random.randint(0, 2**32) for _ in range(len(tokens))]
        if candidate_tokens == tokens:
            print(f"Seed: {seed} (unix timestamp)")
            return seed
    return None

# C rand() seeded (use ctypes to sync with libc):
libc = ctypes.CDLL("libc.so.6")

def crack_c_rand(target_values, window=3600):
    now = int(time.time())
    
    for seed in range(now - window, now + 1):
        libc.srand(seed)
        candidates = [libc.rand() for _ in range(len(target_values))]
        if candidates == target_values:
            print(f"C rand() seed: {seed}")
            return seed
    
# Millisecond precision from file metadata:
import os
stat = os.stat("generated_file.txt")
mtime_ms = int(stat.st_mtime * 1000)

for seed in range(mtime_ms - 100, mtime_ms + 100):
    random.seed(seed)
    # test...
```

---

## Phase 4: LCG Parameter Recovery

```python
# LCG: x[n+1] = (a * x[n] + c) mod m
# Given several consecutive outputs, recover a, c, m

def recover_lcg(outputs):

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

Done for you

Rather not set it up yourself?

Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.

See how we build AI agents →Read the case studies

Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.

launches shipped
50+
launches shipped
media placements
500+
media placements
founders on every account
2
founders on every account

Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block

Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.

Get ctf-crypto-prng running in your business

Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.

Goes to the Chalk Labs founders, not the newsletter. Privacy

Need help deploying ctf-crypto-prng?

CallGet help
Cite this page

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