Skip to content

Commit 97331d5

Browse files
committed
fixes
1 parent 4d6053c commit 97331d5

22 files changed

Lines changed: 292 additions & 413 deletions

.github/workflows/ci.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,6 @@ on: [push, pull_request]
44

55
jobs:
66
test:
7-
runs-on: ubuntu-latest
8-
steps:
9-
- uses: actions/checkout@v3
10-
- uses: actions-rs/toolchain@v1
11-
with:
12-
toolchain: stable
13-
- run: cargo build --release
14-
- run: cargo test
15-
16-
build-cross:
177
runs-on: ${{ matrix.os }}
188
strategy:
199
matrix:
@@ -24,3 +14,4 @@ jobs:
2414
with:
2515
toolchain: stable
2616
- run: cargo build --release
17+
- run: cargo test

.github/workflows/release.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
tags:
66
- 'v*'
77

8+
permissions:
9+
contents: write
10+
811
jobs:
912
build:
1013
name: Build ${{ matrix.target }}
@@ -20,6 +23,7 @@ jobs:
2023
target: aarch64-unknown-linux-gnu
2124
artifact_name: polymorph
2225
asset_name: polymorph-linux-arm64
26+
use_cross: true
2327
- os: macos-latest
2428
target: x86_64-apple-darwin
2529
artifact_name: polymorph
@@ -42,11 +46,17 @@ jobs:
4246
target: ${{ matrix.target }}
4347
override: true
4448

45-
- name: Install cross-compilation tools
46-
if: matrix.target == 'aarch64-unknown-linux-gnu'
47-
run: |
48-
sudo apt-get update
49-
sudo apt-get install -y gcc-aarch64-linux-gnu
49+
- name: Install cross
50+
if: matrix.use_cross
51+
run: cargo install cross --git https://github.com/cross-rs/cross
52+
53+
- name: Build with cross
54+
if: matrix.use_cross
55+
run: cross build --release --target ${{ matrix.target }}
56+
57+
- name: Build native
58+
if: "!matrix.use_cross"
59+
run: cargo build --release --target ${{ matrix.target }}
5060

5161
- name: Build
5262
run: cargo build --release --target ${{ matrix.target }}

CHANGELOG.md

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
# Changelog
22

33
## [1.1.0] - 2026-01-18
4-
5-
### Added
6-
- APE polyglot detection
7-
- Zig malware detection
8-
- WASM cryptominer detection
4+
- APE, Zig, WASM detection
95
- 19 YARA rules
10-
- Cross-platform support
11-
12-
### Features
13-
- Fast scanning (~50ms per 10MB)
14-
- JSON output
15-
- Risk scoring
16-
- Verbose mode
6+
- Fast scanning

CONTRIBUTING.md

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
# Contributing
22

3-
We welcome contributions!
4-
5-
## Getting Started
6-
73
1. Fork the repo
8-
2. Create a feature branch
9-
3. Make your changes
10-
4. Add tests
11-
5. Submit a pull request
12-
13-
## Code Style
14-
15-
- Run `cargo fmt`
16-
- Run `cargo clippy`
17-
- Add documentation
4+
2. Create feature branch
5+
3. Add tests
6+
4. Submit PR

Cargo.toml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ keywords = ["security", "malware", "polyglot", "detection", "wasm"]
1414
categories = ["command-line-utilities", "development-tools"]
1515

1616
[dependencies]
17-
serde = { version = "1.0", features = ["derive"] }
18-
serde_json = "1.0"
1917

2018
[dev-dependencies]
2119
tempfile = "3.8"
20+
criterion = "0.5"
2221

2322
[profile.release]
2423
opt-level = 3
@@ -30,3 +29,15 @@ panic = "abort"
3029
[[bin]]
3130
name = "polymorph"
3231
path = "src/main.rs"
32+
33+
[[bench]]
34+
name = "benchmark"
35+
harness = false
36+
37+
[[example]]
38+
name = "basic_scan"
39+
path = "examples/basic_scan.rs"
40+
41+
[[example]]
42+
name = "batch_scan"
43+
path = "examples/batch_scan.rs"

README.md

