Skip to content

DhakshinP/quantum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quantum

Quantum is a forensic security tool for scanning compiled binaries and identifying cryptographic implementations that are vulnerable in a post-quantum threat model. It focuses on ELF, PE, and Mach-O binaries, extracts executable instructions, analyzes assembly patterns with machine learning, and recommends post-quantum cryptography remediations when RSA or ECC usage is detected.

Product Overview

The goal of Quantum is to help security teams, reverse engineers, and platform owners answer a practical question:

Which shipped binaries are still using cryptography that should be replaced before large-scale quantum attacks become viable?

Quantum performs that analysis in a pipeline:

  1. Parse compiled binaries and locate executable sections.
  2. Disassemble machine code into opcode sequences.
  3. Chunk opcode streams into model-friendly windows.
  4. Classify each chunk for cryptographic risk patterns.
  5. Aggregate findings into a JSON scorecard and dashboard view.

The current scaffold includes:

  • A binary extraction engine for ELF, PE, and Mach-O parsing.
  • A CodeBERT-backed inference module with a heuristic fallback path.
  • A scanner that computes PQC compliance and remediation guidance.
  • A FastAPI backend with file upload scanning.
  • A lightweight web dashboard for interacting with the scanner.
  • A test data generator for building benign and crypto-linked sample binaries.

Tech Stack

Quantum is built with the following stack:

  • Python 3.12: Primary application runtime.
  • LIEF: Binary parsing for ELF, PE, and Mach-O inspection.
  • Capstone: Disassembly of executable sections into assembly opcode streams.
  • PyTorch: Model execution runtime.
  • Hugging Face Transformers: Loading and tokenizing microsoft/codebert-base.
  • FastAPI: API server and dashboard delivery.
  • Uvicorn: ASGI server for local development and deployment.
  • Pydantic: Request and response validation support through FastAPI.

Architecture

extractor.py

BinaryProcessor loads a binary with LIEF, identifies executable sections such as .text, disassembles raw bytes with Capstone, and emits sliding windows of opcode text for downstream ML processing.

model.py

Loads microsoft/codebert-base through Hugging Face and exposes predict_crypto_risk(opcode_chunk). The current scaffold assumes a future fine-tuned classification head for:

  • RSA
  • ECC
  • PQC-Safe

If a fine-tuned head or model weights are unavailable, the module falls back to a heuristic classifier so the rest of the system can still run end to end.

scanner.py

Coordinates extraction and inference, then aggregates results into a Quantum Risk Scorecard. If RSA or ECC appears in more than 1% of analyzed chunks, the scanner sets quantum_ready to False.

main.py

Provides:

  • POST /scan for binary upload scanning
  • / for the browser dashboard
  • CLI usage through python main.py --file ./path/to/binary

static/

Contains the dashboard frontend:

  • index.html
  • styles.css
  • app.js

The dashboard gives a simple security-operations-style interface for file upload, scan status, compliance display, and vulnerability review.

generate_test.py

Generates two small C programs and attempts to compile them:

  • An OpenSSL RSA sample to simulate crypto-heavy behavior
  • A hello-world control binary for a benign baseline

Risk Mapping

Quantum currently maps the following algorithm detections to remediation guidance:

  • RSA -> High Risk -> Replace with ML-KEM / Kyber
  • ECC -> High Risk -> Replace with ML-DSA / Dilithium
  • PQC-Safe -> Low Risk -> Post-quantum-ready implementation detected

Example Response

{
  "filename": "app.exe",
  "pqc_compliance": "FAILED",
  "vulnerabilities": [
    {
      "type": "RSA",
      "confidence": 0.98,
      "location": "0x401000",
      "section": ".text",
      "remediation": "High Risk (Replace with ML-KEM/Kyber)"
    }
  ],
  "remediation": "Update to NIST FIPS 203 (ML-KEM/Kyber)"
}

Local Setup

./setup.sh
source .venv/bin/activate

Run The Dashboard

python main.py --serve

Open:

  • http://localhost:8000 for the dashboard
  • http://localhost:8000/docs for the API docs

Run A CLI Scan

python main.py --file ./test_binary

Generate Test Binaries

python generate_test.py

If OpenSSL development libraries are available, this script will also produce an RSA-linked sample binary.

Current Status

This repository is an initial working scaffold for the product. The binary extraction and API flow are implemented, while the ML classification layer is still set up as a baseline wrapper around CodeBERT and is ready for a real fine-tuned classification head.

Roadmap Ideas

  • Train and attach a real classification head for binary-level crypto detection.
  • Add persistent scan history and artifact management.
  • Expand detections beyond RSA and ECC into classical signature and key exchange families.
  • Support richer symbol-aware and control-flow-aware feature extraction.
  • Add authentication and team workflows for production deployment.

About

An ML-driven security framework utilizing transformer-based opcode analysis to detect and remediate quantum vulnerable cryptography within compiled software and data lakes.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors