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.1.tar.gz (80.4 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.1-py3-none-any.whl (100.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: packerscope-0.2.1.tar.gz
  • Upload date:
  • Size: 80.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for packerscope-0.2.1.tar.gz
Algorithm Hash digest
SHA256 eb064f92c5e4f67e0b87e3a932a7ce7a74f89bba593e794e6311092022a47f13
MD5 84af64c2672bdc1b4e1fd298095d0148
BLAKE2b-256 1c00760dd2325999e61945bf7e66718fc74ef13ab48609a7b8d4462866be4e97

See more details on using hashes here.

Provenance

The following attestation bundles were made for packerscope-0.2.1.tar.gz:

Publisher: publish.yml on salmanmallah/packerscope

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: packerscope-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 100.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for packerscope-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7720005c895da2aef513e00a25b00043d5076dd9caadb11e875f73a6b3ce40f2
MD5 df004b43941f28f62d0de402f690e542
BLAKE2b-256 ffce967f27fa1d44a2a4fb0c5e63aec1a4e05e436d4cabf99fb182cc071e262b

See more details on using hashes here.

Provenance

The following attestation bundles were made for packerscope-0.2.1-py3-none-any.whl:

Publisher: publish.yml on salmanmallah/packerscope

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.3.0

2 files

0.2.2

2 files

This release

0.2.1 This release

2 files

0.2.0

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