Skip to main content

Fully Local, Decentralized Threat Defense

Project description

Leukquant — Fully Local, Decentralized Threat Defense

Zero cloud. Zero corporate telemetry. Zero single point of failure.

Python 3.10+ License: MIT


Overview

Leukquant is a fully offline, privacy-first endpoint threat-defense system. It combines on-device AI malware classification, a behavioral anomaly profiler, and post-quantum cryptography — all running locally with no cloud calls, no telemetry, and no account required.

The blockchain threat ledger is currently disabled. Detection relies on local ONNX AI models trained on datasets such as EMBER, VirusShare, and Kaggle malware corpora.


Features

Feature Description
Local AI Scanning On-device malware classification via ONNX RandomForest models. No telemetry.
Behavior Profiler Learns a 14-day baseline of normal system activity and flags statistical deviations using Z-score analysis.
Post-Quantum Crypto Vault Encrypts files with NIST PQC standards (ML-KEM-1024, ML-DSA-87, SLH-DSA). Falls back to X25519/Ed25519 when liboqs is unavailable.
Signature Database Local SQLite database of SHA-256 / MD5 threat hashes. Supports bulk VirusShare imports.
Offline Sync Export/import signed threat signatures as tamper-evident .lqsig bundles for air-gapped machines.
Quarantine Manager Isolates suspicious files with forensic secure-delete on removal.
Auto-Start Service Registers the monitor daemon as a systemd user unit (Linux) or Task Scheduler task (Windows).

Architecture

~/.leukquant/           ← all runtime data (override with LEUKQUANT_HOME)
  config/Leukquant.yml  ← YAML runtime config
  models/               ← ONNX model + .meta.json
  db/                   ← threats.db, behavior_baseline.db (SQLite)
  keys/                 ← kem.pub/priv, sig.pub/priv
  logs/                 ← monitor.pid, application logs
  quarantine/           ← isolated malicious files
  exports/              ← .lqsig signature bundles
  data/                 ← optional dataset downloads

Scan pipeline (two-stage):

  1. Signature lookup — SHA-256 and MD5 checked against threats.db.
  2. AI inference — 258-dim basic (file-size + Shannon entropy + byte histogram) or 2351-dim EMBER feature vector fed into an ONNX RandomForest.

Requirements

  • Python 3.10 or newer
  • Linux, macOS, or Windows

Optional — enable post-quantum cryptography:

# Install the liboqs C library first: https://github.com/open-quantum-safe/liboqs
pip install liboqs-python

Optional — enable the EMBER 2351-feature extractor:

pip install ember lief

Installation

git clone https://github.com/leukquant/leukquant
cd leukquant
pip install -r requirements.txt
pip install -e .

First-run initialization

Creates all required directories, SQLite databases, and a fresh PQ keypair:

leukquant init

Usage

1. Train the AI Model

# Synthetic data — no dataset needed (good for testing)
leukquant train

# EMBER 2018 PE dataset (~1 M samples, 2351 features)
leukquant train --source ember --ember-dir ~/data/ember2018

# VirusShare hash list → populates signature DB only (no ONNX model produced)
leukquant train --source virusshare --hash-list ~/VirusShare_00000.md5

# Kaggle CSV feature file
leukquant train --source kaggle --csv ~/malware_features.csv

# Raw binary sample directories
leukquant train --source files --malware-dir ~/samples/mal --benign-dir ~/samples/ok

2. Scan Files

# Scan a single file
leukquant scan --file /path/to/suspicious.exe

# Scan a directory recursively
leukquant scan --file /path/to/dir

# Auto-quarantine any file flagged as MALICIOUS
leukquant scan --file /path/to/dir --quarantine-on-detect

3. Behavior Monitor

# Foreground (Ctrl+C to stop)
leukquant monitor start

# Background daemon
leukquant monitor start --daemon

# Show live snapshot + recent anomalies
leukquant monitor status

# Stop the background daemon
leukquant monitor stop

4. Post-Quantum File Encryption

# Encrypt a file (produces secret.pdf.sqe)
leukquant encrypt --file secret.pdf

# Decrypt (produces secret.pdf.dec by default)
leukquant decrypt --file secret.pdf.sqe

# Decrypt to a specific output path
leukquant decrypt --file secret.pdf.sqe --key ~/.leukquant/keys/kem.priv --output secret.pdf

