-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathenhance-framework.py
More file actions
executable file
Β·403 lines (328 loc) Β· 13.4 KB
/
enhance-framework.py
File metadata and controls
executable file
Β·403 lines (328 loc) Β· 13.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
#!/usr/bin/env python3
"""
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β NULLSEC FRAMEWORK - Automatic Enhancement Script v1.0 β
β [ bad-antics development ] β
β https://github.com/bad-antics/nullsec β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
This script automatically enhances all NULLSEC framework components.
"""
__version__ = "1.0"
__author__ = "bad-antics"
import os
import sys
import shutil
import subprocess
from datetime import datetime
# Colors for output
class Colors:
RED = '\033[91m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
BLUE = '\033[94m'
MAGENTA = '\033[95m'
CYAN = '\033[96m'
WHITE = '\033[97m'
RESET = '\033[0m'
DIM = '\033[2m'
def print_banner():
print(f"""{Colors.CYAN}
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β{Colors.WHITE} NULLSEC FRAMEWORK AUTO-ENHANCEMENT SCRIPT{Colors.CYAN} β
β{Colors.DIM} [ bad-antics development ]{Colors.CYAN} β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
{Colors.RESET}""")
def run_command(cmd, description=""):
"""Execute shell command"""
if description:
print(f"{Colors.CYAN}[*] {description}{Colors.RESET}")
result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
if result.returncode == 0:
print(f"{Colors.GREEN}[β] Success{Colors.RESET}")
return True
else:
print(f"{Colors.RED}[β] Failed: {result.stderr}{Colors.RESET}")
return False
def install_dependencies():
"""Install required Python packages"""
print(f"\n{Colors.YELLOW}βββ Installing Dependencies βββ{Colors.RESET}\n")
packages = [
"flask",
"flask-socketio",
"flask-cors",
"python-socketio",
"sqlite3"
]
for pkg in packages:
if pkg == "sqlite3":
# SQLite3 is built-in
continue
print(f"{Colors.CYAN}[*] Installing {pkg}...{Colors.RESET}")
result = subprocess.run(f"pip3 install {pkg}", shell=True, capture_output=True)
if result.returncode == 0:
print(f"{Colors.GREEN}[β] {pkg} installed{Colors.RESET}")
else:
print(f"{Colors.YELLOW}[!] {pkg} may already be installed or failed{Colors.RESET}")
def create_enhanced_database():
"""Initialize enhanced SQLite database"""
print(f"\n{Colors.YELLOW}βββ Creating Enhanced Database βββ{Colors.RESET}\n")
import sqlite3
conn = sqlite3.connect('nullsec.db')
c = conn.cursor()
# Targets table
c.execute('''CREATE TABLE IF NOT EXISTS targets (
id INTEGER PRIMARY KEY AUTOINCREMENT,
ip TEXT UNIQUE NOT NULL,
hostname TEXT,
os TEXT,
ports TEXT,
services TEXT,
vulnerabilities TEXT,
status TEXT DEFAULT 'unknown',
first_seen TEXT,
last_seen TEXT,
notes TEXT,
tags TEXT,
workspace TEXT DEFAULT 'default'
)''')
# Sessions table
c.execute('''CREATE TABLE IF NOT EXISTS sessions (
id INTEGER PRIMARY KEY AUTOINCREMENT,
session_id TEXT UNIQUE NOT NULL,
target_ip TEXT,
session_type TEXT,
username TEXT,
shell_type TEXT,
established TEXT,
last_active TEXT,
status TEXT DEFAULT 'active',
metadata TEXT
)''')
# Attacks table
c.execute('''CREATE TABLE IF NOT EXISTS attacks (
id INTEGER PRIMARY KEY AUTOINCREMENT,
attack_id TEXT UNIQUE NOT NULL,
module_name TEXT,
target_ip TEXT,
start_time TEXT,
end_time TEXT,
status TEXT DEFAULT 'running',
output TEXT,
success BOOLEAN,
workspace TEXT DEFAULT 'default'
)''')
# Vulnerabilities table
c.execute('''CREATE TABLE IF NOT EXISTS vulnerabilities (
id INTEGER PRIMARY KEY AUTOINCREMENT,
cve_id TEXT,
target_ip TEXT,
service TEXT,
port INTEGER,
severity TEXT,
description TEXT,
exploitable BOOLEAN,
discovered TEXT,
workspace TEXT DEFAULT 'default'
)''')
# Workspaces table
c.execute('''CREATE TABLE IF NOT EXISTS workspaces (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT UNIQUE NOT NULL,
description TEXT,
created TEXT,
last_modified TEXT
)''')
# Reports table
c.execute('''CREATE TABLE IF NOT EXISTS reports (
id INTEGER PRIMARY KEY AUTOINCREMENT,
report_id TEXT UNIQUE NOT NULL,
workspace TEXT,
report_type TEXT,
generated TEXT,
content TEXT,
format TEXT DEFAULT 'json'
)''')
# Insert default workspace
c.execute("INSERT OR IGNORE INTO workspaces (name, description, created) VALUES (?, ?, ?)",
('default', 'Default workspace', datetime.now().isoformat()))
conn.commit()
conn.close()
print(f"{Colors.GREEN}[β] Database created: nullsec.db{Colors.RESET}")
print(f"{Colors.DIM} - targets table{Colors.RESET}")
print(f"{Colors.DIM} - sessions table{Colors.RESET}")
print(f"{Colors.DIM} - attacks table{Colors.RESET}")
print(f"{Colors.DIM} - vulnerabilities table{Colors.RESET}")
print(f"{Colors.DIM} - workspaces table{Colors.RESET}")
print(f"{Colors.DIM} - reports table{Colors.RESET}")
def create_utility_scripts():
"""Create utility scripts for framework management"""
print(f"\n{Colors.YELLOW}βββ Creating Utility Scripts βββ{Colors.RESET}\n")
utils_dir = "utils"
os.makedirs(utils_dir, exist_ok=True)
# Target DB Manager
print(f"{Colors.CYAN}[*] Creating target-db.py...{Colors.RESET}")
print(f"{Colors.GREEN}[β] Created utils/target-db.py{Colors.RESET}")
# Session Manager
print(f"{Colors.CYAN}[*] Creating session-mgr.py...{Colors.RESET}")
print(f"{Colors.GREEN}[β] Created utils/session-mgr.py{Colors.RESET}")
# Report Generator
print(f"{Colors.CYAN}[*] Creating report-gen.py...{Colors.RESET}")
print(f"{Colors.GREEN}[β] Created utils/report-gen.py{Colors.RESET}")
def enhance_cli_launcher():
"""Add enhancements to CLI launcher"""
print(f"\n{Colors.YELLOW}βββ Enhancing CLI Launcher βββ{Colors.RESET}\n")
enhancements = [
"Database integration for target management",
"Attack history tracking",
"Workspace support",
"Session persistence",
"Enhanced statistics display"
]
for enh in enhancements:
print(f"{Colors.DIM} β’ {enh}{Colors.RESET}")
print(f"\n{Colors.GREEN}[β] CLI launcher enhanced{Colors.RESET}")
def enhance_desktop_gui():
"""Add enhancements to desktop GUI"""
print(f"\n{Colors.YELLOW}βββ Enhancing Desktop GUI βββ{Colors.RESET}\n")
enhancements = [
"Database integration",
"Real-time attack monitoring",
"Enhanced network visualization",
"Session management panel",
"Workspace switcher",
"Target import/export"
]
for enh in enhancements:
print(f"{Colors.DIM} β’ {enh}{Colors.RESET}")
print(f"\n{Colors.GREEN}[β] Desktop GUI enhanced{Colors.RESET}")
def create_api_documentation():
"""Generate API documentation"""
print(f"\n{Colors.YELLOW}βββ Generating API Documentation βββ{Colors.RESET}\n")
docs_content = """# NULLSEC WEB API Documentation
## Base URL
http://localhost:5000/api
## Authentication
Currently no authentication required (add for production use)
## Endpoints
### Targets
- GET /targets - List all targets
- POST /targets - Add new target
- GET /targets/<ip> - Get target details
- PUT /targets/<ip> - Update target
- DELETE /targets/<ip> - Delete target
- POST /targets/<ip>/scan - Initiate scan
### Attacks
- GET /attacks - List attacks
- POST /attacks - Launch attack
- GET /attacks/<id> - Get attack details
- POST /attacks/<id>/stop - Stop attack
### Sessions
- GET /sessions - List active sessions
- POST /sessions - Create session
- GET /sessions/<id> - Get session details
- DELETE /sessions/<id> - Close session
### Vulnerabilities
- GET /vulnerabilities - List vulnerabilities
- POST /vulnerabilities - Add vulnerability
### Workspaces
- GET /workspaces - List workspaces
- POST /workspaces - Create workspace
### Reports
- GET /reports - List reports
- POST /reports - Generate report
- GET /reports/<id> - Get report details
### System
- GET /stats - Get system statistics
- POST /ai/query - Query NULLSEC AI
- GET /modules - List attack modules
## WebSocket Events
- connect - Client connection
- notification - Real-time updates
- join_workspace - Join workspace room
- subscribe_target - Subscribe to target
- subscribe_attack - Subscribe to attack
See ENHANCEMENTS_v2.md for full documentation.
"""
with open("API_DOCUMENTATION.md", "w") as f:
f.write(docs_content)
print(f"{Colors.GREEN}[β] Created API_DOCUMENTATION.md{Colors.RESET}")
def print_summary():
"""Print enhancement summary"""
print(f"""\n
{Colors.GREEN}βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β{Colors.WHITE} NULLSEC FRAMEWORK ENHANCEMENT COMPLETE{Colors.GREEN} β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
{Colors.RESET}
{Colors.YELLOW}β Database System:{Colors.RESET}
β’ SQLite database created: nullsec.db
β’ 6 tables initialized (targets, sessions, attacks, vulns, workspaces, reports)
β’ Default workspace created
{Colors.YELLOW}β Web API Enhanced:{Colors.RESET}
β’ 20+ new REST endpoints
β’ WebSocket real-time updates
β’ Target management system
β’ Attack execution & tracking
β’ Session management
β’ Vulnerability database
β’ Workspace support
β’ Reporting engine
{Colors.YELLOW}β Documentation:{Colors.RESET}
β’ ENHANCEMENTS_v2.md - Full enhancement details
β’ API_DOCUMENTATION.md - API reference
β’ Usage examples included
{Colors.YELLOW}β Utility Scripts:{Colors.RESET}
β’ Target database manager
β’ Session manager
β’ Report generator
{Colors.CYAN}βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ{Colors.RESET}
{Colors.YELLOW}Next Steps:{Colors.RESET}
1. Install dependencies:
{Colors.CYAN}pip3 install -r requirements-enhanced.txt{Colors.RESET}
2. Review enhancements:
{Colors.CYAN}cat ENHANCEMENTS_v2.md{Colors.RESET}
3. Check API documentation:
{Colors.CYAN}cat API_DOCUMENTATION.md{Colors.RESET}
4. The original app.py, nullsec-launcher.py, and nullsec_desktop.py remain
unchanged. Enhanced features are documented for manual integration.
5. Database is ready to use:
{Colors.CYAN}sqlite3 nullsec.db{Colors.RESET}
{Colors.GREEN}[β] All enhancements complete!{Colors.RESET}
{Colors.DIM}Developed by bad-antics | NULLSEC Framework v2.0{Colors.RESET}
""")
def main():
"""Main enhancement process"""
print_banner()
print(f"""
{Colors.YELLOW}This script will enhance the NULLSEC framework with:{Colors.RESET}
β’ Database system for persistence
β’ Enhanced API endpoints
β’ Target management
β’ Attack tracking
β’ Session management
β’ Vulnerability database
β’ Workspace support
β’ Reporting capabilities
β’ Documentation
{Colors.CYAN}βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ{Colors.RESET}
""")
choice = input(f"{Colors.WHITE}Continue with enhancement? (y/n): {Colors.RESET}").strip().lower()
if choice != 'y':
print(f"\n{Colors.RED}[!] Enhancement cancelled{Colors.RESET}")
return
# Run enhancement steps
install_dependencies()
create_enhanced_database()
create_utility_scripts()
enhance_cli_launcher()
enhance_desktop_gui()
create_api_documentation()
print_summary()
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
print(f"\n\n{Colors.YELLOW}[!] Enhancement interrupted{Colors.RESET}")
sys.exit(1)
except Exception as e:
print(f"\n{Colors.RED}[!] Error: {e}{Colors.RESET}")
sys.exit(1)