zen-ai-pentest 2.0.0__py3-none-any.whl
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.
- agents/__init__.py +28 -0
- agents/agent_base.py +239 -0
- agents/agent_orchestrator.py +346 -0
- agents/analysis_agent.py +225 -0
- agents/cli.py +258 -0
- agents/exploit_agent.py +224 -0
- agents/integration.py +211 -0
- agents/post_scan_agent.py +937 -0
- agents/react_agent.py +384 -0
- agents/react_agent_enhanced.py +616 -0
- agents/react_agent_vm.py +298 -0
- agents/research_agent.py +176 -0
- api/__init__.py +11 -0
- api/auth.py +123 -0
- api/main.py +1027 -0
- api/schemas.py +357 -0
- api/websocket.py +97 -0
- autonomous/__init__.py +122 -0
- autonomous/agent.py +253 -0
- autonomous/agent_loop.py +1370 -0
- autonomous/exploit_validator.py +1537 -0
- autonomous/memory.py +448 -0
- autonomous/react.py +339 -0
- autonomous/tool_executor.py +488 -0
- backends/__init__.py +16 -0
- backends/chatgpt_direct.py +133 -0
- backends/claude_direct.py +130 -0
- backends/duckduckgo.py +138 -0
- backends/openrouter.py +120 -0
- benchmarks/__init__.py +149 -0
- benchmarks/benchmark_engine.py +904 -0
- benchmarks/ci_benchmark.py +785 -0
- benchmarks/comparison.py +729 -0
- benchmarks/metrics.py +553 -0
- benchmarks/run_benchmarks.py +809 -0
- ci_cd/__init__.py +2 -0
- core/__init__.py +17 -0
- core/async_pool.py +282 -0
- core/asyncio_fix.py +222 -0
- core/cache.py +472 -0
- core/container.py +277 -0
- core/database.py +114 -0
- core/input_validator.py +353 -0
- core/models.py +288 -0
- core/orchestrator.py +611 -0
- core/plugin_manager.py +571 -0
- core/rate_limiter.py +405 -0
- core/secure_config.py +328 -0
- core/shield_integration.py +296 -0
- modules/__init__.py +46 -0
- modules/cve_database.py +362 -0
- modules/exploit_assist.py +330 -0
- modules/nuclei_integration.py +480 -0
- modules/osint.py +604 -0
- modules/protonvpn.py +554 -0
- modules/recon.py +165 -0
- modules/sql_injection_db.py +826 -0
- modules/tool_orchestrator.py +498 -0
- modules/vuln_scanner.py +292 -0
- modules/wordlist_generator.py +566 -0
- risk_engine/__init__.py +99 -0
- risk_engine/business_impact.py +267 -0
- risk_engine/business_impact_calculator.py +563 -0
- risk_engine/cvss.py +156 -0
- risk_engine/epss.py +190 -0
- risk_engine/example_usage.py +294 -0
- risk_engine/false_positive_engine.py +1073 -0
- risk_engine/scorer.py +304 -0
- web_ui/backend/main.py +471 -0
- zen_ai_pentest-2.0.0.dist-info/METADATA +795 -0
- zen_ai_pentest-2.0.0.dist-info/RECORD +75 -0
- zen_ai_pentest-2.0.0.dist-info/WHEEL +5 -0
- zen_ai_pentest-2.0.0.dist-info/entry_points.txt +2 -0
- zen_ai_pentest-2.0.0.dist-info/licenses/LICENSE +21 -0
- zen_ai_pentest-2.0.0.dist-info/top_level.txt +10 -0
modules/cve_database.py
ADDED
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
CVE Database Module
|
|
4
|
+
Comprehensive CVE database with ransomware and exploit information
|
|
5
|
+
Author: SHAdd0WTAka
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import json
|
|
9
|
+
import logging
|
|
10
|
+
import os
|
|
11
|
+
from dataclasses import dataclass
|
|
12
|
+
from datetime import datetime
|
|
13
|
+
from typing import Any, Dict, List, Optional
|
|
14
|
+
|
|
15
|
+
logger = logging.getLogger("ZenAI")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@dataclass
|
|
19
|
+
class CVEEntry:
|
|
20
|
+
"""CVE Entry data class"""
|
|
21
|
+
|
|
22
|
+
cve_id: str
|
|
23
|
+
name: str
|
|
24
|
+
cvss_score: float
|
|
25
|
+
severity: str
|
|
26
|
+
description: str
|
|
27
|
+
affected_products: List[str]
|
|
28
|
+
exploits: List[str]
|
|
29
|
+
patches: List[str]
|
|
30
|
+
mitigations: List[str]
|
|
31
|
+
detection_methods: List[str]
|
|
32
|
+
ransomware_used_by: List[str] = None
|
|
33
|
+
ioc: Dict = None
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@dataclass
|
|
37
|
+
class RansomwareEntry:
|
|
38
|
+
"""Ransomware entry"""
|
|
39
|
+
|
|
40
|
+
name: str
|
|
41
|
+
first_seen: str
|
|
42
|
+
type: str
|
|
43
|
+
description: str
|
|
44
|
+
cves: List[str]
|
|
45
|
+
file_extensions: List[str]
|
|
46
|
+
ransom_note: str
|
|
47
|
+
ioc: Dict
|
|
48
|
+
mitigation: List[str]
|
|
49
|
+
detection: List[str]
|
|
50
|
+
decryptable: bool
|
|
51
|
+
estimated_damage: int = 0
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class CVEDatabase:
|
|
55
|
+
"""
|
|
56
|
+
Comprehensive CVE and Ransomware Database
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
def __init__(self, orchestrator=None):
|
|
60
|
+
self.orchestrator = orchestrator
|
|
61
|
+
self.db_path = "data/cve_db"
|
|
62
|
+
self.ransomware_data = {}
|
|
63
|
+
self.cve_data = {}
|
|
64
|
+
self.exploit_chains = {}
|
|
65
|
+
|
|
66
|
+
self._load_databases()
|
|
67
|
+
|
|
68
|
+
def _load_databases(self):
|
|
69
|
+
"""Load all database files"""
|
|
70
|
+
# Load ransomware database
|
|
71
|
+
ransomware_file = os.path.join(self.db_path, "ransomware_cves.json")
|
|
72
|
+
if os.path.exists(ransomware_file):
|
|
73
|
+
try:
|
|
74
|
+
with open(ransomware_file, "r") as f:
|
|
75
|
+
data = json.load(f)
|
|
76
|
+
self.ransomware_data = data.get("ransomware_campaigns", {})
|
|
77
|
+
self.cve_data = data.get("critical_historical_cves", {})
|
|
78
|
+
self.exploit_chains = data.get("common_exploit_chains", {})
|
|
79
|
+
logger.info(
|
|
80
|
+
f"[CVE DB] Loaded {len(self.ransomware_data)} ransomware entries, {len(self.cve_data)} CVEs"
|
|
81
|
+
)
|
|
82
|
+
except Exception as e:
|
|
83
|
+
logger.error(f"[CVE DB] Error loading database: {e}")
|
|
84
|
+
|
|
85
|
+
def search_cve(self, cve_id: str) -> Optional[CVEEntry]:
|
|
86
|
+
"""Search for a specific CVE"""
|
|
87
|
+
cve_id = cve_id.upper()
|
|
88
|
+
|
|
89
|
+
if cve_id in self.cve_data:
|
|
90
|
+
data = self.cve_data[cve_id]
|
|
91
|
+
return CVEEntry(
|
|
92
|
+
cve_id=cve_id,
|
|
93
|
+
name=data.get("name", ""),
|
|
94
|
+
cvss_score=data.get("cvss", 0.0),
|
|
95
|
+
severity=data.get("severity", "Unknown"),
|
|
96
|
+
description=data.get("description", ""),
|
|
97
|
+
affected_products=data.get("affected_products", []),
|
|
98
|
+
exploits=data.get("exploits", []),
|
|
99
|
+
patches=[data.get("patch", "")] if data.get("patch") else [],
|
|
100
|
+
mitigations=data.get("mitigation", []),
|
|
101
|
+
detection_methods=data.get("detection", []),
|
|
102
|
+
ransomware_used_by=data.get("ransomware_used_by", []),
|
|
103
|
+
)
|
|
104
|
+
return None
|
|
105
|
+
|
|
106
|
+
def search_ransomware(self, name: str) -> Optional[RansomwareEntry]:
|
|
107
|
+
"""Search for ransomware by name"""
|
|
108
|
+
name_lower = name.lower()
|
|
109
|
+
|
|
110
|
+
for key, data in self.ransomware_data.items():
|
|
111
|
+
if name_lower in key.lower() or name_lower in data.get("name", "").lower():
|
|
112
|
+
return RansomwareEntry(
|
|
113
|
+
name=data.get("name", key),
|
|
114
|
+
first_seen=data.get("first_seen", ""),
|
|
115
|
+
type=data.get("type", ""),
|
|
116
|
+
description=data.get("description", ""),
|
|
117
|
+
cves=data.get("cves", []),
|
|
118
|
+
file_extensions=data.get("file_extensions", []),
|
|
119
|
+
ransom_note=data.get("ransom_note", ""),
|
|
120
|
+
ioc=data.get("ioc", {}),
|
|
121
|
+
mitigation=data.get("mitigation", []),
|
|
122
|
+
detection=data.get("detection", []),
|
|
123
|
+
decryptable=data.get("decryptable", False),
|
|
124
|
+
estimated_damage=data.get("estimated_damage_usd", 0),
|
|
125
|
+
)
|
|
126
|
+
return None
|
|
127
|
+
|
|
128
|
+
def get_ransomware_by_cve(self, cve_id: str) -> List[str]:
|
|
129
|
+
"""Find ransomware that uses a specific CVE"""
|
|
130
|
+
cve_id = cve_id.upper()
|
|
131
|
+
results = []
|
|
132
|
+
|
|
133
|
+
for key, data in self.ransomware_data.items():
|
|
134
|
+
if cve_id in data.get("cves", []):
|
|
135
|
+
results.append(data.get("name", key))
|
|
136
|
+
|
|
137
|
+
return results
|
|
138
|
+
|
|
139
|
+
def get_cves_by_severity(self, severity: str) -> List[CVEEntry]:
|
|
140
|
+
"""Get all CVEs by severity level"""
|
|
141
|
+
results = []
|
|
142
|
+
severity = severity.capitalize()
|
|
143
|
+
|
|
144
|
+
for cve_id, data in self.cve_data.items():
|
|
145
|
+
if data.get("severity") == severity:
|
|
146
|
+
entry = self.search_cve(cve_id)
|
|
147
|
+
if entry:
|
|
148
|
+
results.append(entry)
|
|
149
|
+
|
|
150
|
+
return results
|
|
151
|
+
|
|
152
|
+
def get_critical_cves(self) -> List[CVEEntry]:
|
|
153
|
+
"""Get all critical CVEs"""
|
|
154
|
+
return self.get_cves_by_severity("Critical")
|
|
155
|
+
|
|
156
|
+
def get_ransomware_iocs(self, ransomware_name: str) -> Dict:
|
|
157
|
+
"""Get IOCs for a specific ransomware"""
|
|
158
|
+
entry = self.search_ransomware(ransomware_name)
|
|
159
|
+
if entry:
|
|
160
|
+
return entry.ioc
|
|
161
|
+
return {}
|
|
162
|
+
|
|
163
|
+
def check_system_for_ransomware(self, indicators: Dict) -> List[Dict]:
|
|
164
|
+
"""
|
|
165
|
+
Check system indicators against ransomware IOCs
|
|
166
|
+
indicators: dict with keys like 'files', 'registry', 'hashes', 'processes'
|
|
167
|
+
"""
|
|
168
|
+
matches = []
|
|
169
|
+
|
|
170
|
+
for key, data in self.ransomware_data.items():
|
|
171
|
+
ransomware_name = data.get("name", key)
|
|
172
|
+
ioc = data.get("ioc", {})
|
|
173
|
+
|
|
174
|
+
match_score = 0
|
|
175
|
+
match_details = []
|
|
176
|
+
|
|
177
|
+
# Check file indicators
|
|
178
|
+
if "files" in indicators and "files" in ioc:
|
|
179
|
+
for file in indicators["files"]:
|
|
180
|
+
for ioc_file in ioc["files"]:
|
|
181
|
+
if (
|
|
182
|
+
file.lower() in ioc_file.lower()
|
|
183
|
+
or ioc_file.lower() in file.lower()
|
|
184
|
+
):
|
|
185
|
+
match_score += 10
|
|
186
|
+
match_details.append(f"File match: {file}")
|
|
187
|
+
|
|
188
|
+
# Check registry indicators
|
|
189
|
+
if "registry" in indicators and "registry" in ioc:
|
|
190
|
+
for reg in indicators["registry"]:
|
|
191
|
+
for ioc_reg in ioc["registry"]:
|
|
192
|
+
if reg.lower() in ioc_reg.lower():
|
|
193
|
+
match_score += 10
|
|
194
|
+
match_details.append(f"Registry match: {reg}")
|
|
195
|
+
|
|
196
|
+
# Check hashes
|
|
197
|
+
if "hashes" in indicators and "hashes" in ioc:
|
|
198
|
+
for hash_val in indicators["hashes"]:
|
|
199
|
+
if hash_val.lower() in [h.lower() for h in ioc["hashes"]]:
|
|
200
|
+
match_score += 50 # Hash match is strong indicator
|
|
201
|
+
match_details.append(f"Hash match: {hash_val}")
|
|
202
|
+
|
|
203
|
+
# Check processes
|
|
204
|
+
if "processes" in indicators and "processes" in ioc:
|
|
205
|
+
for proc in indicators["processes"]:
|
|
206
|
+
for ioc_proc in ioc["processes"]:
|
|
207
|
+
if proc.lower() in ioc_proc.lower():
|
|
208
|
+
match_score += 15
|
|
209
|
+
match_details.append(f"Process match: {proc}")
|
|
210
|
+
|
|
211
|
+
if match_score >= 20:
|
|
212
|
+
matches.append(
|
|
213
|
+
{
|
|
214
|
+
"ransomware": ransomware_name,
|
|
215
|
+
"confidence": min(match_score, 100),
|
|
216
|
+
"indicators": match_details,
|
|
217
|
+
"recommendation": "Isolate system immediately and initiate incident response",
|
|
218
|
+
}
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
return sorted(matches, key=lambda x: x["confidence"], reverse=True)
|
|
222
|
+
|
|
223
|
+
async def analyze_vulnerability_for_ransomware_risk(self, cve_id: str) -> Dict:
|
|
224
|
+
"""Analyze if a CVE is commonly used by ransomware"""
|
|
225
|
+
cve_id = cve_id.upper()
|
|
226
|
+
entry = self.search_cve(cve_id)
|
|
227
|
+
|
|
228
|
+
if not entry:
|
|
229
|
+
return {"error": f"CVE {cve_id} not found"}
|
|
230
|
+
|
|
231
|
+
ransomware_list = entry.ransomware_used_by or []
|
|
232
|
+
risk_level = "High" if len(ransomware_list) > 0 else entry.severity
|
|
233
|
+
|
|
234
|
+
analysis = {
|
|
235
|
+
"cve_id": cve_id,
|
|
236
|
+
"cvss_score": entry.cvss_score,
|
|
237
|
+
"severity": entry.severity,
|
|
238
|
+
"ransomware_associated": ransomware_list,
|
|
239
|
+
"ransomware_risk": risk_level,
|
|
240
|
+
"mitigation_priority": "Critical" if ransomware_list else entry.severity,
|
|
241
|
+
"recommended_actions": entry.mitigations,
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
# Add LLM analysis if orchestrator available
|
|
245
|
+
if self.orchestrator and ransomware_list:
|
|
246
|
+
prompt = f"""
|
|
247
|
+
Analyze CVE {cve_id} which is used by ransomware: {', '.join(ransomware_list)}
|
|
248
|
+
|
|
249
|
+
Provide:
|
|
250
|
+
1. Why this CVE is attractive to ransomware operators
|
|
251
|
+
2. Historical context of attacks
|
|
252
|
+
3. Specific recommendations for ransomware prevention
|
|
253
|
+
4. Detection strategies beyond patching
|
|
254
|
+
"""
|
|
255
|
+
llm_response = await self.orchestrator.process(prompt)
|
|
256
|
+
analysis["ai_analysis"] = llm_response.content
|
|
257
|
+
|
|
258
|
+
return analysis
|
|
259
|
+
|
|
260
|
+
def get_exploit_chain(self, chain_name: str) -> Optional[Dict]:
|
|
261
|
+
"""Get a specific exploit chain"""
|
|
262
|
+
for key, data in self.exploit_chains.items():
|
|
263
|
+
if (
|
|
264
|
+
chain_name.lower() in key.lower()
|
|
265
|
+
or chain_name.lower() in data.get("name", "").lower()
|
|
266
|
+
):
|
|
267
|
+
return data
|
|
268
|
+
return None
|
|
269
|
+
|
|
270
|
+
def list_all_ransomware(self) -> List[Dict]:
|
|
271
|
+
"""List all ransomware in database"""
|
|
272
|
+
results = []
|
|
273
|
+
for key, data in self.ransomware_data.items():
|
|
274
|
+
results.append(
|
|
275
|
+
{
|
|
276
|
+
"key": key,
|
|
277
|
+
"name": data.get("name", key),
|
|
278
|
+
"first_seen": data.get("first_seen", ""),
|
|
279
|
+
"type": data.get("type", ""),
|
|
280
|
+
"decryptable": data.get("decryptable", False),
|
|
281
|
+
"cves": data.get("cves", []),
|
|
282
|
+
}
|
|
283
|
+
)
|
|
284
|
+
return results
|
|
285
|
+
|
|
286
|
+
def list_all_cves(self) -> List[Dict]:
|
|
287
|
+
"""List all CVEs in database"""
|
|
288
|
+
results = []
|
|
289
|
+
for cve_id, data in self.cve_data.items():
|
|
290
|
+
results.append(
|
|
291
|
+
{
|
|
292
|
+
"cve_id": cve_id,
|
|
293
|
+
"name": data.get("name", ""),
|
|
294
|
+
"cvss": data.get("cvss", 0),
|
|
295
|
+
"severity": data.get("severity", "Unknown"),
|
|
296
|
+
"ransomware_used_by": data.get("ransomware_used_by", []),
|
|
297
|
+
}
|
|
298
|
+
)
|
|
299
|
+
return sorted(results, key=lambda x: x["cvss"], reverse=True)
|
|
300
|
+
|
|
301
|
+
def get_latest_threats(self, limit: int = 10) -> List[Dict]:
|
|
302
|
+
"""Get latest critical threats"""
|
|
303
|
+
all_cves = self.list_all_cves()
|
|
304
|
+
critical = [c for c in all_cves if c["severity"] == "Critical"]
|
|
305
|
+
return critical[:limit]
|
|
306
|
+
|
|
307
|
+
def generate_vulnerability_report(self, cve_list: List[str]) -> str:
|
|
308
|
+
"""Generate a report for a list of CVEs"""
|
|
309
|
+
report_lines = [
|
|
310
|
+
"# Vulnerability Analysis Report",
|
|
311
|
+
f"Generated: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}",
|
|
312
|
+
"",
|
|
313
|
+
"## CVE Details",
|
|
314
|
+
"",
|
|
315
|
+
]
|
|
316
|
+
|
|
317
|
+
for cve_id in cve_list:
|
|
318
|
+
entry = self.search_cve(cve_id.upper())
|
|
319
|
+
if entry:
|
|
320
|
+
report_lines.extend(
|
|
321
|
+
[
|
|
322
|
+
f"### {entry.cve_id}: {entry.name}",
|
|
323
|
+
f"**Severity:** {entry.severity} (CVSS: {entry.cvss_score})",
|
|
324
|
+
f"**Description:** {entry.description}",
|
|
325
|
+
"",
|
|
326
|
+
"**Affected Products:**",
|
|
327
|
+
"",
|
|
328
|
+
]
|
|
329
|
+
)
|
|
330
|
+
for product in entry.affected_products[:5]:
|
|
331
|
+
report_lines.append(f"- {product}")
|
|
332
|
+
|
|
333
|
+
if entry.ransomware_used_by:
|
|
334
|
+
report_lines.extend(
|
|
335
|
+
["", "⚠️ **Ransomware Alert:** This CVE is used by:", ""]
|
|
336
|
+
)
|
|
337
|
+
for rw in entry.ransomware_used_by:
|
|
338
|
+
report_lines.append(f"- {rw}")
|
|
339
|
+
|
|
340
|
+
report_lines.extend(["", "**Mitigation:**", ""])
|
|
341
|
+
for mit in entry.mitigations[:3]:
|
|
342
|
+
report_lines.append(f"- {mit}")
|
|
343
|
+
|
|
344
|
+
report_lines.append("")
|
|
345
|
+
else:
|
|
346
|
+
report_lines.append(f"### {cve_id}: Not found in database\n")
|
|
347
|
+
|
|
348
|
+
return "\n".join(report_lines)
|
|
349
|
+
|
|
350
|
+
def get_mitigation_for_cve(self, cve_id: str) -> List[str]:
|
|
351
|
+
"""Get mitigation steps for a CVE"""
|
|
352
|
+
entry = self.search_cve(cve_id.upper())
|
|
353
|
+
if entry:
|
|
354
|
+
return entry.mitigations
|
|
355
|
+
return []
|
|
356
|
+
|
|
357
|
+
def get_detection_for_ransomware(self, ransomware_name: str) -> List[str]:
|
|
358
|
+
"""Get detection methods for ransomware"""
|
|
359
|
+
entry = self.search_ransomware(ransomware_name)
|
|
360
|
+
if entry:
|
|
361
|
+
return entry.detection
|
|
362
|
+
return []
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Exploit Assistance Module
|
|
4
|
+
AI-powered exploit suggestion and payload generation
|
|
5
|
+
Author: SHAdd0WTAka
|
|
6
|
+
|
|
7
|
+
FOR AUTHORIZED SECURITY TESTING ONLY
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import asyncio
|
|
11
|
+
import logging
|
|
12
|
+
from dataclasses import dataclass
|
|
13
|
+
from typing import Dict, List, Optional
|
|
14
|
+
|
|
15
|
+
logger = logging.getLogger("ZenAI")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@dataclass
|
|
19
|
+
class ExploitSuggestion:
|
|
20
|
+
name: str
|
|
21
|
+
exploit_type: str
|
|
22
|
+
description: str
|
|
23
|
+
prerequisites: List[str]
|
|
24
|
+
steps: List[str]
|
|
25
|
+
payload_example: str
|
|
26
|
+
mitigation: str
|
|
27
|
+
risk_level: str
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class ExploitAssistModule:
|
|
31
|
+
"""
|
|
32
|
+
Intelligent exploit assistance and payload generation
|
|
33
|
+
FOR AUTHORIZED TESTING ONLY
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
def __init__(self, orchestrator):
|
|
37
|
+
self.orchestrator = orchestrator
|
|
38
|
+
|
|
39
|
+
async def suggest_exploits(
|
|
40
|
+
self, vuln_name: str, service: str, version: str = ""
|
|
41
|
+
) -> List[ExploitSuggestion]:
|
|
42
|
+
"""
|
|
43
|
+
Suggest exploits for a specific vulnerability
|
|
44
|
+
"""
|
|
45
|
+
prompt = f"""
|
|
46
|
+
Suggest exploits for the following vulnerability:
|
|
47
|
+
- Vulnerability: {vuln_name}
|
|
48
|
+
- Service: {service}
|
|
49
|
+
- Version: {version or "Unknown"}
|
|
50
|
+
|
|
51
|
+
For educational and authorized penetration testing purposes only.
|
|
52
|
+
|
|
53
|
+
Provide for each exploit:
|
|
54
|
+
1. Name/Technique
|
|
55
|
+
2. Prerequisites
|
|
56
|
+
3. Step-by-step approach
|
|
57
|
+
4. Example payload (if applicable)
|
|
58
|
+
5. Detection/prevention methods
|
|
59
|
+
|
|
60
|
+
Format:
|
|
61
|
+
[EXPLOIT]
|
|
62
|
+
Name: <name>
|
|
63
|
+
Type: <type>
|
|
64
|
+
Prerequisites: <list>
|
|
65
|
+
Steps: <numbered steps>
|
|
66
|
+
Payload Example: <example>
|
|
67
|
+
Mitigation: <how to prevent>
|
|
68
|
+
Risk: <Critical/High/Medium/Low>
|
|
69
|
+
[/EXPLOIT]
|
|
70
|
+
"""
|
|
71
|
+
|
|
72
|
+
response = await self.orchestrator.process(prompt)
|
|
73
|
+
return self._parse_exploit_suggestions(response.content)
|
|
74
|
+
|
|
75
|
+
async def generate_payload(
|
|
76
|
+
self, vuln_type: str, target_info: Dict, encoding: str = "raw"
|
|
77
|
+
) -> str:
|
|
78
|
+
"""
|
|
79
|
+
Generate proof-of-concept payloads
|
|
80
|
+
"""
|
|
81
|
+
prompt = f"""
|
|
82
|
+
Generate a proof-of-concept payload for authorized security testing:
|
|
83
|
+
|
|
84
|
+
Vulnerability Type: {vuln_type}
|
|
85
|
+
Target: {target_info.get('target', 'Unknown')}
|
|
86
|
+
Context: {target_info.get('context', 'Web application')}
|
|
87
|
+
Encoding: {encoding}
|
|
88
|
+
|
|
89
|
+
Requirements:
|
|
90
|
+
- Safe for testing (non-destructive where possible)
|
|
91
|
+
- Clearly demonstrates the vulnerability
|
|
92
|
+
- Includes detection string
|
|
93
|
+
- Explain what the payload does
|
|
94
|
+
|
|
95
|
+
DO NOT generate malicious payloads for actual attacks.
|
|
96
|
+
This is for security research and authorized testing only.
|
|
97
|
+
"""
|
|
98
|
+
|
|
99
|
+
response = await self.orchestrator.process(prompt)
|
|
100
|
+
return response.content
|
|
101
|
+
|
|
102
|
+
async def craft_sql_injection_payload(
|
|
103
|
+
self, db_type: str = "mysql", technique: str = "union"
|
|
104
|
+
) -> Dict:
|
|
105
|
+
"""
|
|
106
|
+
Generate SQL injection test payloads
|
|
107
|
+
"""
|
|
108
|
+
prompt = f"""
|
|
109
|
+
Generate SQL injection proof-of-concept payloads for authorized testing:
|
|
110
|
+
|
|
111
|
+
Database: {db_type}
|
|
112
|
+
Technique: {technique}
|
|
113
|
+
|
|
114
|
+
Provide:
|
|
115
|
+
1. Basic detection payload
|
|
116
|
+
2. Database version extraction
|
|
117
|
+
3. Table enumeration payload
|
|
118
|
+
4. Safe SELECT-only data extraction
|
|
119
|
+
|
|
120
|
+
All payloads should use 'AND 1=1' or similar safe constructs that don't modify data.
|
|
121
|
+
Include comments explaining what each payload does.
|
|
122
|
+
"""
|
|
123
|
+
|
|
124
|
+
response = await self.orchestrator.process(prompt)
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
"detection": self._extract_payload(response.content, "detection"),
|
|
128
|
+
"version": self._extract_payload(response.content, "version"),
|
|
129
|
+
"tables": self._extract_payload(response.content, "tables"),
|
|
130
|
+
"full_response": response.content,
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
async def craft_xss_payload(
|
|
134
|
+
self, context: str = "html", waf: str = "none"
|
|
135
|
+
) -> List[str]:
|
|
136
|
+
"""
|
|
137
|
+
Generate XSS proof-of-concept payloads
|
|
138
|
+
"""
|
|
139
|
+
prompt = f"""
|
|
140
|
+
Generate XSS proof-of-concept payloads for authorized security testing:
|
|
141
|
+
|
|
142
|
+
Context: {context} (html, attribute, javascript, url)
|
|
143
|
+
WAF: {waf}
|
|
144
|
+
|
|
145
|
+
Requirements:
|
|
146
|
+
- Use alert(1) or console.log('XSS') for demonstration
|
|
147
|
+
- Include polyglot payloads
|
|
148
|
+
- Provide bypass techniques if WAF is specified
|
|
149
|
+
- Explain the context where each works
|
|
150
|
+
|
|
151
|
+
Payloads should be safe for testing and clearly demonstrate the vulnerability.
|
|
152
|
+
"""
|
|
153
|
+
|
|
154
|
+
response = await self.orchestrator.process(prompt)
|
|
155
|
+
|
|
156
|
+
# Extract payloads (lines that look like XSS)
|
|
157
|
+
payloads = []
|
|
158
|
+
for line in response.content.split("\n"):
|
|
159
|
+
line = line.strip()
|
|
160
|
+
if any(
|
|
161
|
+
indicator in line
|
|
162
|
+
for indicator in [
|
|
163
|
+
"<script",
|
|
164
|
+
"javascript:",
|
|
165
|
+
"onerror",
|
|
166
|
+
"onload",
|
|
167
|
+
"<img",
|
|
168
|
+
"<svg",
|
|
169
|
+
]
|
|
170
|
+
):
|
|
171
|
+
payloads.append(line)
|
|
172
|
+
|
|
173
|
+
return payloads[:10] # Limit results
|
|
174
|
+
|
|
175
|
+
async def post_exploitation(self, access_level: str, target_type: str) -> Dict:
|
|
176
|
+
"""
|
|
177
|
+
Suggest post-exploitation steps
|
|
178
|
+
"""
|
|
179
|
+
prompt = f"""
|
|
180
|
+
Suggest post-exploitation activities for authorized penetration testing:
|
|
181
|
+
|
|
182
|
+
Current Access: {access_level} (user/root/web shell)
|
|
183
|
+
Target Type: {target_type} (linux/windows/web)
|
|
184
|
+
|
|
185
|
+
Focus areas:
|
|
186
|
+
1. Privilege escalation vectors
|
|
187
|
+
2. Lateral movement possibilities
|
|
188
|
+
3. Persistence mechanisms (for testing detection)
|
|
189
|
+
4. Data exfiltration paths (document only)
|
|
190
|
+
5. Cleanup procedures
|
|
191
|
+
|
|
192
|
+
This is for improving security defenses through authorized testing.
|
|
193
|
+
Provide detection methods for each activity.
|
|
194
|
+
"""
|
|
195
|
+
|
|
196
|
+
response = await self.orchestrator.process(prompt)
|
|
197
|
+
|
|
198
|
+
return {
|
|
199
|
+
"privilege_escalation": self._extract_section(
|
|
200
|
+
response.content, "privilege"
|
|
201
|
+
),
|
|
202
|
+
"lateral_movement": self._extract_section(response.content, "lateral"),
|
|
203
|
+
"persistence": self._extract_section(response.content, "persistence"),
|
|
204
|
+
"cleanup": self._extract_section(response.content, "cleanup"),
|
|
205
|
+
"full_response": response.content,
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
async def bypass_techniques(self, security_control: str) -> List[str]:
|
|
209
|
+
"""
|
|
210
|
+
Get bypass techniques for security controls
|
|
211
|
+
"""
|
|
212
|
+
prompt = f"""
|
|
213
|
+
Suggest bypass techniques for authorized security testing:
|
|
214
|
+
|
|
215
|
+
Security Control: {security_control}
|
|
216
|
+
(WAF, Antivirus, EDR, Application Whitelist, etc.)
|
|
217
|
+
|
|
218
|
+
Provide:
|
|
219
|
+
1. Common bypass methods
|
|
220
|
+
2. Encoding/obfuscation techniques
|
|
221
|
+
3. Alternative execution methods
|
|
222
|
+
4. Detection recommendations for defenders
|
|
223
|
+
|
|
224
|
+
For red team exercises and security validation only.
|
|
225
|
+
Include how blue teams can detect these attempts.
|
|
226
|
+
"""
|
|
227
|
+
|
|
228
|
+
response = await self.orchestrator.process(prompt)
|
|
229
|
+
|
|
230
|
+
# Parse techniques
|
|
231
|
+
techniques = []
|
|
232
|
+
for line in response.content.split("\n"):
|
|
233
|
+
line = line.strip()
|
|
234
|
+
if line and (
|
|
235
|
+
line[0].isdigit() or line.startswith("-") or line.startswith("*")
|
|
236
|
+
):
|
|
237
|
+
techniques.append(line.lstrip("- *").strip())
|
|
238
|
+
|
|
239
|
+
return techniques[:15]
|
|
240
|
+
|
|
241
|
+
def _parse_exploit_suggestions(self, content: str) -> List[ExploitSuggestion]:
|
|
242
|
+
"""Parse exploit blocks from response"""
|
|
243
|
+
suggestions = []
|
|
244
|
+
|
|
245
|
+
# Split by [EXPLOIT] blocks
|
|
246
|
+
import re
|
|
247
|
+
|
|
248
|
+
blocks = re.findall(r"\[EXPLOIT\](.*?)\[/EXPLOIT\]", content, re.DOTALL)
|
|
249
|
+
|
|
250
|
+
if not blocks:
|
|
251
|
+
# Try alternative parsing
|
|
252
|
+
sections = content.split("\n\n")
|
|
253
|
+
for section in sections:
|
|
254
|
+
if "prerequisites" in section.lower() or "steps" in section.lower():
|
|
255
|
+
suggestions.append(self._create_exploit_from_text(section))
|
|
256
|
+
else:
|
|
257
|
+
for block in blocks:
|
|
258
|
+
suggestions.append(self._create_exploit_from_text(block))
|
|
259
|
+
|
|
260
|
+
return suggestions
|
|
261
|
+
|
|
262
|
+
def _create_exploit_from_text(self, text: str) -> ExploitSuggestion:
|
|
263
|
+
"""Create ExploitSuggestion from text"""
|
|
264
|
+
import re
|
|
265
|
+
|
|
266
|
+
name_match = re.search(r"Name:\s*(.+?)(?:\n|$)", text, re.IGNORECASE)
|
|
267
|
+
type_match = re.search(r"Type:\s*(.+?)(?:\n|$)", text, re.IGNORECASE)
|
|
268
|
+
risk_match = re.search(r"Risk:\s*(\w+)", text, re.IGNORECASE)
|
|
269
|
+
|
|
270
|
+
# Extract lists
|
|
271
|
+
prereqs = re.findall(
|
|
272
|
+
r"[\*\-]\s*(.+?)(?:\n|$)",
|
|
273
|
+
(
|
|
274
|
+
re.search(
|
|
275
|
+
r"Prerequisites:(.+?)(?:Steps|Payload|Mitigation|$)",
|
|
276
|
+
text,
|
|
277
|
+
re.DOTALL | re.IGNORECASE,
|
|
278
|
+
).group(1)
|
|
279
|
+
if re.search(
|
|
280
|
+
r"Prerequisites:(.+?)(?:Steps|Payload|Mitigation|$)",
|
|
281
|
+
text,
|
|
282
|
+
re.DOTALL | re.IGNORECASE,
|
|
283
|
+
)
|
|
284
|
+
else ""
|
|
285
|
+
),
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
steps = re.findall(r"\d+\.\s*(.+?)(?:\n|$)", text)
|
|
289
|
+
|
|
290
|
+
payload_match = re.search(
|
|
291
|
+
r"Payload\s*(?:Example)?:\s*(.+?)(?:\n\w+:|$)",
|
|
292
|
+
text,
|
|
293
|
+
re.DOTALL | re.IGNORECASE,
|
|
294
|
+
)
|
|
295
|
+
mitigation_match = re.search(
|
|
296
|
+
r"Mitigation:\s*(.+?)(?:\n\w+:|$)", text, re.DOTALL | re.IGNORECASE
|
|
297
|
+
)
|
|
298
|
+
|
|
299
|
+
return ExploitSuggestion(
|
|
300
|
+
name=name_match.group(1).strip() if name_match else "Unknown",
|
|
301
|
+
exploit_type=type_match.group(1).strip() if type_match else "Unknown",
|
|
302
|
+
description=text[:200],
|
|
303
|
+
prerequisites=prereqs if prereqs else ["Unknown"],
|
|
304
|
+
steps=steps if steps else ["See description"],
|
|
305
|
+
payload_example=(
|
|
306
|
+
payload_match.group(1).strip()[:500] if payload_match else "N/A"
|
|
307
|
+
),
|
|
308
|
+
mitigation=(
|
|
309
|
+
mitigation_match.group(1).strip()[:300]
|
|
310
|
+
if mitigation_match
|
|
311
|
+
else "Review security controls"
|
|
312
|
+
),
|
|
313
|
+
risk_level=risk_match.group(1).capitalize() if risk_match else "Medium",
|
|
314
|
+
)
|
|
315
|
+
|
|
316
|
+
def _extract_payload(self, content: str, payload_type: str) -> str:
|
|
317
|
+
"""Extract specific payload from content"""
|
|
318
|
+
import re
|
|
319
|
+
|
|
320
|
+
pattern = rf"{payload_type}[:\s]+(.+?)(?:\n\n|\n[A-Z]|$)"
|
|
321
|
+
match = re.search(pattern, content, re.IGNORECASE | re.DOTALL)
|
|
322
|
+
return match.group(1).strip()[:500] if match else "Not found"
|
|
323
|
+
|
|
324
|
+
def _extract_section(self, content: str, section_name: str) -> str:
|
|
325
|
+
"""Extract a section from content"""
|
|
326
|
+
import re
|
|
327
|
+
|
|
328
|
+
pattern = rf"{section_name}[\s\w]*[:\s]+(.+?)(?:\n\n[A-Z]|\n\d+\.|$)"
|
|
329
|
+
match = re.search(pattern, content, re.IGNORECASE | re.DOTALL)
|
|
330
|
+
return match.group(1).strip()[:500] if match else ""
|