Challenge / Crypto

Quantum Safe

Quantum Safe is a sanitized challenge note from the local HTB archive, organized for quick review by category, difficulty, evidence flow, and reusable operator

EasyPublished 2024-05-07Sanitized local writeup

Scenario

Quantum Safe attack path

Quantum Safe 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.

Quantum Safe sanitized attack graph

Walkthrough flow

01

Extracted the HTB archive and found source.sage plus...

02

Identified the encryption as a per-character integer...

03

Observed that the fixed offset vector r has only 11^3...

04

Brute-forced r, inverted the public matrix over exact...

05

Filtered candidates by printable proof characters and...

Source coverage

High source coverage

Status: complete. This article is generated from 6 sanitized Markdown sources and keeps raw flags, credentials, keys, cookies, and reusable secrets out of the rendered blog.

100% coverage
Evidence verdict

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/Quantum-Safe/writeup.md
  • htb-challenge/Crypto/Quantum-Safe/notes.md
  • htb-challenge/Crypto/Quantum-Safe/memory-summary.md
  • htb-challenge/Crypto/Quantum-Safe/hypothesis-board.md
  • HTB/_knowledge/exports/ctf-lightrag-latest-203412/documents/challenge__Crypto__Quantum-Safe__memory-summary.md.c4efb25cb1.md
  • HTB/_knowledge/exports/ctf-lightrag-latest-203412/documents/challenge__Crypto__Quantum-Safe__notes.md.922ae8e2e8.md

Technical Walkthrough

Writeup

Challenge

  • Name: Quantum-Safe
  • Category: Crypto
  • Difficulty: Easy
  • Mode: file

Summary

The challenge presents itself as “quantum safe,” but the provided Sage source uses a small linear transformation over the integers. The only unknown global value is a three-entry offset vector sampled from 0..10, so the solve is exact linear algebra plus a tiny brute force.

Artifact Inventory

Reference analysis/artifact-inventory.json and summarize the relevant files or remote surface.

  • source.sage: encryption source that defines pubkey, the fixed random offset vector r, and the per-character encoding.
  • output.txt: one transformed 3-vector per flag character.
  • No remote instance is required.

Analysis

The Sage source writes each character as:

text
[ord(c), random_1, random_2] * pubkey + r

The two random coordinates are bounded to 0..100, and the shared offset vector r is bounded to 0..10 for each coordinate. Because pubkey is invertible, every candidate r can be tested by subtracting it from each output row and multiplying by pubkey^-1.

The correct offset is the only candidate that makes every recovered vector integral, keeps the first coordinate printable, and keeps the two random coordinates inside 0..100.

Solve

Run:

bash
python3 solve/solve.py

The script parses output.txt, brute-forces all 11^3 possible offset vectors, inverts the matrix using exact rational arithmetic, filters invalid candidates, and prints the unique HTB-format flag.

Flag

Raw flag is stored in loot/flag.txt and intentionally not reproduced here.

Lessons

  • A source-provided “post-quantum” theme can still reduce to ordinary linear algebra.
  • Small global randomness should be brute-forced before attempting heavier tooling.
  • Exact rational arithmetic avoids false positives from floating-point matrix inversion.

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: Quantum-Safe
  • Category: Crypto
  • Difficulty: Easy
  • Mode: file
  • Remote instance: none
  • Start time: 2026-06-10T09:03:10Z
  • 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

FileSizeSHA256TypeNotes
files/a12c7372-6265-41cb-8cf6-f2e93630c2d4.zip1261<hash redacted>Zip archive data, at least v1.0 to extract, compression method=storezip entries: 3 shown in artifact inventory JSON
files/extracted/crypto_quantum_safe/output.txt947<hash redacted>CSV text
files/extracted/crypto_quantum_safe/source.sage320<hash redacted>ASCII text, with CRLF line terminators

Evidence Ledger

