Skip to content

mhelail/HexTriage

Repository files navigation

HexTriage

AI-Powered Malware Triage — Static Analysis Only

HexTriage is a production-ready CLI tool for static malware triage. It combines PE parsing, string/YARA analysis, a weighted heuristics engine, and ML-based risk scoring using EMBER2024 pretrained LightGBM models — without executing samples.

  • Primary CLI: hextriage
  • Backward-compatible alias: triage

Why this matters

SOC analysts often need fast answers: Is this file likely malicious? What evidence supports that? Is it a legitimate dual-use tool (LOLBin)?
HexTriage accelerates triage by combining static evidence + ML probability, while explicitly separating dual-use risk from maliciousness to reduce noisy false positives.


Demo Screenshots

1) ML Proof — EMBER2024 Challenge Benchmark

Benchmark (EMBER2024 Challenge)

2) Dual-use Separation (Legitimate LOLBin Example)

PowerShell Scan (Dual-use)

3) Benign Baseline

Notepad Scan (Benign)


Key Features

Static Analyzers

  • PE Analysis: headers, sections, imports/exports, entropy, suspicious anomalies (e.g., RWX, abnormal sections)
  • Strings Analysis: ASCII/UTF-16LE extraction with suspicious indicator matching (URLs, IPs, PowerShell patterns)
  • YARA Scanning: rule-based matches with timeouts + safe error handling
  • Heuristics Engine: weighted rules that combine analyzer signals into an interpretable score
  • Optional Integrations: FLOSS (decoded strings) and capa (ATT&CK capabilities)

ML Scoring (EMBER2024)

  • EMBER2024 v3 features: 2568-dimensional vectors via thrember
  • LightGBM models: supports pretrained .model files and artifact models
  • Safe usage: inference on static features only; no sample execution

Dual-use Classification

  • LOLBin awareness: identifies legitimate system tools with abuse potential (PowerShell, certutil, rundll32, regsvr32, etc.)
  • Separates “abuse potential” from “malicious probability” to reduce false positives

Reporting

  • JSON reports (structured, versioned)
  • HTML reports (collapsible sections, evidence-first layout)

Model Management

  • ml list-models — finds pretrained thrember models and artifact models
  • ml validate-model — checks compatibility (feature dimension, required files)
  • ml benchmark — evaluates a LightGBM model on vectorized EMBER2024 features (no binaries required)

Safety Features

  • Static-only analysis (no execution, no emulation)
  • File size limits and timeouts
  • Defensive output (no offensive instructions)

Architecture Overview

┌─────────────┐
│  CLI (Typer)│
└──────┬──────┘
       │
┌──────▼──────────────────┐
│   Orchestrator          │
│  - Intake + limits      │
│  - Analyzer coordination│
│  - ML inference         │
└──────┬──────────────────┘
       │
   ┌───┴────────────────────────┬──────────────────┐
   │                            │                  │
┌──▼────────┐           ┌───────▼─────────┐  ┌────▼──────────┐
│ PE        │           │ Strings + YARA   │  │ Heuristics     │
│ Analyzer  │           │ FLOSS/capa (opt) │  │ Scoring        │
└───────────┘           └──────────────────┘  └────┬──────────┘
                                                    │
                                             ┌──────▼───────┐
                                             │ ML (EMBER2024)│
                                             └──────┬───────┘
                                                    │
                                             ┌──────▼───────┐
                                             │ Reports        │
                                             │ JSON + HTML     │
                                             └───────────────┘

Quick Start (Windows / PowerShell)

Installation

python -m venv .venv
.venv\Scripts\activate

# Core install
pip install -e .

# ML dependencies (EMBER2024 / thrember)
pip install -e ".[ml]"

Download Pretrained EMBER2024 Models

mkdir ml\artifacts\ember2024 -Force | Out-Null
python -c "import thrember; thrember.download_models('ml/artifacts/ember2024')"

Pretrained EMBER2024 Models (ML Scoring)

Models are not committed to the repo. Download locally to ml/artifacts/ember2024/.

pip install -e ".[ml]"
python -c "import thrember; thrember.download_models('ml/artifacts/ember2024')"
hextriage ml validate-model --model-path "ml/artifacts/ember2024"

Enable in config.yaml:

ml:
  enabled: true
  model_path: "ml/artifacts/ember2024"
  model_name: "EMBER2024_PE.model"   # optional (auto for PE)

Configuration

Create config.yaml:

limits:
  max_file_size_mb: 50
  timeout_seconds: 300
  yara_timeout_seconds: 60
  subprocess_timeout_seconds: 120

yara:
  rules_directory: "rules/"

ml:
  enabled: true
  model_path: "ml/artifacts/ember2024"
  model_name: "EMBER2024_PE.model"
  thresholds:
    benign: 0.30
    suspicious: 0.70
  calibration: "none"

reporting:
  include_safe_recommendations: true

Usage

Scan a File

hextriage scan "C:\Windows\System32\notepad.exe" --out reports\notepad.json --html reports\notepad.html

Dual-use Example

hextriage scan "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" --out reports\powershell.json --html reports\powershell.html

Expected style of output:

  • Verdict: BENIGN
  • Dual-use: YES (HIGH)
  • Malicious Probability: small % (model-based)

Proof: ML Catches Malicious Samples (EMBER2024 Challenge)

This benchmark evaluates the pretrained LightGBM model on vectorized EMBER2024 challenge features (no binaries are executed).

Command used:

hextriage ml benchmark -d data\ember2024_eval -s challenge -m ml\artifacts\ember2024\EMBER2024_all.model -o reports\benchmarks\benchmark_challenge.json

Output:

Benchmark Results
Dataset: data\ember2024_eval
Subset: challenge
Model: ml\artifacts\ember2024\EMBER2024_all.model

Dataset Statistics:
  Samples: 6,315
  Features: 2568
  Label distribution: {1: 6315}

Prediction Statistics:
  Mean: 0.6264
  Median: 0.6888
  Std: 0.3554
  Min: 0.0003
  Max: 0.9999

Fraction Above Thresholds:
  >= 0.3: 0.7528 (75.28%)
  >= 0.5: 0.6654 (66.54%)
  >= 0.7: 0.4918 (49.18%)
  >= 0.9: 0.3629 (36.29%)

Why this is credible and safe:

  • Uses vectorized features only (no malware binaries needed for benchmarking).
  • HexTriage performs static-only analysis and never executes samples.
  • Results provide measurable evidence that the ML scoring flags a large fraction of challenge samples at practical thresholds.

Reports

Key Fields

  • verdict: BENIGN / SUSPICIOUS / MALICIOUS
  • decision_confidence: HIGH / MODERATE / LOW
  • dual_use and abuse_potential: dual-use detection signal
  • malicious_probability: model probability (0.0–1.0)
  • heuristics: triggered rules + weighted scoring evidence

Development

pytest -q
ruff check src tests
black src tests

Roadmap

  • Add ROC-AUC / PR-AUC / confusion matrix to ml benchmark when labels include both 0 and 1
  • Improve “explanation” layer: top evidence contributors (rules + indicators)

License & Disclaimer

MIT License.

STATIC TRIAGE ONLY: HexTriage performs static analysis only and never executes, emulates, or runs samples. Use for defensive security purposes only and comply with applicable laws and policies.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published