Skip to content

Commit a6aaf37

Browse files
committed
Added docs, workflows, removed legacy dependency files, publishing to pypi, publishing docs to pages
1 parent a616e2c commit a6aaf37

File tree

71 files changed

+1478
-114
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1478
-114
lines changed

.DS_Store

8 KB
Binary file not shown.

.github/workflows/ci.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Continuous Integration
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
9+
jobs:
10+
build-and-test:
11+
runs-on: ubuntu-latest
12+
name: "🧪 Build & Run Safety Suite"
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: "🦀 Set up Rust"
17+
uses: actions-rs/toolchain@v1
18+
with:
19+
toolchain: stable
20+
override: true
21+
components: clippy, rustfmt
22+
23+
- name: "🐍 Set up Python"
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: "3.10"
27+
28+
- name: "🧱 Install dependencies"
29+
run: |
30+
python -m pip install --upgrade pip
31+
python -m pip install maturin pytest black ruff mypy
32+
python -m pip install -e .[dev,training]
33+
34+
- name: "⚙️ Build Rust extension (develop mode)"
35+
run: |
36+
maturin develop --release
37+
38+
- name: "🧹 Lint and format check"
39+
run: |
40+
cargo fmt -- --check
41+
cargo clippy -- -D warnings
42+
black --check python/
43+
ruff check python/
44+
mypy python/
45+
46+
- name: "🧪 Run Safety Test Suite"
47+
env:
48+
PYTHONPATH: ./python
49+
run: |
50+
echo "Running pytest safety checks..."
51+
pytest -v python/tests/test_safety.py
52+
53+
- name: "✅ Summary"
54+
if: success()
55+
run: echo "✅ All safety and CI checks passed."
56+
57+
- name: "❌ Failure notice"
58+
if: failure()
59+
run: echo "❌ Safety suite failed. Blocking release."
60+
61+
test:
62+
runs-on: ubuntu-latest
63+
name: "🧪 Python Tests (uv)"
64+
steps:
65+
- uses: actions/checkout@v4
66+
- uses: astral-sh/setup-uv@v2
67+
- name: Install dependencies
68+
run: uv sync --group dev --group training
69+
- name: Run tests
70+
run: uv run pytest -q python

.github/workflows/docs.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Deploy Docs
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
pages: write
11+
id-token: write
12+
13+
jobs:
14+
build-deploy:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: astral-sh/setup-uv@v2
19+
- name: Install docs dependencies
20+
run: uv sync --group docs
21+
- name: Build docs
22+
run: uv run mkdocs build --strict
23+
- name: Upload artifact
24+
uses: actions/upload-pages-artifact@v3
25+
with:
26+
path: site
27+
- name: Deploy to GitHub Pages
28+
id: deployment
29+
uses: actions/deploy-pages@v4