Lines changed: 20 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -9,66 +9,35 @@
99
[![Rust](https://img.shields.io/badge/rust-1.70%2B-orange.svg)](https://www.rust-lang.org/)
1010
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
1111
[![Security](https://img.shields.io/badge/security-malware%20detection-red)](https://github.com/xonoxitron/polymorph)
12-
[![Build Status](https://github.com/xonoxitron/polymorph/workflows/CI/badge.svg)](https://github.com/xonoxitron/polymorph/actions)
1312

14-
[Features](#-features)[Quick Start](#-quick-start)[Documentation](#-documentation)[Contributing](#-contributing)
13+
[Features](#-features)[Quick Start](#-quick-start)[Examples](#-examples)
1514

1615
</div>
1716

1817
---
1918

2019
## 🚨 The Polyglot Malware Problem
2120

22-
The malware landscape is evolving. Attackers exploit **polyglot files** - binaries valid in multiple formats simultaneously - to evade detection systems that traditional antivirus cannot catch.
21+
Modern malware exploits **polyglot files** - binaries valid in multiple formats simultaneously - to evade traditional antivirus.
2322

24-
### The Emerging Threats
23+
### The Threats
2524

26-
**Actually Portable Executables (APE)**
27-
- Single binary runs natively on Windows, Linux, macOS, and BSD
28-
- Combines PE + ELF + Mach-O formats in one file
29-
- Perfect for cross-platform malware campaigns
25+
- **APE (Actually Portable Executable)**: Single binary runs on Windows/Linux/macOS/BSD
26+
- **Zig Malware**: Direct syscalls bypass EDR (Hell's Gate, Halo's Gate)
27+
- **WASM Cryptominers**: 75% of WASM modules are malicious (CrowdStrike, 2024)
3028

31-
**Zig Malware**
32-
- Direct syscalls bypass EDR hooks (Hell's Gate, Halo's Gate)
33-
- Compile-time obfuscation defeats static analysis
34-
- Growing adoption in APT toolkits
29+
### Research Shows Defenses Fail
3530

36-
**WebAssembly Cryptominers**
37-
- Near-native performance in browsers
38-
- Binary format evades string-based detection
39-
- **75% of WASM modules in the wild are malicious** (CrowdStrike, 2024)
31+
- **20/36 detectors** bypassed by polyglots (Jana & Shmatikov, 2012)
32+
- **90% evasion rate** against VirusTotal for WASM (Cabrera-Arteaga, 2024)
4033

41-
### Research Proves Traditional Defenses Fail
42-
43-
- **20 out of 36 malware detectors** bypassed by polyglot files (Jana & Shmatikov, 2012)
44-
- **4 leading commercial tools** missed 199 polyglot samples (Bridges et al., 2023)
45-
- **90% evasion rate** against VirusTotal for WASM (Cabrera-Arteaga et al., 2024)
46-
47-
**No open-source production tool detects APE, Zig, AND WASM threats together.**
48-
49-
**PolyMorph fills this gap.**
50-
51-
---
52-
53-
## 🎯 What is PolyMorph?
54-
55-
First open-source static analyzer for:
56-
57-
**Cosmopolitan APE** polyglot binaries
58-
**Zig-based malware** with EDR evasion
59-
**WebAssembly cryptominers**
60-
**Direct syscall patterns** (Hell's Gate, Halo's Gate)
61-
**Anti-debugging/anti-VM** mechanisms
62-
**Process injection** across platforms
63-
64-
Built in Rust for performance (~50ms per 10MB), safety, and portability.
34+
**No open-source tool detects APE + Zig + WASM together. PolyMorph fills this gap.**
6535

6636
---
6737

6838
## ⚡ Quick Start
6939

7040
```bash
71-
# Clone and build
7241
git clone https://github.com/xonoxitron/polymorph
7342
cd polymorph
7443
cargo build --release
@@ -77,66 +46,30 @@ cargo build --release
7746
./target/release/polymorph suspicious.exe
7847

7948
# JSON output
80-
./target/release/polymorph --json malware.com
49+
./target/release/polymorph --json malware.wasm
8150
```
8251

8352
---
8453

85-
## 📚 Documentation
86-
87-
- [Quick Start Guide](docs/QUICKSTART.md)
88-
- [Architecture](docs/ARCHITECTURE.md)
89-
- [WASM Detection](docs/WASM_DETECTION.md)
90-
- [YARA Rules](rules/polymorph.yar)
91-
- [Contributing](CONTRIBUTING.md)
92-
93-
---
94-
95-
## 💻 Usage Examples
54+
## 💻 Examples
9655

97-
### Malware Analysis
98-
```bash
99-
polymorph /tmp/suspicious.exe | grep -E "CRITICAL|HIGH"
100-
```
101-
102-
### CI/CD Integration
103-
```yaml
104-
- name: Scan artifacts
105-
run: polymorph --json ./build/app.exe || exit 1
106-
```
107-
108-
### SOC Automation
109-
```python
110-
import subprocess, json
111-
112-
def scan(path):
113-
result = subprocess.run(['polymorph', '--json', path],
114-
capture_output=True, text=True)
115-
return json.loads(result.stdout)
116-
117-
report = scan('/quarantine/sample.com')
118-
if report['risk_score'] >= 80:
119-
alert_soc_team(report)
120-
```
56+
See `examples/` directory:
57+
- `basic_scan.rs` - Simple file scanning
58+
- `batch_scan.rs` - Multiple file processing
12159

12260
---
12361

124-
## 🔬 Comparison to Existing Tools
125-
126-
| Tool | APE | Zig | WASM | Open Source | Production Ready |
127-
|------|-----|-----|------|-------------|------------------|
128-
| **PolyMorph** | ✅ | ✅ | ✅ | ✅ | ✅ |
129-
| MINOS | ❌ | ❌ | ⚠️ | ⚠️ | ❌ |
130-
| MinerRay | ❌ | ❌ | ✅ | ❌ | ❌ |
131-
| ClamAV | ❌ | ❌ | ❌ | ✅ | ✅ |
62+
## 📚 Documentation
13263

133-
**PolyMorph: Only tool with APE+Zig+WASM detection in production-ready open-source package.**
64+
- [Quick Start](docs/QUICKSTART.md)
65+
- [Architecture](docs/ARCHITECTURE.md)
66+
- [WASM Detection](docs/WASM_DETECTION.md)
13467

13568
---
13669

13770
## 🤝 Contributing
13871

139-
Contributions welcome! See [CONTRIBUTING.md](CONTRIBUTING.md).
72+
Contributions welcome! See [CONTRIBUTING.md](CONTRIBUTING.md)
14073

14174
---
14275

@@ -146,14 +79,6 @@ MIT License - see [LICENSE](LICENSE)
14679

14780
---
14881

149-
## 📧 Support
150-
151-
- **Issues**: [GitHub Issues](https://github.com/xonoxitron/polymorph/issues)
152-
- **Discussions**: [GitHub Discussions](https://github.com/xonoxitron/polymorph/discussions)
153-
- **Security**: [SECURITY.md](SECURITY.md)
154-
155-
---
156-
15782
<div align="center">
15883

15984
Made with ❤️ by the security community

SECURITY.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
# Security Policy
22

3-
## Reporting Vulnerabilities
4-
5-
Email: security@polymorph-project.org
6-
7-
Do not open public issues for security vulnerabilities.
3+
Report vulnerabilities via GitHub Security Advisories.

docs/ARCHITECTURE.md

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,11 @@
11
# Architecture
22

3-
## Overview
4-
5-
PolyMorph uses static analysis to detect polyglot malware patterns.
6-
73
## Components
8-
9-
- **Scanner**: Orchestrates detection modules
10-
- **Detectors**: APE, Zig, WASM, evasion analysis
11-
- **Report**: Human and JSON output
12-
- **Utils**: Helper functions
13-
14-
## Detection Flow
15-
16-
1. Read binary file
17-
2. Run format-specific detectors
18-
3. Analyze evasion techniques
19-
4. Calculate risk score
20-
5. Generate report
4+
- **Scanner**: Orchestrates detection
5+
- **Detectors**: APE, Zig, WASM, evasion
6+
- **Report**: Human/JSON output
7+
- **Utils**: Formatting, hashing
218

229
## Risk Scoring
23-
24-
```
25-
Risk = Σ(severity_points) + binary_type_bonus
26-
Severity: Low=5, Medium=15, High=25, Critical=40
27-
Binary bonus: Cosmopolitan=+10, Hybrid=+20
28-
```
10+
Risk = Σ(severity) + binary_type_bonus
11+
Max: 100

docs/QUICKSTART.md

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,20 @@
1-
# Quick Start Guide
2-
3-
## Installation
1+
# Quick Start
42

3+
## Build
54
```bash
6-
git clone https://github.com/xonoxitron/polymorph
7-
cd polymorph
85
cargo build --release
96
```
107

11-
## Basic Usage
12-
8+
## Scan
139
```bash
14-
# Scan a binary
1510
polymorph suspicious.exe
16-
17-
# JSON output
18-
polymorph --json malware.com
19-
20-
# Verbose with offsets
21-
polymorph -v --offsets binary.elf
11+
polymorph --json malware.wasm
2212
```
2313

24-
## Understanding Output
25-
26-
- **0-40**: Low risk
27-
- **40-60**: Medium risk
28-
- **60-80**: High risk
29-
- **80-100**: Critical threat
30-
3114
## Exit Codes
32-
33-
- `0`: Clean
34-
- `1`: Low
35-
- `2`: Medium
36-
- `3`: High
37-
- `4`: Critical
38-
- `5`: Error
15+
- 0: Clean
16+
- 1: Low (0-40)
17+
- 2: Medium (40-60)
18+
- 3: High (60-80)
19+
- 4: Critical (80+)
20+
- 5: Error

0 commit comments

Comments
 (0)