zen-ai-pentest 2.1.0__py3-none-any.whl → 2.2.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.
api/main.py CHANGED
@@ -60,7 +60,7 @@ async def lifespan(app: FastAPI):
60
60
  app = FastAPI(
61
61
  title="Zen-AI-Pentest API",
62
62
  description="Professional Pentesting Framework API",
63
- version="2.1.0",
63
+ version="2.2.0",
64
64
  lifespan=lifespan
65
65
  )
66
66
 
@@ -500,7 +500,7 @@ async def health_check():
500
500
  """Health check endpoint"""
501
501
  return {
502
502
  "status": "healthy",
503
- "version": "2.1.0",
503
+ "version": "2.2.0",
504
504
  "timestamp": datetime.utcnow().isoformat()
505
505
  }
506
506
 
api/websocket_v2.py ADDED
@@ -0,0 +1,181 @@
1
+ """
2
+ WebSocket v2.0 - Real-time Updates
3
+ Q2 2026 Feature
4
+ """
5
+
6
+ import json
7
+ import logging
8
+ from typing import Dict, Set
9
+ from fastapi import WebSocket, WebSocketDisconnect
10
+ from datetime import datetime
11
+
12
+ logger = logging.getLogger(__name__)
13
+
14
+
15
+ class ConnectionManagerV2:
16
+ """Advanced WebSocket connection manager with rooms"""
17
+
18
+ def __init__(self):
19
+ # Active connections by room
20
+ self.rooms: Dict[str, Set[WebSocket]] = {
21
+ "dashboard": set(),
22
+ "scans": set(),
23
+ "findings": set(),
24
+ "notifications": set()
25
+ }
26
+ # User connections
27
+ self.user_connections: Dict[str, WebSocket] = {}
28
+
29
+ async def connect(self, websocket: WebSocket, room: str = "dashboard", user_id: str = None):
30
+ """Connect client to room"""
31
+ await websocket.accept()
32
+
33
+ if room in self.rooms:
34
+ self.rooms[room].add(websocket)
35
+
36
+ if user_id:
37
+ self.user_connections[user_id] = websocket
38
+
39
+ logger.info(f"Client connected to room: {room}")
40
+
41
+ # Send welcome message
42
+ await websocket.send_json({
43
+ "type": "connection",
44
+ "status": "connected",
45
+ "room": room,
46
+ "timestamp": datetime.utcnow().isoformat()
47
+ })
48
+
49
+ def disconnect(self, websocket: WebSocket, room: str = None):
50
+ """Disconnect client"""
51
+ if room and room in self.rooms:
52
+ self.rooms[room].discard(websocket)
53
+ else:
54
+ # Remove from all rooms
55
+ for room_set in self.rooms.values():
56
+ room_set.discard(websocket)
57
+
58
+ # Remove from user connections
59
+ for user_id, conn in list(self.user_connections.items()):
60
+ if conn == websocket:
61
+ del self.user_connections[user_id]
62
+
63
+ logger.info("Client disconnected")
64
+
65
+ async def broadcast_to_room(self, room: str, message: dict):
66
+ """Broadcast message to all clients in room"""
67
+ if room not in self.rooms:
68
+ return
69
+
70
+ disconnected = set()
71
+ for connection in self.rooms[room]:
72
+ try:
73
+ await connection.send_json(message)
74
+ except Exception:
75
+ disconnected.add(connection)
76
+
77
+ # Clean up disconnected clients
78
+ for conn in disconnected:
79
+ self.rooms[room].discard(conn)
80
+
81
+ async def send_to_user(self, user_id: str, message: dict):
82
+ """Send message to specific user"""
83
+ if user_id in self.user_connections:
84
+ try:
85
+ await self.user_connections[user_id].send_json(message)
86
+ except Exception:
87
+ del self.user_connections[user_id]
88
+
89
+ async def broadcast_scan_update(self, scan_id: str, status: str, progress: int = None):
90
+ """Broadcast scan progress update"""
91
+ await self.broadcast_to_room("scans", {
92
+ "type": "scan_update",
93
+ "scan_id": scan_id,
94
+ "status": status,
95
+ "progress": progress,
96
+ "timestamp": datetime.utcnow().isoformat()
97
+ })
98
+
99
+ async def broadcast_finding(self, finding: dict):
100
+ """Broadcast new finding discovery"""
101
+ await self.broadcast_to_room("findings", {
102
+ "type": "new_finding",
103
+ "finding": finding,
104
+ "timestamp": datetime.utcnow().isoformat()
105
+ })
106
+
107
+ async def broadcast_notification(self, title: str, message: str, severity: str = "info"):
108
+ """Broadcast system notification"""
109
+ await self.broadcast_to_room("notifications", {
110
+ "type": "notification",
111
+ "title": title,
112
+ "message": message,
113
+ "severity": severity,
114
+ "timestamp": datetime.utcnow().isoformat()
115
+ })
116
+
117
+ def get_room_stats(self) -> dict:
118
+ """Get connection statistics"""
119
+ return {
120
+ room: len(connections)
121
+ for room, connections in self.rooms.items()
122
+ }
123
+
124
+
125
+ # Global manager instance
126
+ manager_v2 = ConnectionManagerV2()
127
+
128
+
129
+ async def websocket_dashboard_endpoint(websocket: WebSocket):
130
+ """Dashboard real-time updates"""
131
+ await manager_v2.connect(websocket, room="dashboard")
132
+ try:
133
+ while True:
134
+ # Receive ping from client
135
+ data = await websocket.receive_text()
136
+ message = json.loads(data)
137
+
138
+ if message.get("action") == "ping":
139
+ await websocket.send_json({
140
+ "type": "pong",
141
+ "timestamp": datetime.utcnow().isoformat()
142
+ })
143
+
144
+ except WebSocketDisconnect:
145
+ manager_v2.disconnect(websocket, room="dashboard")
146
+
147
+
148
+ async def websocket_scans_endpoint(websocket: WebSocket):
149
+ """Scan progress real-time updates"""
150
+ await manager_v2.connect(websocket, room="scans")
151
+ try:
152
+ while True:
153
+ data = await websocket.receive_text()
154
+ # Handle scan subscription requests
155
+ message = json.loads(data)
156
+
157
+ if message.get("action") == "subscribe_scan":
158
+ scan_id = message.get("scan_id")
159
+ await websocket.send_json({
160
+ "type": "subscribed",
161
+ "scan_id": scan_id,
162
+ "message": f"Subscribed to scan {scan_id} updates"
163
+ })
164
+
165
+ except WebSocketDisconnect:
166
+ manager_v2.disconnect(websocket, room="scans")
167
+
168
+
169
+ async def websocket_notifications_endpoint(websocket: WebSocket, user_id: str = None):
170
+ """User-specific notifications"""
171
+ await manager_v2.connect(websocket, room="notifications", user_id=user_id)
172
+ try:
173
+ while True:
174
+ data = await websocket.receive_text()
175
+ # Acknowledge receipt
176
+ await websocket.send_json({
177
+ "type": "ack",
178
+ "received": True
179
+ })
180
+ except WebSocketDisconnect:
181
+ manager_v2.disconnect(websocket, room="notifications")
@@ -0,0 +1,207 @@
1
+ """
2
+ Report Export Module
3
+ Q2 2026 - PDF & CSV Export
4
+ """
5
+
6
+ import csv
7
+ import io
8
+ import logging
9
+ from datetime import datetime
10
+ from typing import List, Dict, Any
11
+ from dataclasses import dataclass
12
+
13
+ try:
14
+ from weasyprint import HTML, CSS
15
+ WEASYPRINT_AVAILABLE = True
16
+ except ImportError:
17
+ WEASYPRINT_AVAILABLE = False
18
+
19
+ logger = logging.getLogger(__name__)
20
+
21
+
22
+ @dataclass
23
+ class ReportData:
24
+ """Report data structure"""
25
+ title: str
26
+ scan_date: datetime
27
+ target: str
28
+ findings: List[Dict[str, Any]]
29
+ summary: Dict[str, int]
30
+ recommendations: List[str]
31
+
32
+
33
+ class ReportExporter:
34
+ """Export reports to various formats"""
35
+
36
+ def __init__(self):
37
+ self.templates = {
38
+ "executive": self._executive_template,
39
+ "technical": self._technical_template,
40
+ "compliance": self._compliance_template
41
+ }
42
+
43
+ def export_csv(self, findings: List[Dict], filename: str = None) -> bytes:
44
+ """Export findings to CSV"""
45
+ if not filename:
46
+ filename = f"findings_{datetime.now().strftime('%Y%m%d_%H%M%S')}.csv"
47
+
48
+ output = io.StringIO()
49
+ writer = csv.writer(output)
50
+
51
+ # Header
52
+ writer.writerow([
53
+ "ID", "Severity", "Title", "Description", "Target",
54
+ "CVE", "CVSS", "Status", "Discovered"
55
+ ])
56
+
57
+ # Data
58
+ for finding in findings:
59
+ writer.writerow([
60
+ finding.get("id", ""),
61
+ finding.get("severity", ""),
62
+ finding.get("title", ""),
63
+ finding.get("description", ""),
64
+ finding.get("target", ""),
65
+ finding.get("cve_id", ""),
66
+ finding.get("cvss_score", ""),
67
+ finding.get("status", "open"),
68
+ finding.get("discovered_at", "")
69
+ ])
70
+
71
+ return output.getvalue().encode('utf-8')
72
+
73
+ def export_pdf(self, report: ReportData, template: str = "executive") -> bytes:
74
+ """Export report to PDF"""
75
+ if not WEASYPRINT_AVAILABLE:
76
+ logger.error("WeasyPrint not available. Install: pip install weasyprint")
77
+ raise RuntimeError("PDF generation requires WeasyPrint")
78
+
79
+ html_content = self.templates.get(template, self._executive_template)(report)
80
+
81
+ pdf = HTML(string=html_content).write_pdf()
82
+ return pdf
83
+
84
+ def _executive_template(self, report: ReportData) -> str:
85
+ """Executive summary template"""
86
+ findings_html = ""
87
+ for f in report.findings[:10]: # Top 10
88
+ severity_color = {
89
+ "critical": "#dc2626",
90
+ "high": "#ea580c",
91
+ "medium": "#ca8a04",
92
+ "low": "#16a34a"
93
+ }.get(f.get("severity", "low"), "#6b7280")
94
+
95
+ findings_html += f"""
96
+ <div style="margin: 10px 0; padding: 10px; border-left: 4px solid {severity_color}; background: #f9fafb;">
97
+ <strong>{f.get('title', 'Unknown')}</strong>
98
+ <span style="color: {severity_color}; text-transform: uppercase; font-size: 0.8em;">
99
+ {f.get('severity', 'unknown')}
100
+ </span>
101
+ <p style="margin: 5px 0; color: #4b5563;">{f.get('description', '')[:200]}...</p>
102
+ </div>
103
+ """
104
+
105
+ return f"""
106
+ <!DOCTYPE html>
107
+ <html>
108
+ <head>
109
+ <meta charset="UTF-8">
110
+ <title>{report.title}</title>
111
+ <style>
112
+ body {{ font-family: Arial, sans-serif; margin: 40px; }}
113
+ h1 {{ color: #111827; border-bottom: 2px solid #059669; padding-bottom: 10px; }}
114
+ .summary {{ background: #f3f4f6; padding: 20px; border-radius: 8px; margin: 20px 0; }}
115
+ .metric {{ display: inline-block; margin: 10px 20px; }}
116
+ .metric-value {{ font-size: 2em; font-weight: bold; color: #059669; }}
117
+ .metric-label {{ color: #6b7280; font-size: 0.9em; }}
118
+ .findings {{ margin-top: 30px; }}
119
+ </style>
120
+ </head>
121
+ <body>
122
+ <h1>{report.title}</h1>
123
+ <p><strong>Target:</strong> {report.target}</p>
124
+ <p><strong>Scan Date:</strong> {report.scan_date.strftime('%Y-%m-%d %H:%M')}</p>
125
+
126
+ <div class="summary">
127
+ <h2>Summary</h2>
128
+ <div class="metric">
129
+ <div class="metric-value">{report.summary.get('critical', 0)}</div>
130
+ <div class="metric-label">Critical</div>
131
+ </div>
132
+ <div class="metric">
133
+ <div class="metric-value">{report.summary.get('high', 0)}</div>
134
+ <div class="metric-label">High</div>
135
+ </div>
136
+ <div class="metric">
137
+ <div class="metric-value">{report.summary.get('medium', 0)}</div>
138
+ <div class="metric-label">Medium</div>
139
+ </div>
140
+ <div class="metric">
141
+ <div class="metric-value">{report.summary.get('low', 0)}</div>
142
+ <div class="metric-label">Low</div>
143
+ </div>
144
+ </div>
145
+
146
+ <div class="findings">
147
+ <h2>Top Findings</h2>
148
+ {findings_html}
149
+ </div>
150
+
151
+ <div style="margin-top: 40px; padding-top: 20px; border-top: 1px solid #e5e7eb; color: #6b7280; font-size: 0.9em;">
152
+ <p>Generated by Zen AI Pentest v2.1.0</p>
153
+ <p>Confidential - For authorized eyes only</p>
154
+ </div>
155
+ </body>
156
+ </html>
157
+ """
158
+
159
+ def _technical_template(self, report: ReportData) -> str:
160
+ """Technical detailed template"""
161
+ # Similar to executive but with more technical details
162
+ return self._executive_template(report) # Simplified for now
163
+
164
+ def _compliance_template(self, report: ReportData) -> str:
165
+ """Compliance-focused template"""
166
+ # For compliance reporting (PCI-DSS, GDPR, etc.)
167
+ return self._executive_template(report) # Simplified for now
168
+
169
+ def export_json(self, findings: List[Dict]) -> str:
170
+ """Export findings to JSON"""
171
+ import json
172
+ return json.dumps(findings, indent=2)
173
+
174
+ def get_export_formats(self) -> List[str]:
175
+ """List available export formats"""
176
+ formats = ["csv", "json"]
177
+ if WEASYPRINT_AVAILABLE:
178
+ formats.append("pdf")
179
+ return formats
180
+
181
+
182
+ # Convenience function
183
+ def export_findings(findings: List[Dict], format: str = "csv") -> bytes:
184
+ """Quick export function"""
185
+ exporter = ReportExporter()
186
+
187
+ if format == "csv":
188
+ return exporter.export_csv(findings)
189
+ elif format == "json":
190
+ return exporter.export_json(findings).encode('utf-8')
191
+ elif format == "pdf":
192
+ report = ReportData(
193
+ title="Security Assessment Report",
194
+ scan_date=datetime.now(),
195
+ target="Multiple Targets",
196
+ findings=findings,
197
+ summary={
198
+ "critical": len([f for f in findings if f.get("severity") == "critical"]),
199
+ "high": len([f for f in findings if f.get("severity") == "high"]),
200
+ "medium": len([f for f in findings if f.get("severity") == "medium"]),
201
+ "low": len([f for f in findings if f.get("severity") == "low"])
202
+ },
203
+ recommendations=[]
204
+ )
205
+ return exporter.export_pdf(report)
206
+ else:
207
+ raise ValueError(f"Unsupported format: {format}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zen-ai-pentest
3
- Version: 2.1.0
3
+ Version: 2.2.0
4
4
  Summary: Advanced AI-Powered Penetration Testing Framework with Multi-Agent Orchestration
5
5
  Home-page: https://github.com/SHAdd0WTAka/zen-ai-pentest
6
6
  Author: SHAdd0WTAka
@@ -12,9 +12,10 @@ agents/react_agent_vm.py,sha256=DF_TMWG_AfWbtvw9s4TB1MAwkFLMRaWpKw2UcM7Pa5U,1112
12
12
  agents/research_agent.py,sha256=f_OjmEvgQX1mUdLRlsj3-QMyB1m5J0oHIsTvFkcRijc,6394
13
13
  api/__init__.py,sha256=HQ2cFR8t_PlbtgLzir7P1Umzh-syS5iEfCNZky5uL_Y,256
14
14
  api/auth.py,sha256=ZqIvj0L0BTAFsytjCznGF53i1kz6DOunhLxd0mPUykA,3934
15
- api/main.py,sha256=0sy31LpFZh6SvvGV1qwWV91QLbXMTuZz4o2CnjpWjf0,32801
15
+ api/main.py,sha256=ZeU_ZQVNl9JD73S-L2wWt37n02SRkWzf2eLcGYTqB8k,32801
16
16
  api/schemas.py,sha256=nnE-97OOOWpAAenD_sCsCpcLy-SpWW1g2WW902mbihY,10306
17
17
  api/websocket.py,sha256=DTDKr48g6RBNCBX6LM1WljR1FLTkoYB-BTm1TtMNaOY,3602
18
+ api/websocket_v2.py,sha256=fVFlDhJc4iq95BBy7UdkdeQdv2QgSCbCmYGLzqL9DfM,6019
18
19
  autonomous/__init__.py,sha256=Gv83jnjasidFfyD6ggCXjJlqjn6YwANLi_b0-kpBSok,2858
19
20
  autonomous/agent.py,sha256=LG937JGTdiywhjDr9wCxuYaysgL7dRMbPguYWTnjrt0,8021
20
21
  autonomous/agent_loop.py,sha256=a_WvxaKgImXyMdddXmdoJCANVbjmWz-FBiptHJn2608,47216
@@ -54,6 +55,7 @@ modules/nuclei_integration.py,sha256=2pvFCcTpEpC6M6YV2QWoHBxpKYswoYnD7dX4GJTQnX4
54
55
  modules/osint.py,sha256=SZG1rfMQ-zPIasYtKRzFlsjXR3wDSrVLRUtg6extUok,20600
55
56
  modules/protonvpn.py,sha256=4G-tLL3JyjJm-ryQIt4-hQTX4eKX_OTZnKFkZaK_F8Q,18133
56
57
  modules/recon.py,sha256=utS-wfdRBS7XaGtr1mcpMuetyJcCi2B8LZrAmVJjhcM,5002
58
+ modules/report_export.py,sha256=PKZNWrwK_x0XFpSjDzoI3-BoXYBnZ5VyQJ1V-nyhVj8,7622
57
59
  modules/siem_integration.py,sha256=GbG8sbyziItdQhRArNku7pV6yZW8jR9AQgUxU2dvJ98,18594
58
60
  modules/sql_injection_db.py,sha256=x9VVIaXkykXo0zFmcPqIMk9gh_CF-Lrs9Ht2hrb9DLk,28945
59
61
  modules/tool_orchestrator.py,sha256=6FwR-EMR-HIrLFFimWf5MUMf_AYIYPUuZPaL8oTUNVU,15868
@@ -68,9 +70,9 @@ risk_engine/example_usage.py,sha256=eM54wLDy3eZtiDGjOSZ4YrsCcEUzfVKjV_A_Pkn07is,
68
70
  risk_engine/false_positive_engine.py,sha256=8u0wI3W25fsEq9eXfskUtcHfV3D2V6ElzVSgY_TAA-c,37961
69
71
  risk_engine/scorer.py,sha256=BklUfMo26IaOYOJse-mjvY8NwjpbI4UEIlqZ6MhCmwU,10282
70
72
  web_ui/backend/main.py,sha256=DTVmsvbDH7EvMmeohbcl8vYyKPyaLU8oHMvwWAqAF8k,15402
71
- zen_ai_pentest-2.1.0.dist-info/licenses/LICENSE,sha256=C1sNTmgBbFuCm9vPCctuz6pQr4khkgqoQEMUE6cP-FY,1068
72
- zen_ai_pentest-2.1.0.dist-info/METADATA,sha256=oq5UetxEhLY1rzImAO6AQvHxrEtu3T2PJDlS6lR6Qkw,30802
73
- zen_ai_pentest-2.1.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
74
- zen_ai_pentest-2.1.0.dist-info/entry_points.txt,sha256=qZRuz7yjZdEMiUrfflMiGzMUHUZWasT49-HNE-EKmTE,55
75
- zen_ai_pentest-2.1.0.dist-info/top_level.txt,sha256=ExWeAuK-0xRpcWS7QsL8LEdPVJy1-Z-83qwOJ1-CERA,80
76
- zen_ai_pentest-2.1.0.dist-info/RECORD,,
73
+ zen_ai_pentest-2.2.0.dist-info/licenses/LICENSE,sha256=C1sNTmgBbFuCm9vPCctuz6pQr4khkgqoQEMUE6cP-FY,1068
74
+ zen_ai_pentest-2.2.0.dist-info/METADATA,sha256=i4AXbZaIOQ3ewhiNCQ4vgMblexzd6qs3uuJlFhiiCVE,30802
75
+ zen_ai_pentest-2.2.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
76
+ zen_ai_pentest-2.2.0.dist-info/entry_points.txt,sha256=qZRuz7yjZdEMiUrfflMiGzMUHUZWasT49-HNE-EKmTE,55
77
+ zen_ai_pentest-2.2.0.dist-info/top_level.txt,sha256=ExWeAuK-0xRpcWS7QsL8LEdPVJy1-Z-83qwOJ1-CERA,80
78
+ zen_ai_pentest-2.2.0.dist-info/RECORD,,