TimeActionOutput/FileFindingConfidenceNext
2026-06-10T09:03:10Zharness initchallenge-state.jsonWorkspace initialized with deterministic state fileHighInventory artifacts
2026-06-10T09:03:21Zartifact inventoryanalysis/artifact-inventory.json3 artifact(s) inventoriedHighBuild or update hypotheses
2026-06-10T09:04:44Zhypothesis recordedhypothesis-board.mdInvert the provided linear map after brute-forcing the tiny fixed offset vector r.MediumBrute-force r in 11^3 candidates, invert pubkey over exact rationals, and require printable chars plus noise coordinates in 0..100.
2026-06-10T09:04:44Zresearch recordanalysis/research/research-records.mdResearch tagged MATCHEDMediumValidate against current evidence
2026-06-10T09:04:44Zflag captureloot/flag.txtHTB-format flag captured; raw value kept in loot onlyHighWrite solution and run completion gate
2026-06-10T09:05:32Zcompletion gatechallenge-state.jsonCompletion gate passed; state marked COMPLETEHighOptional sanitized memory summary approval

Key Findings

  • source.sage is the authoritative encryption logic.
  • Each flag character is encoded independently as [ord(c), randint(0,100), randint(0,100)] * pubkey + r.
  • The fixed offset r is sampled once as a 3-vector with values in 0..10, making exhaustive search only 11^3 candidates.
  • For the correct r, multiplying each adjusted output vector by pubkey^-1 over exact rationals recovers integral triples.
  • The first recovered coordinate is the flag character, while the second and third coordinates must remain within 0..100.
  • The solver found a unique HTB-format candidate and captured it via the harness into loot/flag.txt.

RAG / Advisory Memory

RAG output is advisory only. Record evaluated retrievals with:

bash
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: Quantum-Safe
  • Difficulty: Easy
  • Source workspace: <local workspace>

Validated Solve Chain

Concepts only. Do not include raw flags, reusable credentials, tokens, cookies, private keys, or live secrets.

  1. Extracted the HTB archive and found source.sage plus output.txt.
  2. Identified the encryption as a per-character integer vector transformation: [ord(c), noise1, noise2] * pubkey + r.
  3. Observed that the fixed offset vector r has only 11^3 possible values.
  4. Brute-forced r, inverted the public matrix over exact rationals, and required each recovered row to be integral.
  5. Filtered candidates by printable flag characters and bounded noise coordinates in 0..100.
  6. Recovered one unique HTB-format flag and captured it with the challenge harness.

Reusable Lessons

  • For source-based crypto challenges, inspect the data model and randomness bounds before reaching for specialized tooling.
  • If a linear map is invertible and the global random offset is small, brute-force the offset and solve exactly.
  • Use rational/integer arithmetic for matrix recovery to avoid floating-point precision mistakes.

Dead Ends

  • Sage was not installed locally, but it was unnecessary because the source translated cleanly to Python.
  • Heavy crypto or quantum-specific tooling was not needed.

Tool Quirks

  • Local tool_readiness.py reported Sage, sympy, and z3 missing.
  • The final solver uses only Python standard library modules.

Evidence Paths

  • files/extracted/crypto_quantum_safe/source.sage
  • files/extracted/crypto_quantum_safe/output.txt
  • analysis/research/local-crypto-strategy.md
  • solve/solve.py
  • loot/flag.txt

Ingestion Decision

  • Proposed for LightRAG: yes
  • 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.

RankPathEvidenceMissing ProofCheapest ValidationConfidenceStatus
1Invert the provided linear map after brute-forcing the tiny fixed offset vector r.source.sage encrypts [ord(c), randint(0,100), randint(0,100)] * pubkey + r, with r entries in 0..10.Brute-force r in 11^3 candidates, invert pubkey over exact rationals, and require printable chars plus noise coordinates in 0..100.MediumActive

Closed Branches

BranchEvidence TestedFailure OutputReason ClosedRevisit Condition

Memory Summary

approval_required: true

Sanitized Memory Summary

Metadata

  • Platform: HackTheBox Challenges
  • Category: Crypto
  • Challenge: Quantum-Safe
  • Difficulty: Easy
  • Source workspace: <local workspace>

