Skip to content

meltedinhex/analyst-ai-pack / skills/analyzing-compiled-python-malware

analyzing-compiled-python-malware

Unverified

Analyzes Python-based malware packaged as PyInstaller/py2exe executables by detecting the packer, locating the embedded archive, and identifying bundled .pyc modules for extraction and decompilation. Activates for requests to analyze compiled Python malware, unpack a PyInstaller binary, or extract pyc modules from a frozen Python executable.

FileKindSize
LICENSEother340 B
SKILL.mdskill md2.9 KB
references/api-reference.mdmarkdown1.1 KB
scripts/analyst.pyscript2.1 KB

references/api-reference.md

View on GitHub
# API Reference: Analyzing Compiled Python Malware

## Overview

`scripts/analyst.py` detects frozen-Python packers (PyInstaller, py2exe, cx_Freeze) by their markers,
locates the PyInstaller CArchive magic cookie, and extracts embedded Python version strings. It
reads bytes statically and executes nothing.

## Dependencies

| Package | Version | Purpose |
|---------|---------|---------|
| (stdlib) | — | regex, JSON, file IO |

## Core functions

### `detect(path)`
Returns the detected packer, PyInstaller cookie offset, and Python version strings, plus the
recommended next step.

## Markers

- PyInstaller: `_MEIPASS`, `PYZ-00.pyz`, `pyiboot01_bootstrap`, CArchive cookie `MEI\\014\\013\\012\\013\\016`.
- py2exe: `PYTHONSCRIPT`.
- cx_Freeze: `cx_Freeze` strings.

## Usage

```bash
python scripts/analyst.py detect sample.exe
```

## Sources

- PyInstaller archive format (CArchive/PKG, MEI cookie) — https://pyinstaller.org/en/stable/advanced-topics.html
- Python bytecode / .pyc magic (dis module) — https://docs.python.org/3/library/dis.html
- pyinstxtractor extraction workflow (public PyInstaller-unpacking tooling)
receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 318kUpdated Claude CodeCodexUnverifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 318kUpdated Claude CodeCodexUnverifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 318kUpdated Claude CodeCodexUnverifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 318kUpdated Claude CodeCodexUnverifiedInstall