# Verify the digital signature of an encrypted bundle without decrypting it
leukquant verify --file secret.pdf.sqe

Key paths (defaults under ~/.leukquant/keys/):

  • Private KEM key: kem.priv
  • Public KEM key: kem.pub
  • Signing key: sig.priv / sig.pub

5. Key Management

# Generate a named keypair
leukquant keygen --name alice

6. Signature Management

# Manually add a hash to the local threat DB
leukquant add-sig --hash <sha256>

# Export all signatures to a signed bundle (for air-gap transfer)
leukquant export-sigs --output /media/usb/sigs.lqsig

# Import and verify a signature bundle
leukquant import-sigs --input /media/usb/sigs.lqsig

7. Quarantine

# List quarantined files
leukquant quarantine list

# Restore a quarantined file to its original location
leukquant quarantine restore --id <uuid-prefix>

# Permanently and securely delete a quarantined file
leukquant quarantine delete --id <uuid-prefix>

8. Auto-Start Service

# Install the monitor as a persistent service (survives reboots)
#   Linux   → systemd user unit (~/.config/systemd/user/leukquant.service)
#   Windows → Task Scheduler task (Leukquant\Monitor)
leukquant service install

# Remove the service
leukquant service uninstall

9. System Status Dashboard

leukquant status

Configuration

The config file is written to ~/.leukquant/config/Leukquant.yml on first run. Override the entire data directory with the LEUKQUANT_HOME environment variable.

Key settings:

behavior:
  baseline_period_days: 14
  alert_threshold: 3.5       # Z-score alert level
  quarantine_threshold: 5.0  # Z-score critical level

scanner:
  malware_threshold: 0.85    # AI confidence threshold (0.0–1.0)

crypto:
  default_kem: ML-KEM-1024
  default_sig: ML-DSA-87

Datasets for Training

Dataset Type URL
EMBER 2018 ~1 M labeled PE samples (2351 features) elastic/ember
VirusShare MD5 / SHA-256 hash lists virusshare.com/hashfiles (free, no login)
Kaggle Malware Various CSV feature datasets kaggle.com

After training, the model is saved to ~/.leukquant/models/malware_detector.onnx.


Source Layout

src/
  cli/main.py           CLI entry point (Click)
  scanner/
    scan.py             Two-stage scanner (signature DB + AI model)
    train.py            Model training pipeline
    extract.py          Feature extraction (basic 258-dim / EMBER 2351-dim)
    dataset_loaders.py  EMBER / VirusShare / Kaggle / file-dir loaders
  behavior/
    profiler.py         Z-score anomaly detection loop
    monitors.py         psutil + watchdog system-metrics collector
  crypto/
    pq_encrypt.py       ML-KEM + AES-256-GCM + ML-DSA encryption vault
    key_manager.py      Keypair generation, persistence, sign/verify
  db/database.py        SQLite layer (threats, metrics, quarantine, anomalies)
  quarantine/manager.py Quarantine move / restore / secure-delete
  offline/sync.py       .lqsig export/import with HMAC integrity (V2 format)
  service.py            systemd user unit / Task Scheduler installer
  config.py             YAML config with deep-merge defaults
  paths.py              Platform-aware APP_DIR (~/.leukquant)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

leukquant-0.1.1.tar.gz (45.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

leukquant-0.1.1-py3-none-any.whl (48.2 kB view details)

Uploaded Python 3

File details

Details for the file leukquant-0.1.1.tar.gz.

File metadata

  • Download URL: leukquant-0.1.1.tar.gz
  • Upload date:
  • Size: 45.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for leukquant-0.1.1.tar.gz
Algorithm Hash digest
SHA256 47da406a3375015f07e5b0abc9c7df9c698c3b413fff2fe697872946bc7f4184
MD5 e2ef20d0eba0142ff302c28927b9c6ae
BLAKE2b-256 a11a36fbec3e8c4820c28b1e8c7826f6ed7ff8eff79dc2c9ce2d01e49752e349

See more details on using hashes here.

File details

Details for the file leukquant-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: leukquant-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 48.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for leukquant-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ccef2c00e8433bb98cf05b532c8dfd3c324695720749ca086d3dd50f2a2e0e8a
MD5 24f54cdc9dd8c15a7b875d7bd7396442
BLAKE2b-256 de31cf71246b17d46829c229fa117fc59bb53f84fab454c7f7053c3b49eeca80

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page