Mysterybox
Mysterybox is a sanitized challenge note from the local HTB archive, organized for quick review by category, difficulty, evidence flow, and reusable operator
Scenario
Mysterybox attack path
Mysterybox is a sanitized challenge note from the local HTB archive, organized for quick review by category, difficulty, evidence flow, and reusable operator
Objective
Challenge walkthrough focused on Crypto evidence, validation, and reusable operator lessons.
Walkthrough flow
The service implements textbook RSA signing and...
The sign oracle blocks only the exact forbidden admin...
The hidden modulus can be recovered from GCDs of...
After recovering n, choose an allowed factor a and...
Multiplying sig(a) and sig(b) modulo n gives a valid...
Source coverage
High source coverage
Status: complete. This article is generated from 4 sanitized Markdown sources and keeps raw flags, credentials, keys, cookies, and reusable secrets out of the rendered blog.
High confidence: the page is reconstructed from a primary walkthrough plus multiple supporting notes or evidence sources. Treat the chain as source-backed, while still checking the listed source files for sensitive values.
- Crypto/Mysterybox/writeup.md
- htb-challenge/Crypto/Mysterybox/notes.md
- htb-challenge/Crypto/Mysterybox/memory-summary.md
- htb-challenge/Crypto/Mysterybox/hypothesis-board.md
Technical Walkthrough
Writeup
Challenge
- Name: Mysterybox
- Category: Crypto
- Difficulty: Medium
- Mode: hybrid
Summary
Mysterybox is a raw RSA signing-oracle challenge. The server hides the public key but exposes signing and verification. It refuses to sign one specific admin message residue, but the implementation is textbook RSA, so signatures remain multiplicative.
The solve recovers the hidden modulus from signature relations, then forges a valid signature for the blocked admin message by multiplying signatures for two allowed residues.
Artifact Inventory
files/extracted/crypto_mysterybox/server.py: challenge source for the signing server.analysis/artifact-inventory.json: archive inventory.- Remote service:
<TARGET>:32087.
Analysis
The source in files/extracted/crypto_mysterybox/server.py shows:
sign(message) = pow(message, d, n)verify(message, signature)checkspow(signature, e, n) == messagenandeare hidden from the user- signing is blocked only when
msg % n == admin_message
Raw RSA is multiplicative:
sign(a) * sign(b) == sign(a * b) mod nFor signed messages a, b, and a*b, this means:
sign(a) * sign(b) - sign(a*b)is a multiple of n. The solver asks for signatures on several small products and computes the GCD of those differences to recover the hidden modulus.
After recovering n, the solver chooses an allowed factor a = 2 and computes:
b = admin_message * inverse(a, n) mod nThe server signs both a and b, and multiplying those signatures modulo n creates a valid signature for the forbidden admin message.
The source-backed solve plan is in analysis/solve-plan.md. RAG was recorded as advisory and validated against current source before use.
Solve
Run:
python3 solve/solve.py <TARGET> 32087 --output loot/flag-candidate.txtThe script keeps all operations in one connection, because the server generates a fresh RSA keypair per process. It writes the admin verification response to loot/flag-candidate.txt; the harness then extracts the flag into loot/flag.txt.
Flag
Raw flag is stored in loot/flag.txt and intentionally not reproduced here.
Lessons
- Hiding
ndoes not protect textbook RSA signing if multiplicative signature relations are exposed. - A “do not sign this exact message” check is insufficient when signatures for related residues are available.
- For remote crypto challenges with per-connection key generation, keep modulus recovery and forgery inside the same session.
Source-Backed Dossier
The sections below are merged from companion Markdown notes for the same case. They are rendered after sanitization so the article stays precise without publishing raw flags, credentials, or target-specific secrets.
Notes
Scope
- Challenge: Mysterybox
- Category: Crypto
- Difficulty: Medium
- Mode: hybrid
- Remote instance: <TARGET>:32087
- Start time: 2026-06-13T10:29:34Z
- Operator: harness
- State file:
challenge-state.json
Harness Status
- Current phase: see
challenge-state.json - Next allowed actions: see
next-action.json - Raw flags and sensitive material stay in
loot/only. Do not paste them here.
Artifact Inventory
| File | Size | SHA256 | Type | Notes |
|---|---|---|---|---|
files/a12c7340-a70d-4dea-8c46-b733e53c142e.zip | 1225 | <hash redacted> | Zip archive data, at least v1.0 to extract, compression method=store | zip entries: 2 shown in artifact inventory JSON |
Evidence Ledger
| Time | Action | Output/File | Finding | Confidence | Next |
|---|---|---|---|---|---|
| 2026-06-13T10:29:34Z | harness init | challenge-state.json | Workspace initialized with deterministic state file | High | Inventory artifacts |
| 2026-06-13T10:29:49Z | artifact inventory | analysis/artifact-inventory.json | 1 artifact(s) inventoried | High | Build or update hypotheses |
| 2026-06-13T10:30:41Z | hypothesis recorded | hypothesis-board.md | Recover the hidden RSA modulus from multiplicative signature relations, then forge the forbidden admin signature by asking for signatures on two allowed factors whose product is congruent to the admin message mod n. | Medium | Sign 2,3,6 and compute gcd(sig2*sig3-sig6, ...); then test a forged signature for the admin message. |
| 2026-06-13T10:30:41Z | instrumentation plan | analysis/instrumentation-plan.md | Build a reproducible solver that recovers n from signature multiplicativity and forges the admin signature without signing the forbidden message directly. | High | Stop after two failed remote forgery attempts without new modulus/parser evidence; record failure and reassess message encoding or modulus recovery. |
| 2026-06-13T10:30:50Z | research task | analysis/research/task-20260613T103050435448Z-1e133dd2.md | Research task created for advisory investigation | Medium | Record research output |
| 2026-06-13T10:31:04Z | source audit | analysis/source-audit.md | Source audit recorded | High | Gate before exploit |
| 2026-06-13T10:31:21Z | RAG query | analysis/rag/rag-query-20260613T103104327004Z-7ba71097.txt | RAG helper exited 0; output saved | Medium | Record retrieval tag and validation |
| 2026-06-13T10:32:37Z | research record | analysis/research/research-records.md | Research tagged MATCHED | Medium | Validate against current evidence |
| 2026-06-13T10:32:37Z | RAG record | analysis/rag-records.md | Retrieved memory tagged PARTIAL | Medium | Validate or reject with live evidence |
| 2026-06-13T10:32:37Z | checkpoint recorded | analysis/checkpoint-analysis-20260613T103237295814Z-6e2f5954.md | Checkpoint for ANALYSIS | High | Use checkpoint to drive next decision |
| 2026-06-13T10:32:47Z | evaluator | analysis/evaluator-20260613T103247734058Z-1214fc64.md | Proceed | High | Gate before exploit, run solve.py, then capture loot/flag-candidate.txt. |
| 2026-06-13T10:33:10Z | flag capture | loot/flag.txt | HTB-format flag captured; raw value kept in loot only | High | Write solution and run completion gate |
| 2026-06-13T10:34:07Z | completion gate | challenge-state.json | Completion gate passed; state marked COMPLETE | High | Optional sanitized memory summary approval |
Key Findings
- Remote endpoint:
<TARGET>:32087. - The server uses raw RSA signatures and hides
n/e. - Multiplicative signature relations leak the hidden modulus via GCD.
- The forbidden admin message can be forged by signing two allowed residues whose product is congruent to the admin message.
- Raw flag is stored only at
loot/flag.txt.
RAG / Advisory Memory
RAG output is advisory only. Record evaluated retrievals with:
scripts/challenge_harness.py rag-record <workspace> --query "..." --tag MATCHED|PARTIAL|MISSING|<secret redacted>|GENERIC --validation "..."Secrets/Flags
Raw flags and sensitive material stay in loot/ only. Use scripts/challenge_harness.py capture-flag to validate and record flag capture without printing the value.
Memory Summary
Metadata
- Platform: HackTheBox Challenges
- Category: Crypto
- Challenge: Mysterybox
- Difficulty: Medium
- Source workspace:
<local workspace>
Validated Solve Chain
Concepts only. Do not include raw flags, reusable credentials, tokens, cookies, private keys, or live secrets.
- The service implements textbook RSA signing and verification while hiding
nande. - The sign oracle blocks only the exact forbidden admin residue.
- The hidden modulus can be recovered from GCDs of multiplicative signature differences:
sig(a) sig(b) - sig(ab). - After recovering
n, choose an allowed factoraand computeb = target * inverse(a, n) mod n. - Multiplying
sig(a)andsig(b)modulongives a valid signature for the forbidden target message.
Reusable Lessons
- Hiding an RSA modulus does not prevent recovery when raw signing exposes multiplicative relations.
- Direct forbidden-message checks do not stop blind multiplicative forgery in textbook RSA.
- If a remote service regenerates keys per process/session, perform modulus recovery and forgery on the same connection.
Dead Ends
- None material. The source-backed RSA multiplicativity path was direct.
Tool Quirks
- No heavy math tooling was required; Python
math.gcdand modular inverse were enough. - Solver writes raw remote flag response to
loot/flag-candidate.txtand the harness extractsloot/flag.txt.
Evidence Paths
files/extracted/crypto_mysterybox/server.pyanalysis/server.py.txtanalysis/solve-plan.mdsolve/solve.pyloot/flag.txt
Ingestion Decision
- Proposed for LightRAG: yes, sanitized technique only
- Requires user approval before ingestion: yes
Hypothesis Board
Keep no more than 3 active hypotheses on Easy/Medium and 5 on Hard unless the user explicitly asks for breadth.
| Rank | Path | Evidence | Missing Proof | Cheapest Validation | Confidence | Status |
|---|---|---|---|---|---|---|
| 1 | Recover the hidden RSA modulus from multiplicative signature relations, then forge the forbidden admin signature by asking for signatures on two allowed factors whose product is congruent to the admin message mod n. | server.py uses raw RSA signatures, hides n/e, signs arbitrary messages except msg % n == admin, and verify only checks pow(signature,e,n) == message. | Sign 2,3,6 and compute gcd(sig2*sig3-sig6, ...); then test a forged signature for the admin message. | Medium | Active |
Closed Branches
| Branch | Evidence Tested | Failure Output | Reason Closed | Revisit Condition |
|---|
Technical analogy
How to remember this solve
Think of the challenge like a locked box where the lock is mathematical but slightly flawed. The goal is not to smash the box; it is to notice which part of the lock repeats, leaks, or trusts the wrong assumption.
For Mysterybox, keep the mental model simple: identify the trusted assumption, prove it with the smallest safe test, then automate or repeat only the part that directly leads to the flag.