LICENSE-APPENDIX.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# 📘 License Appendix – Educational Use and Liability Statement
2+
3+
**Project:** PE-Packer
4+
**Primary License:** Apache-2.0
5+
**Effective Date:** 2025-10-15
6+
7+
---
8+
9+
## 1. Purpose of This Appendix
10+
11+
This appendix supplements the main license file to clarify the **intended scope and ethical limitations** of the PE-Packer project.
12+
13+
The purpose of PE-Packer is **educational and research-oriented learning** about the Windows Portable Executable (PE) format, static analysis, and safe unpacking.
14+
It is **not designed or authorized** for use in software concealment, obfuscation, or malware deployment of any kind.
15+
16+
This clarification does not alter the legal permissions of the MIT or Apache-2.0 license but provides additional binding terms of **responsible use** and **liability disclaimers** specific to this project.
17+
18+
---
19+
20+
## 2. Educational-Use Intent
21+
22+
By obtaining, using, or redistributing this software, you acknowledge that:
23+
24+
- The software is provided **solely for authorized research, teaching, academic, or defensive cybersecurity education**.
25+
- It **must not** be used to disguise or distribute executables, payloads, or binaries outside a controlled educational or testing environment.
26+
- You assume **full responsibility** for ensuring compliance with your institution’s and jurisdiction’s cybersecurity laws and policies.
27+
28+
---
29+
30+
## 3. Safety Controls
31+
32+
PE-Packer enforces a **safety gating system**:
33+
34+
1. Binary packing functionality is **disabled by default**.
35+
2. Activation requires both:
36+
- The environment variable `PE_PACKER_ALLOW_PACKING=1`, **and**
37+
- The command-line flag `--force`.
38+
39+
This gating mechanism exists to prevent accidental or unauthorized generation of packed executables.
40+
41+
---
42+
43+
## 4. No Warranty or Liability
44+
45+
Consistent with the MIT and Apache-2.0 licenses:
46+
47+
- The software is provided **“as is,” without warranty of any kind**, express or implied.
48+
- Under no circumstances shall the authors, contributors, or affiliated institutions be liable for **any claim, damages, or other liability** arising from misuse, modification, or redistribution of this software.
49+
- You are solely responsible for ensuring compliance with all applicable laws, export regulations, and institutional policies.
50+
51+
---
52+
53+
## 5. Academic Citation
54+
55+
If you use PE-Packer in an academic, instructional, or research context, please cite the repository as follows:
56+
57+
> **Tutu, A.M. (2025). PE-Packer: An Educational PE File Packing Laboratory.**
58+
> Available at: [https://github.com/codeamt/rust-python-pe-packer](https://github.com/codeamt/rust-python-pe-packer)
59+
60+
---
61+
62+
## 6. Contact
63+
64+
| Purpose | Contact |
65+
|----------|----------|
66+
| General inquiries | annmargaret.mailforce@gmail.com |
67+
| Security disclosures | annmargaret.mailforce@gmail.com |
68+
| License & institutional use | annmargaret.mailforce@gmail.com |
69+
70+
---
71+
72+
*This appendix is intended to reinforce ethical, transparent, and responsible software distribution practices in alignment with open-source security research standards.*

Makefile

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,4 +285,36 @@ install-tools: ## Install development tools
285285
cargo install cargo-watch
286286
cargo install cargo-bloat
287287
$(UV) pip install pre-commit
288-
@echo "$(GREEN)Development tools installed$(NC)"
288+
@echo "$(GREEN)Development tools installed$(NC)"
289+
290+
# PyPI Educational Stub (safe wheel)
291+
.PHONY: stub-build
292+
stub-build: ## Build educational stub wheel (PyPI-safe)
293+
@echo "$(BLUE)Building educational stub wheel...$(NC)"
294+
@test -d pypi-stub || { echo "missing pypi-stub/"; exit 1; }
295+
@test -f pypi-stub/pyproject.toml || { echo "missing pypi-stub/pyproject.toml"; exit 1; }
296+
$(UV) run $(PYTHON) -m pip install --upgrade build
297+
cd pypi-stub && $(UV) run $(PYTHON) -m build
298+
@echo "$(GREEN)Stub wheel built in pypi-stub/dist$(NC)"
299+
300+
.PHONY: stub-publish
301+
stub-publish: ## Publish educational stub to PyPI (requires ALLOW_PYPI_RELEASE=1 and PYPI_TOKEN configured in environment)
302+
@echo "$(BLUE)Publishing educational stub to PyPI...$(NC)"
303+
test "$(ALLOW_PYPI_RELEASE)" = "1" || (echo "Set ALLOW_PYPI_RELEASE=1 to enable publishing" && false)
304+
$(UV) run $(PYTHON) -m pip install --upgrade twine
305+
cd pypi-stub && $(UV) run $(PYTHON) -m twine upload --non-interactive dist/*
306+
@echo "$(GREEN)Stub published to PyPI$(NC)"
307+
308+
# MkDocs Documentation
309+
.PHONY: docs-serve
310+
docs-serve: ## Serve MkDocs locally at http://127.0.0.1:8000
311+
@echo "$(BLUE)Starting MkDocs dev server...$(NC)"
312+
$(UV) run $(PYTHON) -m pip install -q mkdocs-material
313+
$(UV) run mkdocs serve --watch .
314+
315+
.PHONY: docs-build
316+
docs-build: ## Build MkDocs site into ./site
317+
@echo "$(BLUE)Building MkDocs site...$(NC)"
318+
$(UV) run $(PYTHON) -m pip install -q mkdocs-material
319+
$(UV) run mkdocs build --strict
320+
@echo "$(GREEN)Docs built in ./site$(NC)"

README.md

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
[![CI](https://github.com/codeamt/rust-python-pe-packer/actions/workflows/ci.yml/badge.svg)](https://github.com/codeamt/rust-python-pe-packer/actions/workflows/ci.yml)
2+
[![Docs](https://img.shields.io/badge/docs-mkdocs--material-blue)](https://codeamt.github.io/rust-python-pe-packer/)
3+
[![License](https://img.shields.io/badge/license-Apache--2.0-green)](./LICENSE)
4+
15
# PE-Packer
26

3-
An educational PE (Portable Executable) packer built in Rust with Python bindings for generating packed malware samples to train machine learning-based malware detection models.
7+
An educational PE (Portable Executable) laboratory built in Rust with Python bindings for research and training on PE formats, safe unpacking workflows, and defensive ML evaluation.
48

59
**⚠️ Educational Purpose Only**: This tool is designed for security research, malware analysis training, and building robust ML detection systems. Use only with legitimate, authorized benign samples.
610

11+
> Quick links: [Security Policy](./SECURITY.md) · [License Appendix (Educational Use)](./LICENSE-APPENDIX.md)
12+
713
## Features
814

915
- **Multiple Encryption Algorithms**: XOR, AES, or no encryption
@@ -24,24 +30,27 @@ An educational PE (Portable Executable) packer built in Rust with Python binding
2430
- Python 3.8+
2531
- pip or poetry
2632

27-
### From PyPI
33+
### From PyPI (educational stub)
2834

2935
```bash
30-
pip install pe-packer
36+
pip install pe-packer-educational
3137
```
3238

39+
This PyPI package is a non-functional educational stub that prints guidance and links to the source. It does not ship packing code or native modules.
40+
3341
### From Source
3442

3543
```bash
3644
# Clone the repository
37-
git clone https://github.com/codeamt/pe-packer
38-
cd pe-packer
45+
git clone https://github.com/codeamt/rust-python-pe-packer
46+
cd rust-python-pe-packer
3947

40-
# Install in development mode
41-
pip install -e .
48+
# Using uv (recommended)
49+
uv sync --group dev --group training
50+
uv run maturin develop --features python
4251

43-
# Or build and install the wheel
44-
pip install maturin
52+
# Or using pip
53+
pip install -e .[dev,training]
4554
maturin develop
4655
```
4756

@@ -50,14 +59,21 @@ maturin develop
5059
### Pack a Single File
5160

5261
```bash
53-
# Pack with default settings (XOR encryption)
62+
# Safety gate: actual packing requires BOTH
63+
# PE_PACKER_ALLOW_PACKING=1 and --force
64+
# Otherwise, the CLI runs in dry-run mode and prints analysis only.
65+
66+
# Dry-run (no env, no --force)
5467
pe-packer pack malware.exe packed.exe
5568

69+
# Actual packing (requires both env and --force)
70+
PE_PACKER_ALLOW_PACKING=1 pe-packer pack malware.exe packed.exe --force
71+
5672
# Pack with AES encryption and anti-debugging
5773
pe-packer pack malware.exe packed.exe --encryption aes --anti-debug
5874

59-
# Randomize sections and add benign metadata
60-
pe-packer pack malware.exe packed.exe \
75+
# Randomize sections and add benign metadata (with gates)
76+
PE_PACKER_ALLOW_PACKING=1 pe-packer pack malware.exe packed.exe --force \
6177
--encryption aes \
6278
--anti-debug \
6379
--random-sections \
@@ -81,6 +97,21 @@ pe-packer generate-training-data \
8197
--encryption xor,aes
8298
```
8399

100+
## Testing Dataset Generation (Checklist)
101+
102+
- Ensure you have a local folder with benign PE files, for example: `./benign_samples/`
103+
- Run a small test to validate the pipeline end-to-end:
104+
105+
```bash
106+
# Minimal smoke test: 1 variant, analysis-focused
107+
pe-packer generate-training-data ./benign_samples ./training_data --variants 1
108+
109+
# Analyze the produced metadata
110+
pe-packer analyze-dataset ./training_data/dataset_metadata.json
111+
```
112+
113+
- If you intend to actually generate packed binaries (not just analysis), ensure safety gates are consciously enabled when invoking direct packing commands (see Pack a Single File section). Dataset generation itself focuses on safe educational workflows and metadata.
114+
84115
### Analyze Generated Dataset
85116

86117
```bash
@@ -111,10 +142,11 @@ pe-packer pack INPUT OUTPUT [OPTIONS]
111142
- `--benign-metadata`: Add benign-looking metadata
112143
- `--stub-variation, -s`: Stub variation identifier (1-32) [default: 1]
113144
- `--verbose, -v`: Enable verbose logging
145+
- `--force`: Required along with `PE_PACKER_ALLOW_PACKING=1` to perform actual packing
114146

115147
**Example:**
116148
```bash
117-
pe-packer pack sample.exe packed.exe \
149+
PE_PACKER_ALLOW_PACKING=1 pe-packer pack sample.exe packed.exe --force \
118150
--encryption aes \
119151
--key deadbeef \
120152
--anti-debug \
@@ -413,7 +445,7 @@ If you use PE-Packer in your research, please cite:
413445
title={PE-Packer: Educational PE Packer for Malware Detection Training},
414446
author={AnnMargaret Tutu},
415447
year={2025},
416-
url={https://github.com/codeamt/pe-packer}
448+
url={https://github.com/codeamt/rust-python-pe-packer}
417449
}
418450
```
419451

0 commit comments

Comments
 (0)