Skip to main content

PackerScope

PackerScope is a production-grade Python framework for automated Windows PE packer detection, classification, and unpacking. Designed for defensive security analysts, reverse engineers, and malware analysis laboratories.


Features

  • Multi-layered Detection Pipeline:

    • Entropy Analysis: Measures Shannon entropy across whole files, sections, and via sliding-window heuristics.
    • Section Analysis: Detects anomalous section names (e.g., UPX0, .vmp0), extreme virtual-to-raw size ratios, and abnormal permissions (RWX).
    • IAT Analysis: Analyzes Import Address Table sparseness and suspicious loader API usage.
    • Entry Point Analysis: Disassembles entry point instructions using Capstone to detect stubs, jump chains, and trampolines.
    • Structure Analysis: Identifies structural PE header anomalies, misaligned headers, and invalid metadata.
    • Signature Matching: Built-in byte-pattern scanning using PEiD database signatures.
    • YARA Scanning: Deep static analysis utilizing community or custom YARA rules.
    • Heuristic Aggregator: Combines weighted multi-module signals into an ensemble packing verdict.
  • Automated Unpacking:

    • UPXUnpacker: Native decompression using the UPX binary.
    • GenericStaticUnpacker: Framework for static decompression routines.
    • DynamicUnpacker: Dynamic emulation and instrumentation unpacker integration.
  • Verification Subsystem: Automatically verifies unpacked binaries by validating PE integrity, entropy reduction, and IAT restoration.

  • Multi-Format Reporting: Generates structured reports in JSON, CSV, Markdown, and HTML formats.


Installation

From PyPI

pip install packerscope

From Source

git clone https://github.com/salmanmallah/packerscope.git
cd packerscope
pip install .

Optional Dependencies

For additional disassembly, YARA, or dynamic analysis capabilities:

pip install "packerscope[all]"

Quickstart (Python API)

PackerScope provides a simple, high-level Python API designed for rapid analysis and easy scripting.

Basic Analysis

import packerscope

# Analyze a single binary
result = packerscope.scan("path/to/sample.exe")

if result.is_packed:
    print(f"File is packed with {result.packer.upper()}")
    print(f"Confidence: {result.confidence:.2%}")
    print("Detection Reasons:")
    for reason in result.reasons:
        print(f"  - {reason}")
else:
    print("File is not packed.")

Dictionary Summary

import packerscope

result = packerscope.scan("path/to/sample.exe")
summary = result.summary()

print(summary)
# {
#     "file_name": "sample.exe",
#     "file_path": "C:\\samples\\sample.exe",
#     "is_packed": True,
#     "packer": "upx",
#     "confidence": 0.85,
#     "confidence_level": "high",
#     "reasons": [...],
#     "analysis_duration_seconds": 0.02
# }

Automatic Unpacking

import packerscope

# Analyze and unpack if a supported packer is found
result = packerscope.scan("path/to/sample.exe", unpack=True)

if result.unpack_result and result.unpack_result.success:
    print(f"Unpacked file saved to: {result.unpack_result.unpacked_path}")

Batch Scanning a Directory

import packerscope

# Scan all PE files in a directory concurrently
results = packerscope.batch_scan("samples_folder/", workers=8)

for res in results:
    status = "PACKED" if res.is_packed else "NOT PACKED"
    print(f"{res.file_name:<30} | {status:<10} | {res.packer:<10} | {res.confidence:.2%}")

Command Line Interface (CLI)

PackerScope can also be executed directly from your terminal:

Analyze a Single File

packerscope scan samples/sample.exe --format json,html --output results/

Batch Analyze a Directory

packerscope batch samples/ --workers 8 --format csv

Quick PE Information

packerscope info samples/sample.exe

Architecture

  1. Orchestrator: Coordinates pipeline lifecycle: Initialization -> Detection -> Verdict -> Unpack -> Verify -> Report.
  2. PEContext: Central blackboard state object. Parsed PE artifacts and detector results are shared here.
  3. Plugin Manager: Dynamically discovers and loads detectors, unpackers, reporters, and verifiers.
  4. Detectors: Independent modules implementing BaseDetector, executed in priority order.
  5. Unpackers: Modules implementing BaseUnpacker, invoked based on verdict classification.

Project Structure

packer_identifier_framework/
├── packerscope/
│   ├── __init__.py            # Top-level public API (scan, detect, batch_scan)
│   ├── cli.py                 # Command-line interface
│   ├── config.py              # Central configuration (Pydantic Settings)
│   ├── constants.py           # Thresholds and heuristics constants
│   ├── context.py             # PEContext (Blackboard state)
│   ├── exceptions.py          # Custom exceptions
│   ├── orchestrator.py        # Pipeline execution logic
│   ├── plugin_manager.py      # Dynamic plugin discovery
│   ├── core/                  # Interfaces, Enums, and Pydantic Models
│   ├── detectors/             # Detection modules (Entropy, IAT, YARA, etc.)
│   ├── reporters/             # Report generators (JSON, CSV, HTML, MD)
│   ├── signatures/            # PEiD signature database & parser
│   ├── unpackers/             # Unpacker implementations
│   ├── utils/                 # Binary analysis helpers & structured logging
│   └── verification/          # Post-unpack verification logic
├── tests/                     # Unit and Integration tests
├── pyproject.toml             # Packaging metadata and dependency definitions
└── requirements.txt           # Flat dependency list

Running Tests

Execute the automated test suite using pytest:

python -m pytest

License

This project is licensed under the MIT License. See LICENSE for details.


Disclaimer

Educational and Defensive Research Purposes Only. This framework is intended strictly for defensive security research, malware analysis, and educational use within authorized environments.

Download files

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

Source Distribution

packerscope-0.2.0.tar.gz (81.3 kB view details)

Uploaded Source

Built Distribution

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

packerscope-0.2.0-py3-none-any.whl (99.7 kB view details)

Uploaded Python 3

File details

Details for the file packerscope-0.2.0.tar.gz.

File metadata

  • Download URL: packerscope-0.2.0.tar.gz
  • Upload date:
  • Size: 81.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for packerscope-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f62419fe6576e7a1ba8e69303b498f5129566167f41d709041887bdfb4df8073
MD5 e2ef27eeefd9b9b83eec33d2c84f2de1
BLAKE2b-256 2a4f7ee611184dc7ff5d74e13e344de956ab068121675eff078e5996ceacbdd5

See more details on using hashes here.

File details

Details for the file packerscope-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: packerscope-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 99.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for packerscope-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1ffc91f2c8c6a32a60240a48bf426d5dff91fa463318e3fe949f0879d76bfff2
MD5 464bbd8d8e56ae79c898df25425885cf
BLAKE2b-256 3e6d25b8e6cfac8b620d167d07ce1f22d159da62298dc4d7a3efabae4522eda6

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.0

2 files

0.2.2

2 files

0.2.1

2 files

This release

0.2.0 This release

2 files

0.1.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page