hemspect 3.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.
@@ -0,0 +1,319 @@
1
+ Metadata-Version: 2.4
2
+ Name: hemspect
3
+ Version: 3.0.0
4
+ Summary: Enterprise package security scanner for PSADT
5
+ Author: Hemendra Mahajan
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: License :: OSI Approved :: MIT License
8
+ Classifier: Operating System :: OS Independent
9
+ Requires-Python: >=3.7
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: pyyaml>=6.0
12
+ Requires-Dist: cryptography>=41.0.0
13
+ Requires-Dist: pefile>=2023.2.7
14
+
15
+ # 🛡 HemSpect v3.0
16
+
17
+ **Package Security Scanner**
18
+
19
+ > Compliance: NIST SP 800-53 Rev5 | CMMC 2.0 | IEC 62443-2-4 | CIS Controls v8 | MITRE ATT&CK
20
+
21
+ HemSpect is an enterprise security scanner purpose-built for organizations that deploy software using the **PowerShell App Deployment Toolkit (PSADT)**. It performs deep security analysis of deployment packages before they reach production endpoints — catching credential leaks, malware techniques, and compliance violations that antivirus and EDR solutions miss.
22
+
23
+ ---
24
+
25
+ ## ⚡ Key Features
26
+
27
+ | Feature | Description |
28
+ |---------|-------------|
29
+ | **HemSpect Engine** | 3-tier data leakage intelligence engine — extension classification, filename heuristics, and deep content regex scanning for connection strings, cloud tokens, XML credentials, and more |
30
+ | **60+ Detection Patterns** | AMSI bypasses, LOLBin abuse, WMI persistence, ETW tampering, credential dumping, obfuscation, and PSADT v4 cmdlet misuse |
31
+ | **Factory Scan Mode** | Batch-scan an entire package factory (300+ packages) in one command with a consolidated HTML dashboard |
32
+ | **Dynamic Secrets Detection** | Integrates Yelp's `detect-secrets` entropy engine for catching passwords that static regex misses |
33
+ | **MITRE ATT&CK Mapping** | Every finding is mapped to ATT&CK techniques with a visual heatmap in the HTML report |
34
+ | **Compliance Matrix** | Automatic compliance tagging against NIST 800-53, CMMC 2.0, IEC 62443, and CIS Controls v8 |
35
+ | **CVSS v3.1 Scoring** | Each finding includes a computed CVSS base score and vector string |
36
+ | **Cryptographic Signing** | ECDSA P-256 signed manifests for tamper-proof chain-of-custody |
37
+ | **3-Stage Approval Workflow** | `AUTO_SCAN` → `ANALYST_REVIEW` → `CISO_APPROVAL` with full audit trail |
38
+ | **SBOM Generation** | CycloneDX 1.4 JSON + SPDX 2.3 tag-value format with NVD CVE correlation |
39
+ | **Multi-Format Reports** | HTML dashboard, JSON, CSV, SARIF (GitHub/Azure DevOps), JUnit XML (CI/CD gating) |
40
+ | **MSI Custom Action Analysis** | Flags dangerous Type 1 (DLL), Type 2 (EXE), and Type 34/1074 (deferred system context) custom actions |
41
+
42
+ ---
43
+
44
+ ## 🚀 Quick Start
45
+
46
+ ### Prerequisites
47
+
48
+ - Python 3.9 or higher
49
+ - Windows 10/11 or Windows Server 2016+
50
+ - PowerShell 5.1+
51
+
52
+ ### Installation
53
+
54
+ ```powershell
55
+ # Clone the repository
56
+ git clone https://github.com/hemmhjn87/psadt_secure.git
57
+ cd psadt_secure
58
+
59
+ # Create a virtual environment (recommended)
60
+ python -m venv venv
61
+ .\venv\Scripts\Activate.ps1
62
+
63
+ # Install dependencies
64
+ pip install -r requirements.txt
65
+ ```
66
+
67
+ ### Scan a Single Package
68
+
69
+ ```powershell
70
+ # Interactive mode (prompts for report folder name)
71
+ python main.py scan "C:\Packages\MyApp" --format all
72
+
73
+ # Specify output directory
74
+ python main.py scan "C:\Packages\MyApp" -o "C:\HemSpect\MyApp" --format all --sign-report
75
+ ```
76
+
77
+ ### Factory Scan (Batch Mode)
78
+
79
+ ```powershell
80
+ # Scan your entire package factory in one shot
81
+ python main.py factory-scan "\\server\PackageFactory" -o "C:\HemSpect\FactoryReport"
82
+ ```
83
+
84
+ ---
85
+
86
+ ## 📖 Commands Reference
87
+
88
+ ### `scan` — Scan a Single Package
89
+
90
+ ```
91
+ python main.py scan <PACKAGE_PATH> [OPTIONS]
92
+ ```
93
+
94
+ | Option | Description | Default |
95
+ |--------|-------------|---------|
96
+ | `-o`, `--output-dir` | Output directory for reports | `C:\HemSpect\<prompted>` |
97
+ | `-f`, `--format` | Output formats: `html,json,csv,sarif,junit,sbom,all` | `html,json,csv` |
98
+ | `--sign-report` | Generate ECDSA-signed manifest | off |
99
+ | `--signing-key` | Path to ECDSA private key PEM | ephemeral key |
100
+ | `--allowlist` | Path to `allowlist.yaml` for exception management | none |
101
+ | `--operator` | Operator name for audit log | system username |
102
+ | `--nvd-api-key` | NVD API key for SBOM CVE lookups | `NVD_API_KEY` env var |
103
+ | `--no-network` | Offline mode: skip NVD/OCSP lookups | off |
104
+ | `--ci` | CI/CD mode: JSON to stdout, minimal output | off |
105
+ | `--fail-on` | Severities that cause non-zero exit | `critical,high` |
106
+ | `--compliance` | Filter by framework: `nist,cmmc,iec62443,cis,all` | `all` |
107
+
108
+ ### `factory-scan` — Batch Scan Entire Package Factory
109
+
110
+ ```
111
+ python main.py factory-scan <FACTORY_PATH> [OPTIONS]
112
+ ```
113
+
114
+ | Option | Description | Default |
115
+ |--------|-------------|---------|
116
+ | `-o`, `--output-dir` | Output directory for consolidated reports | `C:\HemSpect\factory_scan_TIMESTAMP` |
117
+ | `--operator` | Operator name for audit log | system username |
118
+
119
+ **Auto-discovery**: The factory scanner automatically identifies PSADT packages by looking for folders containing:
120
+ - `Deploy-Application.ps1`
121
+ - `Invoke-AppDeployToolkit.ps1`
122
+ - `AppDeployToolkit` subdirectory
123
+ - Any `.msi` or `.msix` files
124
+ - Any `.ps1` scripts
125
+
126
+ ### `verify` — Verify Signed Manifest
127
+
128
+ ```powershell
129
+ python main.py verify "C:\HemSpect\MyApp"
130
+ ```
131
+
132
+ ### `workflow` — Manage Approval Workflow
133
+
134
+ ```powershell
135
+ # Analyst review
136
+ python main.py workflow analyst-review "C:\HemSpect\MyApp" "Jane.Smith" --approve --notes "All FPs validated"
137
+
138
+ # CISO approval
139
+ python main.py workflow ciso-approve "C:\HemSpect\MyApp" "CEO.Name" "AUTH-20260601" --approve
140
+ ```
141
+
142
+ ---
143
+
144
+ ## 🔍 Scan Pipeline (9 Steps)
145
+
146
+ | Step | Engine | What It Does |
147
+ |------|--------|-------------|
148
+ | 1 | **PowerShell Analysis** | 60+ pattern matching against AMSI bypasses, LOLBins, persistence, credential dumping, PSADT cmdlet misuse |
149
+ | 2 | **Binary Analysis** | PE file inspection, Authenticode chain-of-trust verification, entropy analysis |
150
+ | 3 | **Credential Detection** | Static regex + Yelp `detect-secrets` entropy engine for passwords, API keys, tokens |
151
+ | 4 | **HemSpect Engine** | 3-tier data leakage sweep — dangerous file types, suspicious filenames, deep content regex |
152
+ | 5 | **Malware Patterns** | C2 indicators, process injection, ransomware keywords, data exfiltration |
153
+ | 6 | **Configuration Analysis** | Dependency scanning, config file analysis |
154
+ | 7 | **PSADT v4 Compliance** | Deprecated v3 API detection, cmdlet misuse, exit code handling |
155
+ | 8 | **MSI Analysis** | Custom action type classification, unsigned MSI detection |
156
+ | 9 | **Risk Scoring** | CVSS v3.1 computation, MITRE mapping, approval decision |
157
+
158
+ ---
159
+
160
+ ## 🕵 HemSpect — Data Leakage Intelligence Engine
161
+
162
+ HemSpect is our proprietary 3-tier data leakage detection engine that ensures no sensitive data ships inside deployment packages.
163
+
164
+ ### Tier 1 — Extension Classifier
165
+ Instantly flags file types that should **never** exist in a deployment package:
166
+
167
+ | Category | Extensions |
168
+ |----------|-----------|
169
+ | Credential Stores | `.kdbx`, `.kdb`, `.keychain`, `.jks`, `.keystore`, `.pfx`, `.p12`, `.pem`, `.key`, `.ppk` |
170
+ | Email/Mailbox | `.ost`, `.pst`, `.eml`, `.msg` |
171
+ | Database Files | `.mdf`, `.ldf`, `.sdf`, `.sqlite`, `.bak` |
172
+ | RDP/VPN Configs | `.rdp`, `.rdg`, `.ovpn`, `.pcf` |
173
+ | Memory Dumps | `.dmp`, `.vmem`, `.vmdk` |
174
+
175
+ ### Tier 2 — Filename Heuristic
176
+ Flags files with suspicious names like `password.txt`, `id_rsa`, `unattend.xml`, `web.config`, `.env`, `ntds.dit`, `kubeconfig`, and 13+ patterns.
177
+
178
+ ### Tier 3 — Deep Content Regex
179
+ Scans file contents for:
180
+ - SQL/OLEDB/JDBC/MongoDB connection strings with embedded passwords
181
+ - XML credential elements and attributes
182
+ - .NET machine keys and validation keys
183
+ - Windows Unattend/Sysprep embedded passwords
184
+ - AWS/Azure/GCP cloud provider secrets
185
+ - OAuth Bearer/JWT tokens
186
+ - SMTP credentials
187
+ - Docker registry auth tokens
188
+ - WiFi passwords in exported profiles
189
+ - Registry exports with stored credentials
190
+
191
+ ---
192
+
193
+ ## 📊 Output Formats
194
+
195
+ | Format | File | Use Case |
196
+ |--------|------|----------|
197
+ | **HTML** | `report.html` | Interactive dashboard for analysts and auditors |
198
+ | **JSON** | `findings.json` | Programmatic consumption, SIEM integration |
199
+ | **CSV** | `findings.csv` | Excel/spreadsheet analysis |
200
+ | **SARIF** | `findings.sarif.json` | GitHub Advanced Security, Azure DevOps |
201
+ | **JUnit** | `findings_junit.xml` | CI/CD pipeline gating (Jenkins, GitLab, Azure Pipelines) |
202
+ | **CycloneDX** | `sbom.cyclonedx.json` | Software Bill of Materials (NTIA compliant) |
203
+ | **SPDX** | `sbom.spdx` | Alternative SBOM format |
204
+ | **Factory HTML** | `factory_report.html` | Consolidated dashboard for batch scans |
205
+ | **Factory CSV** | `factory_results.csv` | Batch scan results for Excel |
206
+ | **Factory JSON** | `factory_results.json` | Batch scan results for automation |
207
+
208
+ ---
209
+
210
+ ## 🔐 Exit Codes
211
+
212
+ | Code | Meaning |
213
+ |------|---------|
214
+ | `0` | **APPROVED** — Package meets all security thresholds |
215
+ | `1` | **REVIEW REQUIRED** — Manual analyst review needed |
216
+ | `2` | **REJECTED** — Critical/High findings above threshold |
217
+ | `3` | **SCAN ERROR** — Exception during scan |
218
+ | `4` | **MANIFEST INVALID** — Signature verification failed |
219
+
220
+ ---
221
+
222
+ ## 📁 Project Structure
223
+
224
+ ```
225
+ hemspect/
226
+ ├── main.py # CLI entry point
227
+ ├── requirements.txt # Python dependencies
228
+ ├── config/
229
+ │ ├── rules.yaml # Custom detection rules
230
+ │ └── allowlist.yaml # Exception management
231
+ ├── src/
232
+ │ └── scanners/
233
+ │ ├── scan_psadt.py # Core scanner engine + HemSpect
234
+ │ ├── report_generator.py # Enterprise HTML report generator
235
+ │ ├── sbom_generator.py # CycloneDX + SPDX SBOM generator
236
+ │ └── approval_workflow.py # 3-stage approval workflow
237
+
238
+ ```
239
+
240
+ ---
241
+
242
+ ## ⚙️ Configuration
243
+
244
+ ### Custom Rules (`config/rules.yaml`)
245
+
246
+ Add custom detection patterns without modifying source code:
247
+
248
+ ```yaml
249
+ custom_rules:
250
+ my_company_api_key:
251
+ pattern: "(?i)MYCOMPANY-API-[A-Za-z0-9]{32}"
252
+ severity: CRITICAL
253
+ description: "MyCompany API key detected"
254
+ remediation: "Use Azure Key Vault instead"
255
+ ```
256
+
257
+ ### Allowlist (`config/allowlist.yaml`)
258
+
259
+ Suppress known false positives with audit trail:
260
+
261
+ ```yaml
262
+ exceptions:
263
+ - rule_id: hardcoded_credential
264
+ file_pattern: "*/test_data/*"
265
+ reason: "Test fixture data, not real credentials"
266
+ approved_by: "Jane.Smith"
267
+ expires: "2027-01-01"
268
+ ```
269
+
270
+ ---
271
+
272
+ ## 🏭 Enterprise Deployment
273
+
274
+ ### Scheduled Factory Scan (Windows Task Scheduler)
275
+
276
+ ```powershell
277
+ # Create a nightly scheduled task
278
+ $action = New-ScheduledTaskAction -Execute "python" -Argument "main.py factory-scan \\server\PackageFactory -o C:\HemSpect\Nightly"
279
+ $trigger = New-ScheduledTaskTrigger -Daily -At "02:00AM"
280
+ Register-ScheduledTask -TaskName "HemSpect-Nightly" -Action $action -Trigger $trigger
281
+ ```
282
+
283
+ ### CI/CD Integration (Azure DevOps)
284
+
285
+ ```yaml
286
+ - task: PythonScript@0
287
+ inputs:
288
+ scriptPath: 'main.py'
289
+ arguments: 'scan $(Build.SourcesDirectory) --ci --fail-on critical,high --format sarif'
290
+ displayName: 'PSADT Security Scan'
291
+ ```
292
+
293
+ ---
294
+
295
+ ## 📜 Compliance Mapping
296
+
297
+ | Framework | Coverage |
298
+ |-----------|----------|
299
+ | **NIST SP 800-53 Rev5** | SI-3, SI-7, CM-7, AC-6, AU-9, SA-11 |
300
+ | **CMMC 2.0** | SI.1.210, SI.2.214, AU.2.041, CM.2.061 |
301
+ | **IEC 62443-2-4** | SR 3.2, SR 3.4 |
302
+ | **CIS Controls v8** | CIS-2, CIS-7, CIS-10, CIS-13 |
303
+ | **MITRE ATT&CK** | 30+ techniques across 14 tactics |
304
+
305
+ ---
306
+
307
+ ## 🤝 Contributing
308
+
309
+ 1. Fork the repository
310
+ 2. Create your feature branch (`git checkout -b feature/new-detection`)
311
+ 3. Commit your changes (`git commit -m 'feat: add new detection pattern'`)
312
+ 4. Push to the branch (`git push origin feature/new-detection`)
313
+ 5. Open a Pull Request
314
+
315
+ ---
316
+
317
+ <p align="center">
318
+ <sub>// Designed by <b>Hem</b></sub>
319
+ </p>
@@ -0,0 +1,305 @@
1
+ # 🛡 HemSpect v3.0
2
+
3
+ **Package Security Scanner**
4
+
5
+ > Compliance: NIST SP 800-53 Rev5 | CMMC 2.0 | IEC 62443-2-4 | CIS Controls v8 | MITRE ATT&CK
6
+
7
+ HemSpect is an enterprise security scanner purpose-built for organizations that deploy software using the **PowerShell App Deployment Toolkit (PSADT)**. It performs deep security analysis of deployment packages before they reach production endpoints — catching credential leaks, malware techniques, and compliance violations that antivirus and EDR solutions miss.
8
+
9
+ ---
10
+
11
+ ## ⚡ Key Features
12
+
13
+ | Feature | Description |
14
+ |---------|-------------|
15
+ | **HemSpect Engine** | 3-tier data leakage intelligence engine — extension classification, filename heuristics, and deep content regex scanning for connection strings, cloud tokens, XML credentials, and more |
16
+ | **60+ Detection Patterns** | AMSI bypasses, LOLBin abuse, WMI persistence, ETW tampering, credential dumping, obfuscation, and PSADT v4 cmdlet misuse |
17
+ | **Factory Scan Mode** | Batch-scan an entire package factory (300+ packages) in one command with a consolidated HTML dashboard |
18
+ | **Dynamic Secrets Detection** | Integrates Yelp's `detect-secrets` entropy engine for catching passwords that static regex misses |
19
+ | **MITRE ATT&CK Mapping** | Every finding is mapped to ATT&CK techniques with a visual heatmap in the HTML report |
20
+ | **Compliance Matrix** | Automatic compliance tagging against NIST 800-53, CMMC 2.0, IEC 62443, and CIS Controls v8 |
21
+ | **CVSS v3.1 Scoring** | Each finding includes a computed CVSS base score and vector string |
22
+ | **Cryptographic Signing** | ECDSA P-256 signed manifests for tamper-proof chain-of-custody |
23
+ | **3-Stage Approval Workflow** | `AUTO_SCAN` → `ANALYST_REVIEW` → `CISO_APPROVAL` with full audit trail |
24
+ | **SBOM Generation** | CycloneDX 1.4 JSON + SPDX 2.3 tag-value format with NVD CVE correlation |
25
+ | **Multi-Format Reports** | HTML dashboard, JSON, CSV, SARIF (GitHub/Azure DevOps), JUnit XML (CI/CD gating) |
26
+ | **MSI Custom Action Analysis** | Flags dangerous Type 1 (DLL), Type 2 (EXE), and Type 34/1074 (deferred system context) custom actions |
27
+
28
+ ---
29
+
30
+ ## 🚀 Quick Start
31
+
32
+ ### Prerequisites
33
+
34
+ - Python 3.9 or higher
35
+ - Windows 10/11 or Windows Server 2016+
36
+ - PowerShell 5.1+
37
+
38
+ ### Installation
39
+
40
+ ```powershell
41
+ # Clone the repository
42
+ git clone https://github.com/hemmhjn87/psadt_secure.git
43
+ cd psadt_secure
44
+
45
+ # Create a virtual environment (recommended)
46
+ python -m venv venv
47
+ .\venv\Scripts\Activate.ps1
48
+
49
+ # Install dependencies
50
+ pip install -r requirements.txt
51
+ ```
52
+
53
+ ### Scan a Single Package
54
+
55
+ ```powershell
56
+ # Interactive mode (prompts for report folder name)
57
+ python main.py scan "C:\Packages\MyApp" --format all
58
+
59
+ # Specify output directory
60
+ python main.py scan "C:\Packages\MyApp" -o "C:\HemSpect\MyApp" --format all --sign-report
61
+ ```
62
+
63
+ ### Factory Scan (Batch Mode)
64
+
65
+ ```powershell
66
+ # Scan your entire package factory in one shot
67
+ python main.py factory-scan "\\server\PackageFactory" -o "C:\HemSpect\FactoryReport"
68
+ ```
69
+
70
+ ---
71
+
72
+ ## 📖 Commands Reference
73
+
74
+ ### `scan` — Scan a Single Package
75
+
76
+ ```
77
+ python main.py scan <PACKAGE_PATH> [OPTIONS]
78
+ ```
79
+
80
+ | Option | Description | Default |
81
+ |--------|-------------|---------|
82
+ | `-o`, `--output-dir` | Output directory for reports | `C:\HemSpect\<prompted>` |
83
+ | `-f`, `--format` | Output formats: `html,json,csv,sarif,junit,sbom,all` | `html,json,csv` |
84
+ | `--sign-report` | Generate ECDSA-signed manifest | off |
85
+ | `--signing-key` | Path to ECDSA private key PEM | ephemeral key |
86
+ | `--allowlist` | Path to `allowlist.yaml` for exception management | none |
87
+ | `--operator` | Operator name for audit log | system username |
88
+ | `--nvd-api-key` | NVD API key for SBOM CVE lookups | `NVD_API_KEY` env var |
89
+ | `--no-network` | Offline mode: skip NVD/OCSP lookups | off |
90
+ | `--ci` | CI/CD mode: JSON to stdout, minimal output | off |
91
+ | `--fail-on` | Severities that cause non-zero exit | `critical,high` |
92
+ | `--compliance` | Filter by framework: `nist,cmmc,iec62443,cis,all` | `all` |
93
+
94
+ ### `factory-scan` — Batch Scan Entire Package Factory
95
+
96
+ ```
97
+ python main.py factory-scan <FACTORY_PATH> [OPTIONS]
98
+ ```
99
+
100
+ | Option | Description | Default |
101
+ |--------|-------------|---------|
102
+ | `-o`, `--output-dir` | Output directory for consolidated reports | `C:\HemSpect\factory_scan_TIMESTAMP` |
103
+ | `--operator` | Operator name for audit log | system username |
104
+
105
+ **Auto-discovery**: The factory scanner automatically identifies PSADT packages by looking for folders containing:
106
+ - `Deploy-Application.ps1`
107
+ - `Invoke-AppDeployToolkit.ps1`
108
+ - `AppDeployToolkit` subdirectory
109
+ - Any `.msi` or `.msix` files
110
+ - Any `.ps1` scripts
111
+
112
+ ### `verify` — Verify Signed Manifest
113
+
114
+ ```powershell
115
+ python main.py verify "C:\HemSpect\MyApp"
116
+ ```
117
+
118
+ ### `workflow` — Manage Approval Workflow
119
+
120
+ ```powershell
121
+ # Analyst review
122
+ python main.py workflow analyst-review "C:\HemSpect\MyApp" "Jane.Smith" --approve --notes "All FPs validated"
123
+
124
+ # CISO approval
125
+ python main.py workflow ciso-approve "C:\HemSpect\MyApp" "CEO.Name" "AUTH-20260601" --approve
126
+ ```
127
+
128
+ ---
129
+
130
+ ## 🔍 Scan Pipeline (9 Steps)
131
+
132
+ | Step | Engine | What It Does |
133
+ |------|--------|-------------|
134
+ | 1 | **PowerShell Analysis** | 60+ pattern matching against AMSI bypasses, LOLBins, persistence, credential dumping, PSADT cmdlet misuse |
135
+ | 2 | **Binary Analysis** | PE file inspection, Authenticode chain-of-trust verification, entropy analysis |
136
+ | 3 | **Credential Detection** | Static regex + Yelp `detect-secrets` entropy engine for passwords, API keys, tokens |
137
+ | 4 | **HemSpect Engine** | 3-tier data leakage sweep — dangerous file types, suspicious filenames, deep content regex |
138
+ | 5 | **Malware Patterns** | C2 indicators, process injection, ransomware keywords, data exfiltration |
139
+ | 6 | **Configuration Analysis** | Dependency scanning, config file analysis |
140
+ | 7 | **PSADT v4 Compliance** | Deprecated v3 API detection, cmdlet misuse, exit code handling |
141
+ | 8 | **MSI Analysis** | Custom action type classification, unsigned MSI detection |
142
+ | 9 | **Risk Scoring** | CVSS v3.1 computation, MITRE mapping, approval decision |
143
+
144
+ ---
145
+
146
+ ## 🕵 HemSpect — Data Leakage Intelligence Engine
147
+
148
+ HemSpect is our proprietary 3-tier data leakage detection engine that ensures no sensitive data ships inside deployment packages.
149
+
150
+ ### Tier 1 — Extension Classifier
151
+ Instantly flags file types that should **never** exist in a deployment package:
152
+
153
+ | Category | Extensions |
154
+ |----------|-----------|
155
+ | Credential Stores | `.kdbx`, `.kdb`, `.keychain`, `.jks`, `.keystore`, `.pfx`, `.p12`, `.pem`, `.key`, `.ppk` |
156
+ | Email/Mailbox | `.ost`, `.pst`, `.eml`, `.msg` |
157
+ | Database Files | `.mdf`, `.ldf`, `.sdf`, `.sqlite`, `.bak` |
158
+ | RDP/VPN Configs | `.rdp`, `.rdg`, `.ovpn`, `.pcf` |
159
+ | Memory Dumps | `.dmp`, `.vmem`, `.vmdk` |
160
+
161
+ ### Tier 2 — Filename Heuristic
162
+ Flags files with suspicious names like `password.txt`, `id_rsa`, `unattend.xml`, `web.config`, `.env`, `ntds.dit`, `kubeconfig`, and 13+ patterns.
163
+
164
+ ### Tier 3 — Deep Content Regex
165
+ Scans file contents for:
166
+ - SQL/OLEDB/JDBC/MongoDB connection strings with embedded passwords
167
+ - XML credential elements and attributes
168
+ - .NET machine keys and validation keys
169
+ - Windows Unattend/Sysprep embedded passwords
170
+ - AWS/Azure/GCP cloud provider secrets
171
+ - OAuth Bearer/JWT tokens
172
+ - SMTP credentials
173
+ - Docker registry auth tokens
174
+ - WiFi passwords in exported profiles
175
+ - Registry exports with stored credentials
176
+
177
+ ---
178
+
179
+ ## 📊 Output Formats
180
+
181
+ | Format | File | Use Case |
182
+ |--------|------|----------|
183
+ | **HTML** | `report.html` | Interactive dashboard for analysts and auditors |
184
+ | **JSON** | `findings.json` | Programmatic consumption, SIEM integration |
185
+ | **CSV** | `findings.csv` | Excel/spreadsheet analysis |
186
+ | **SARIF** | `findings.sarif.json` | GitHub Advanced Security, Azure DevOps |
187
+ | **JUnit** | `findings_junit.xml` | CI/CD pipeline gating (Jenkins, GitLab, Azure Pipelines) |
188
+ | **CycloneDX** | `sbom.cyclonedx.json` | Software Bill of Materials (NTIA compliant) |
189
+ | **SPDX** | `sbom.spdx` | Alternative SBOM format |
190
+ | **Factory HTML** | `factory_report.html` | Consolidated dashboard for batch scans |
191
+ | **Factory CSV** | `factory_results.csv` | Batch scan results for Excel |
192
+ | **Factory JSON** | `factory_results.json` | Batch scan results for automation |
193
+
194
+ ---
195
+
196
+ ## 🔐 Exit Codes
197
+
198
+ | Code | Meaning |
199
+ |------|---------|
200
+ | `0` | **APPROVED** — Package meets all security thresholds |
201
+ | `1` | **REVIEW REQUIRED** — Manual analyst review needed |
202
+ | `2` | **REJECTED** — Critical/High findings above threshold |
203
+ | `3` | **SCAN ERROR** — Exception during scan |
204
+ | `4` | **MANIFEST INVALID** — Signature verification failed |
205
+
206
+ ---
207
+
208
+ ## 📁 Project Structure
209
+
210
+ ```
211
+ hemspect/
212
+ ├── main.py # CLI entry point
213
+ ├── requirements.txt # Python dependencies
214
+ ├── config/
215
+ │ ├── rules.yaml # Custom detection rules
216
+ │ └── allowlist.yaml # Exception management
217
+ ├── src/
218
+ │ └── scanners/
219
+ │ ├── scan_psadt.py # Core scanner engine + HemSpect
220
+ │ ├── report_generator.py # Enterprise HTML report generator
221
+ │ ├── sbom_generator.py # CycloneDX + SPDX SBOM generator
222
+ │ └── approval_workflow.py # 3-stage approval workflow
223
+
224
+ ```
225
+
226
+ ---
227
+
228
+ ## ⚙️ Configuration
229
+
230
+ ### Custom Rules (`config/rules.yaml`)
231
+
232
+ Add custom detection patterns without modifying source code:
233
+
234
+ ```yaml
235
+ custom_rules:
236
+ my_company_api_key:
237
+ pattern: "(?i)MYCOMPANY-API-[A-Za-z0-9]{32}"
238
+ severity: CRITICAL
239
+ description: "MyCompany API key detected"
240
+ remediation: "Use Azure Key Vault instead"
241
+ ```
242
+
243
+ ### Allowlist (`config/allowlist.yaml`)
244
+
245
+ Suppress known false positives with audit trail:
246
+
247
+ ```yaml
248
+ exceptions:
249
+ - rule_id: hardcoded_credential
250
+ file_pattern: "*/test_data/*"
251
+ reason: "Test fixture data, not real credentials"
252
+ approved_by: "Jane.Smith"
253
+ expires: "2027-01-01"
254
+ ```
255
+
256
+ ---
257
+
258
+ ## 🏭 Enterprise Deployment
259
+
260
+ ### Scheduled Factory Scan (Windows Task Scheduler)
261
+
262
+ ```powershell
263
+ # Create a nightly scheduled task
264
+ $action = New-ScheduledTaskAction -Execute "python" -Argument "main.py factory-scan \\server\PackageFactory -o C:\HemSpect\Nightly"
265
+ $trigger = New-ScheduledTaskTrigger -Daily -At "02:00AM"
266
+ Register-ScheduledTask -TaskName "HemSpect-Nightly" -Action $action -Trigger $trigger
267
+ ```
268
+
269
+ ### CI/CD Integration (Azure DevOps)
270
+
271
+ ```yaml
272
+ - task: PythonScript@0
273
+ inputs:
274
+ scriptPath: 'main.py'
275
+ arguments: 'scan $(Build.SourcesDirectory) --ci --fail-on critical,high --format sarif'
276
+ displayName: 'PSADT Security Scan'
277
+ ```
278
+
279
+ ---
280
+
281
+ ## 📜 Compliance Mapping
282
+
283
+ | Framework | Coverage |
284
+ |-----------|----------|
285
+ | **NIST SP 800-53 Rev5** | SI-3, SI-7, CM-7, AC-6, AU-9, SA-11 |
286
+ | **CMMC 2.0** | SI.1.210, SI.2.214, AU.2.041, CM.2.061 |
287
+ | **IEC 62443-2-4** | SR 3.2, SR 3.4 |
288
+ | **CIS Controls v8** | CIS-2, CIS-7, CIS-10, CIS-13 |
289
+ | **MITRE ATT&CK** | 30+ techniques across 14 tactics |
290
+
291
+ ---
292
+
293
+ ## 🤝 Contributing
294
+
295
+ 1. Fork the repository
296
+ 2. Create your feature branch (`git checkout -b feature/new-detection`)
297
+ 3. Commit your changes (`git commit -m 'feat: add new detection pattern'`)
298
+ 4. Push to the branch (`git push origin feature/new-detection`)
299
+ 5. Open a Pull Request
300
+
301
+ ---
302
+
303
+ <p align="center">
304
+ <sub>// Designed by <b>Hem</b></sub>
305
+ </p>
@@ -0,0 +1,32 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "hemspect"
7
+ version = "3.0.0"
8
+ authors = [
9
+ { name="Hemendra Mahajan" },
10
+ ]
11
+ description = "Enterprise package security scanner for PSADT"
12
+ readme = "README.md"
13
+ requires-python = ">=3.7"
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Operating System :: OS Independent",
18
+ ]
19
+ dependencies = [
20
+ "pyyaml>=6.0",
21
+ "cryptography>=41.0.0",
22
+ "pefile>=2023.2.7"
23
+ ]
24
+
25
+ [project.scripts]
26
+ hemspect = "hemspect.cli:main"
27
+
28
+ [tool.setuptools.packages.find]
29
+ where = ["src"]
30
+
31
+ [tool.setuptools.package-data]
32
+ "hemspect.config" = ["*.yaml"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes