-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
281 lines (232 loc) · 9.34 KB
/
Copy pathsetup.py
File metadata and controls
281 lines (232 loc) · 9.34 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
#!/usr/bin/env python3
"""
Setup script for Advanced Cloud Penetration Testing Suite
Handles installation, configuration, and dependency management
"""
import os
import sys
import subprocess
import platform
import json
from pathlib import Path
class CloudPentestSetup:
"""Setup and configuration manager for the Cloud Pentest Suite"""
def __init__(self):
self.config_dir = Path.home() / '.cloud_pentest_suite'
self.config_file = self.config_dir / 'config.json'
self.log_dir = self.config_dir / 'logs'
def create_directories(self):
"""Create necessary directories"""
print("Creating application directories...")
directories = [self.config_dir, self.log_dir]
for directory in directories:
directory.mkdir(parents=True, exist_ok=True)
print(f"✓ Created: {directory}")
def check_system_requirements(self):
"""Check system requirements and dependencies"""
print("Checking system requirements...")
# Check Python version
python_version = sys.version_info
if python_version < (3, 8):
print(f"✗ Python 3.8+ required. Current version: {python_version.major}.{python_version.minor}")
return False
print(f"✓ Python version: {python_version.major}.{python_version.minor}.{python_version.micro}")
# Check operating system
os_name = platform.system()
print(f"✓ Operating System: {os_name} {platform.release()}")
# Check if running on Windows
if os_name != "Windows":
print("⚠ This application is optimized for Windows but can run on other platforms")
return True
def install_system_dependencies(self):
"""Install system-level dependencies"""
print("Checking system dependencies...")
# Check for nmap
try:
subprocess.run(['nmap', '--version'], capture_output=True, check=True)
print("✓ Nmap is installed")
except (subprocess.CalledProcessError, FileNotFoundError):
print("✗ Nmap not found. Please install Nmap:")
print(" Download from: https://nmap.org/download.html")
print(" Or use package manager: winget install Nmap.Nmap")
return False
return True
def install_python_dependencies(self):
"""Install Python dependencies"""
print("Installing Python dependencies...")
try:
# Upgrade pip first
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '--upgrade', 'pip'])
# Install requirements
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-r', 'requirements.txt'])
print("✓ Python dependencies installed successfully")
return True
except subprocess.CalledProcessError as e:
print(f"✗ Failed to install Python dependencies: {e}")
return False
def create_default_config(self):
"""Create default configuration file"""
print("Creating default configuration...")
default_config = {
"version": "2.0",
"settings": {
"auto_save_results": True,
"max_threads": 10,
"timeout_seconds": 30,
"default_ports": "21,22,23,25,53,80,110,143,443,993,995,8080,8443",
"log_level": "INFO"
},
"aws": {
"default_region": "us-east-1",
"max_retries": 3
},
"azure": {
"default_subscription": "",
"max_retries": 3
},
"gcp": {
"default_project": "",
"max_retries": 3
},
"reporting": {
"auto_generate": True,
"format": "excel",
"include_screenshots": False
}
}
try:
with open(self.config_file, 'w') as f:
json.dump(default_config, f, indent=4)
print(f"✓ Configuration file created: {self.config_file}")
return True
except Exception as e:
print(f"✗ Failed to create configuration: {e}")
return False
def verify_installation(self):
"""Verify the installation is working"""
print("Verifying installation...")
try:
# Test imports
test_imports = [
'tkinter', 'boto3', 'azure.identity', 'google.cloud.compute_v1',
'nmap', 'paramiko', 'pandas', 'xlsxwriter'
]
for module in test_imports:
try:
__import__(module)
print(f"✓ {module}")
except ImportError as e:
print(f"✗ {module}: {e}")
return False
print("✓ All modules imported successfully")
return True
except Exception as e:
print(f"✗ Verification failed: {e}")
return False
def setup_windows_shortcuts(self):
"""Create Windows shortcuts and Start Menu entries"""
if platform.system() != "Windows":
return True
print("Setting up Windows shortcuts...")
try:
import winshell
from win32com.client import Dispatch
# Create desktop shortcut
desktop = winshell.desktop()
shortcut_path = os.path.join(desktop, "Cloud Pentest Suite.lnk")
shell = Dispatch('WScript.Shell')
shortcut = shell.CreateShortCut(shortcut_path)
shortcut.Targetpath = sys.executable
shortcut.Arguments = os.path.abspath("CloudStrikeX.py")
shortcut.WorkingDirectory = os.path.dirname(os.path.abspath("CloudStrikeX.py"))
shortcut.IconLocation = os.path.abspath("assets/CloudStrikeX_icon.ico")
shortcut.save()
print("✓ Desktop shortcut created")
return True
except ImportError:
print("⚠ Windows shortcuts not created (missing winshell/pywin32)")
return True
except Exception as e:
print(f"⚠ Failed to create shortcuts: {e}")
return True
def run_setup(self):
"""Run the complete setup process"""
print("=" * 60)
print("CloudStrikeX - Advanced Cloud Penetration Testing Platform - Setup")
print("=" * 60)
steps = [
("Checking system requirements", self.check_system_requirements),
("Creating directories", self.create_directories),
("Installing system dependencies", self.install_system_dependencies),
("Installing Python dependencies", self.install_python_dependencies),
("Creating configuration", self.create_default_config),
("Verifying installation", self.verify_installation),
("Setting up shortcuts", self.setup_windows_shortcuts)
]
for step_name, step_func in steps:
print(f"\n{step_name}...")
if not step_func():
print(f"\n✗ Setup failed at: {step_name}")
return False
print("\n" + "=" * 60)
print("SETUP COMPLETED SUCCESSFULLY!")
print("=" * 60)
print("\nYou can now run the application using:")
print(" python CloudStrikeX.py")
print("\nOr build an executable using:")
print(" python build_exe.py")
print("\nConfiguration location:")
print(f" {self.config_file}")
print("=" * 60)
return True
class CloudPentestLauncher:
"""Application launcher with pre-flight checks"""
def __init__(self):
self.setup = CloudPentestSetup()
def pre_flight_check(self):
"""Perform pre-flight checks before launching"""
print("Performing pre-flight checks...")
# Check if configuration exists
if not self.setup.config_file.exists():
print("⚠ Configuration not found. Running setup...")
if not self.setup.run_setup():
return False
# Quick dependency check
critical_modules = ['tkinter', 'boto3']
for module in critical_modules:
try:
__import__(module)
except ImportError:
print(f"✗ Critical module missing: {module}")
print("Please run setup: python setup.py")
return False
print("✓ Pre-flight checks passed")
return True
def launch_application(self):
"""Launch the main application"""
if not self.pre_flight_check():
return False
print("Launching CloudStrikeX - Advanced Cloud Penetration Testing Platform...")
try:
# Import and run the main application
from CloudStrikeX import CloudPentestGUI
app = CloudPentestGUI()
app.run()
return True
except Exception as e:
print(f"✗ Failed to launch application: {e}")
return False
def main():
"""Main entry point"""
if len(sys.argv) > 1 and sys.argv[1] == 'launch':
# Launch mode
launcher = CloudPentestLauncher()
if not launcher.launch_application():
sys.exit(1)
else:
# Setup mode
setup = CloudPentestSetup()
if not setup.run_setup():
sys.exit(1)
if __name__ == "__main__":
main()