Validated Solve Chain

Concepts only. Do not include raw flags, reusable credentials, tokens, cookies, private keys, or live secrets.

  1. Extracted the HTB archive and found source.sage plus output.txt.
  2. Identified the encryption as a per-character integer vector transformation: [ord(c), noise1, noise2] * pubkey + r.
  3. Observed that the fixed offset vector r has only 11^3 possible values.
  4. Brute-forced r, inverted the public matrix over exact rationals, and required each recovered row to be integral.
  5. Filtered candidates by printable flag characters and bounded noise coordinates in 0..100.
  6. Recovered one unique HTB-format flag and captured it with the challenge harness.

Reusable Lessons

  • For source-based crypto challenges, inspect the data model and randomness bounds before reaching for specialized tooling.
  • If a linear map is invertible and the global random offset is small, brute-force the offset and solve exactly.
  • Use rational/integer arithmetic for matrix recovery to avoid floating-point precision mistakes.

Dead Ends

  • Sage was not installed locally, but it was unnecessary because the source translated cleanly to Python.
  • Heavy crypto or quantum-specific tooling was not needed.

Tool Quirks

  • Local tool_readiness.py reported Sage, sympy, and z3 missing.
  • The final solver uses only Python standard library modules.

Evidence Paths

  • files/extracted/crypto_quantum_safe/source.sage
  • files/extracted/crypto_quantum_safe/output.txt
  • analysis/research/local-crypto-strategy.md
  • solve/solve.py
  • loot/flag.txt

Ingestion Decision

  • Proposed for LightRAG: yes
  • Requires user approval before ingestion: yes

Notes

Notes

Scope

  • Challenge: Quantum-Safe
  • Category: Crypto
  • Difficulty: Easy
  • Mode: file
  • Remote instance: none
  • Start time: 2026-06-10T09:03:10Z
  • 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

FileSizeSHA256TypeNotes
files/a12c7372-6265-41cb-8cf6-f2e93630c2d4.zip1261<hash redacted>Zip archive data, at least v1.0 to extract, compression method=storezip entries: 3 shown in artifact inventory JSON
files/extracted/crypto_quantum_safe/output.txt947<hash redacted>CSV text
files/extracted/crypto_quantum_safe/source.sage320<hash redacted>ASCII text, with CRLF line terminators

Evidence Ledger

TimeActionOutput/FileFindingConfidenceNext
2026-06-10T09:03:10Zharness initchallenge-state.jsonWorkspace initialized with deterministic state fileHighInventory artifacts
2026-06-10T09:03:21Zartifact inventoryanalysis/artifact-inventory.json3 artifact(s) inventoriedHighBuild or update hypotheses
2026-06-10T09:04:44Zhypothesis recordedhypothesis-board.mdInvert the provided linear map after brute-forcing the tiny fixed offset vector r.MediumBrute-force r in 11^3 candidates, invert pubkey over exact rationals, and require printable chars plus noise coordinates in 0..100.
2026-06-10T09:04:44Zresearch recordanalysis/research/research-records.mdResearch tagged MATCHEDMediumValidate against current evidence
2026-06-10T09: <REDACTED>
2026-06-10T09:05:32Zcompletion gatechallenge-state.jsonCompletion gate passed; state marked COMPLETEHighOptional sanitized memory summary approval

Key Findings

  • source.sage is the authoritative encryption logic.
  • Each flag character is encoded independently as [ord(c), randint(0,100), randint(0,100)] * pubkey + r.
  • The fixed offset r is sampled once as a 3-vector with values in 0..10, making exhaustive search only 11^3 candidates.
  • For the correct r, multiplying each adjusted output vector by pubkey^-1 over exact rationals recovers integral triples.
  • The first recovered coordinate is the flag character, while the second and third coordinates must remain within 0..100.
  • The solver found a unique HTB-format candidate and captured it via the harness into loot/flag.txt.

RAG / Advisory Memory

RAG output is advisory only. Record evaluated retrievals with:

bash
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.

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 Quantum Safe, 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.