entropystrip 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- entropystrip-1.0.0/LICENSE +21 -0
- entropystrip-1.0.0/PKG-INFO +147 -0
- entropystrip-1.0.0/README.md +115 -0
- entropystrip-1.0.0/entropystrip/__init__.py +23 -0
- entropystrip-1.0.0/entropystrip/__main__.py +5 -0
- entropystrip-1.0.0/entropystrip/core.py +941 -0
- entropystrip-1.0.0/entropystrip.egg-info/PKG-INFO +147 -0
- entropystrip-1.0.0/entropystrip.egg-info/SOURCES.txt +12 -0
- entropystrip-1.0.0/entropystrip.egg-info/dependency_links.txt +1 -0
- entropystrip-1.0.0/entropystrip.egg-info/entry_points.txt +2 -0
- entropystrip-1.0.0/entropystrip.egg-info/requires.txt +2 -0
- entropystrip-1.0.0/entropystrip.egg-info/top_level.txt +1 -0
- entropystrip-1.0.0/pyproject.toml +48 -0
- entropystrip-1.0.0/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 EntropyStrip Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: entropystrip
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Algorithmic PE de-obfuscator, Shannon entropy radar, and incident triage engine.
|
|
5
|
+
Author-email: dwexi <dwexi@users.noreply.github.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/dwexi/entropystrip
|
|
8
|
+
Project-URL: Repository, https://github.com/dwexi/entropystrip
|
|
9
|
+
Project-URL: Issues, https://github.com/dwexi/entropystrip/issues
|
|
10
|
+
Keywords: malware-analysis,reverse-engineering,pe,entropy,shannon-entropy,incident-response,security,dfir
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Information Technology
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Security
|
|
24
|
+
Classifier: Topic :: Software Development :: Disassemblers
|
|
25
|
+
Classifier: Topic :: Utilities
|
|
26
|
+
Requires-Python: >=3.8
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Requires-Dist: pefile>=2024.8.26
|
|
30
|
+
Requires-Dist: rich>=13.7.0
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
# entropystrip
|
|
34
|
+
|
|
35
|
+
```text
|
|
36
|
+
___________ __ _________ __ .__
|
|
37
|
+
\_ _____/ _____/ |________ ____ ______ ___.__./ _____// |________|__|_____
|
|
38
|
+
| __)_ / \ __\_ __ \/ _ \\____ < | |\_____ \\ __\_ __ \ \____ \
|
|
39
|
+
| \ | \ | | | \( <_> ) |_> >___ |/ \| | | | \/ | |_> >
|
|
40
|
+
/_______ /___| /__| |__| \____/| __// ____/_______ /|__| |__| |__| __/
|
|
41
|
+
\/ \/ |__| \/ \/ |__|
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## What it does
|
|
48
|
+
|
|
49
|
+
Most modern malware hides behind packers (like UPX, VMProtect, or Themida) or stashes encrypted payloads in PE resource directories or trailing file overlays. Rather than relying on static byte signatures, `entropystrip` evaluates:
|
|
50
|
+
|
|
51
|
+
1. **Section Entropy:** Calculates block-level Shannon entropy across every PE section to locate encrypted or compressed buffers ($H > 7.20$).
|
|
52
|
+
2. **Memory Permissions:** Identifies sections marked simultaneously as Writable and Executable (`IMAGE_SCN_MEM_WRITE` and `IMAGE_SCN_MEM_EXECUTE`), which indicates self-modifying code or runtime unpackers.
|
|
53
|
+
3. **PE Overlays:** Measures trailing bytes appended past the end of the last mapped section.
|
|
54
|
+
4. **Import Table Size & Composition:** Flags binaries with unusually small IATs (e.g. only importing `LoadLibrary` / `GetProcAddress`) or sensitive process injection primitives (`VirtualAlloc`, `WriteProcessMemory`, `QueueUserAPC`).
|
|
55
|
+
5. **.NET Classification:** Inspects the COM descriptor directory to separate managed CLR assemblies from native binaries, avoiding false positives on standard C# applications.
|
|
56
|
+
6. **Payload Carving:** Extracts identified high-entropy sections or overlays straight to raw binary files on disk for further analysis.
|
|
57
|
+
7. **Directory Triage:** Walks directories or drives and ranks all found binaries by threat score.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
Requirements: Python 3.8+ on Windows, Linux, or macOS.
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pip install entropystrip
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Or install directly from source:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
git clone https://github.com/dwexi/entropystrip.git
|
|
73
|
+
cd entropystrip
|
|
74
|
+
pip install -e .
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Usage
|
|
80
|
+
|
|
81
|
+
```text
|
|
82
|
+
usage: main.py [-h] [-r] [--dump] [--deep] [--html HTML] [--json JSON] target
|
|
83
|
+
|
|
84
|
+
EntropyStrip: PE De-obfuscator & Triage Engine
|
|
85
|
+
|
|
86
|
+
positional arguments:
|
|
87
|
+
target Path to Windows executable (.exe / .dll) or directory to scan
|
|
88
|
+
|
|
89
|
+
options:
|
|
90
|
+
-h, --help show this help message and exit
|
|
91
|
+
-r, --recursive
|
|
92
|
+
recursively scan subdirectories if target is a folder
|
|
93
|
+
--dump carve and write high-entropy payloads to extracted_payloads/
|
|
94
|
+
--deep deep forensic triage: MITRE ATT&CK mapping, entry point disassembly, hashes
|
|
95
|
+
--html HTML write minimalist HTML report to specified path
|
|
96
|
+
--json JSON write machine-readable JSON telemetry to specified path
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Examples
|
|
100
|
+
|
|
101
|
+
**Analyze a single binary:**
|
|
102
|
+
```bash
|
|
103
|
+
python main.py target.exe
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Deep forensic triage with MITRE ATT&CK mapping & disassembly:**
|
|
107
|
+
```bash
|
|
108
|
+
python main.py suspicious.exe --deep
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**Analyze and extract hidden payload buffers:**
|
|
112
|
+
```bash
|
|
113
|
+
python main.py suspicious.exe --dump
|
|
114
|
+
```
|
|
115
|
+
Carved payloads are written to `extracted_payloads/<target>_<section>.bin`.
|
|
116
|
+
|
|
117
|
+
**Export a standalone HTML report:**
|
|
118
|
+
```bash
|
|
119
|
+
python main.py sample.exe --html report.html
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Triage an entire directory of unknown files:**
|
|
123
|
+
```bash
|
|
124
|
+
python main.py "C:\IncidentTriage" -r
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Entropy Scale Reference
|
|
130
|
+
|
|
131
|
+
Shannon entropy measures information density from 0.00 to 8.00 bits per byte:
|
|
132
|
+
|
|
133
|
+
$$H(X) = -\sum_{i=0}^{255} P(x_i) \log_2 P(x_i)$$
|
|
134
|
+
|
|
135
|
+
| Entropy Range | Expected Content | Notes |
|
|
136
|
+
|---|---|---|
|
|
137
|
+
| `0.00 - 2.00` | Zero-padding, sparse tables | Common in uninitialized data or alignment padding |
|
|
138
|
+
| `2.00 - 5.50` | Standard ASCII, configurations | Normal application metadata, strings |
|
|
139
|
+
| `5.50 - 6.60` | Native compiled machine code | Standard x86/x64 instructions (`.text`) |
|
|
140
|
+
| `6.60 - 7.30` | Compressed assets | Bitmaps, icons, zlib/deflate streams |
|
|
141
|
+
| `7.40 - 8.00` | Cryptographic ciphertext | AES/RC4 encrypted payloads or tightly packed shellcode |
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
MIT License. See [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# entropystrip
|
|
2
|
+
|
|
3
|
+
```text
|
|
4
|
+
___________ __ _________ __ .__
|
|
5
|
+
\_ _____/ _____/ |________ ____ ______ ___.__./ _____// |________|__|_____
|
|
6
|
+
| __)_ / \ __\_ __ \/ _ \\____ < | |\_____ \\ __\_ __ \ \____ \
|
|
7
|
+
| \ | \ | | | \( <_> ) |_> >___ |/ \| | | | \/ | |_> >
|
|
8
|
+
/_______ /___| /__| |__| \____/| __// ____/_______ /|__| |__| |__| __/
|
|
9
|
+
\/ \/ |__| \/ \/ |__|
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## What it does
|
|
16
|
+
|
|
17
|
+
Most modern malware hides behind packers (like UPX, VMProtect, or Themida) or stashes encrypted payloads in PE resource directories or trailing file overlays. Rather than relying on static byte signatures, `entropystrip` evaluates:
|
|
18
|
+
|
|
19
|
+
1. **Section Entropy:** Calculates block-level Shannon entropy across every PE section to locate encrypted or compressed buffers ($H > 7.20$).
|
|
20
|
+
2. **Memory Permissions:** Identifies sections marked simultaneously as Writable and Executable (`IMAGE_SCN_MEM_WRITE` and `IMAGE_SCN_MEM_EXECUTE`), which indicates self-modifying code or runtime unpackers.
|
|
21
|
+
3. **PE Overlays:** Measures trailing bytes appended past the end of the last mapped section.
|
|
22
|
+
4. **Import Table Size & Composition:** Flags binaries with unusually small IATs (e.g. only importing `LoadLibrary` / `GetProcAddress`) or sensitive process injection primitives (`VirtualAlloc`, `WriteProcessMemory`, `QueueUserAPC`).
|
|
23
|
+
5. **.NET Classification:** Inspects the COM descriptor directory to separate managed CLR assemblies from native binaries, avoiding false positives on standard C# applications.
|
|
24
|
+
6. **Payload Carving:** Extracts identified high-entropy sections or overlays straight to raw binary files on disk for further analysis.
|
|
25
|
+
7. **Directory Triage:** Walks directories or drives and ranks all found binaries by threat score.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
Requirements: Python 3.8+ on Windows, Linux, or macOS.
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install entropystrip
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Or install directly from source:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
git clone https://github.com/dwexi/entropystrip.git
|
|
41
|
+
cd entropystrip
|
|
42
|
+
pip install -e .
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Usage
|
|
48
|
+
|
|
49
|
+
```text
|
|
50
|
+
usage: main.py [-h] [-r] [--dump] [--deep] [--html HTML] [--json JSON] target
|
|
51
|
+
|
|
52
|
+
EntropyStrip: PE De-obfuscator & Triage Engine
|
|
53
|
+
|
|
54
|
+
positional arguments:
|
|
55
|
+
target Path to Windows executable (.exe / .dll) or directory to scan
|
|
56
|
+
|
|
57
|
+
options:
|
|
58
|
+
-h, --help show this help message and exit
|
|
59
|
+
-r, --recursive
|
|
60
|
+
recursively scan subdirectories if target is a folder
|
|
61
|
+
--dump carve and write high-entropy payloads to extracted_payloads/
|
|
62
|
+
--deep deep forensic triage: MITRE ATT&CK mapping, entry point disassembly, hashes
|
|
63
|
+
--html HTML write minimalist HTML report to specified path
|
|
64
|
+
--json JSON write machine-readable JSON telemetry to specified path
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Examples
|
|
68
|
+
|
|
69
|
+
**Analyze a single binary:**
|
|
70
|
+
```bash
|
|
71
|
+
python main.py target.exe
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Deep forensic triage with MITRE ATT&CK mapping & disassembly:**
|
|
75
|
+
```bash
|
|
76
|
+
python main.py suspicious.exe --deep
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Analyze and extract hidden payload buffers:**
|
|
80
|
+
```bash
|
|
81
|
+
python main.py suspicious.exe --dump
|
|
82
|
+
```
|
|
83
|
+
Carved payloads are written to `extracted_payloads/<target>_<section>.bin`.
|
|
84
|
+
|
|
85
|
+
**Export a standalone HTML report:**
|
|
86
|
+
```bash
|
|
87
|
+
python main.py sample.exe --html report.html
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Triage an entire directory of unknown files:**
|
|
91
|
+
```bash
|
|
92
|
+
python main.py "C:\IncidentTriage" -r
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Entropy Scale Reference
|
|
98
|
+
|
|
99
|
+
Shannon entropy measures information density from 0.00 to 8.00 bits per byte:
|
|
100
|
+
|
|
101
|
+
$$H(X) = -\sum_{i=0}^{255} P(x_i) \log_2 P(x_i)$$
|
|
102
|
+
|
|
103
|
+
| Entropy Range | Expected Content | Notes |
|
|
104
|
+
|---|---|---|
|
|
105
|
+
| `0.00 - 2.00` | Zero-padding, sparse tables | Common in uninitialized data or alignment padding |
|
|
106
|
+
| `2.00 - 5.50` | Standard ASCII, configurations | Normal application metadata, strings |
|
|
107
|
+
| `5.50 - 6.60` | Native compiled machine code | Standard x86/x64 instructions (`.text`) |
|
|
108
|
+
| `6.60 - 7.30` | Compressed assets | Bitmaps, icons, zlib/deflate streams |
|
|
109
|
+
| `7.40 - 8.00` | Cryptographic ciphertext | AES/RC4 encrypted payloads or tightly packed shellcode |
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## License
|
|
114
|
+
|
|
115
|
+
MIT License. See [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""
|
|
2
|
+
EntropyStrip: Algorithmic PE De-obfuscator, Shannon Entropy Radar, and Incident Triage Engine.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
__version__ = "1.0.0"
|
|
6
|
+
__author__ = "dwexi"
|
|
7
|
+
|
|
8
|
+
from .core import (
|
|
9
|
+
calculate_entropy,
|
|
10
|
+
calculate_dilution_metrics,
|
|
11
|
+
analyze_single_file,
|
|
12
|
+
scan_directory,
|
|
13
|
+
main,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
"calculate_entropy",
|
|
18
|
+
"calculate_dilution_metrics",
|
|
19
|
+
"analyze_single_file",
|
|
20
|
+
"scan_directory",
|
|
21
|
+
"main",
|
|
22
|
+
"__version__",
|
|
23
|
+
]
|