-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
262 lines (219 loc) · 8.57 KB
/
setup.py
File metadata and controls
262 lines (219 loc) · 8.57 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
#!/usr/bin/env python3
"""
IntelProbe Setup Script
Simple installation and configuration for IntelProbe
Created by: Lintshiwe Slade
"""
import os
import sys
import subprocess
from pathlib import Path
def print_banner():
"""Display IntelProbe banner"""
banner = """
███████╗███╗ ██╗████████╗███████╗██╗ ██████╗ ██████╗ ██████╗ ██████╗ ███████╗
██╔════╝████╗ ██║╚══██╔══╝██╔════╝██║ ██╔══██╗██╔══██╗██╔═══██╗██╔══██╗██╔════╝
██║ ██╔██╗ ██║ ██║ █████╗ ██║ ██████╔╝██████╔╝██║ ██║██████╔╝█████╗
██║ ██║╚██╗██║ ██║ ██╔══╝ ██║ ██╔═══╝ ██╔══██╗██║ ██║██╔══██╗██╔══╝
███████╗██║ ╚████║ ██║ ███████╗███████╗██║ ██║ ██║╚██████╔╝██████╔╝███████╗
╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝
🔍 AI-Powered Network Forensics CLI Utility
Created by: Lintshiwe Slade (@lintshiwe)
"""
print(banner)
def check_python_version():
"""Check if Python version is compatible"""
if sys.version_info < (3, 8):
print("❌ Error: Python 3.8 or higher is required")
print(f" Current version: {sys.version}")
sys.exit(1)
print(f"✅ Python {sys.version.split()[0]} detected")
def install_dependencies():
"""Install required dependencies"""
print("\n📦 Installing dependencies...")
try:
# Try simple requirements first
result = subprocess.run([
sys.executable, "-m", "pip", "install", "-r", "requirements-simple.txt"
], check=True, capture_output=True, text=True)
print("✅ Basic dependencies installed successfully")
# Ask about optional dependencies
install_advanced = input("\n🤔 Install advanced dependencies (pandas, numpy, etc.)? [y/N]: ").lower().strip()
if install_advanced in ['y', 'yes']:
print("📦 Installing advanced dependencies...")
advanced_packages = [
"pandas>=2.1.0",
"numpy>=1.25.0",
"matplotlib>=3.7.0",
"requests[security]"
]
for package in advanced_packages:
try:
subprocess.run([
sys.executable, "-m", "pip", "install", package
], check=True, capture_output=True, text=True)
print(f"✅ Installed {package}")
except subprocess.CalledProcessError:
print(f"⚠️ Failed to install {package} (optional)")
return True
except subprocess.CalledProcessError as e:
print(f"❌ Failed to install dependencies: {e}")
print("💡 Try installing manually: pip install -r requirements-simple.txt")
return False
except FileNotFoundError:
print("❌ requirements-simple.txt not found")
return False
def create_directories():
"""Create necessary directory structure"""
print("\n📁 Creating directory structure...")
directories = [
"reports",
"logs",
"sessions",
"alerts",
"cache",
"docs"
]
for directory in directories:
Path(directory).mkdir(exist_ok=True)
print(f"✅ Created {directory}/")
def create_config():
"""Create basic configuration file"""
print("\n⚙️ Creating configuration...")
config_content = """[Network]
# Default network interface (auto-detect if empty)
interface=auto
# Scan timeout in seconds
timeout=30
# Number of threads for scanning
threads=50
[AI]
# Enable AI features (requires API key)
enabled=false
# AI provider (openai, huggingface, local)
provider=openai
# API key file path (keep secure!)
api_key_file=.env
[Output]
# Output format (json, xml, csv, txt)
format=json
# Save reports to file
save_to_file=true
# Report directory
report_path=./reports/
# Log level (DEBUG, INFO, WARNING, ERROR)
log_level=INFO
# Enable file logging
log_to_file=true
[Scanning]
# Default port range
port_range=1-1000
# Scan speed (fast, normal, slow)
speed=normal
# Enable service detection
service_detection=true
# Enable OS detection
os_detection=true
[Detection]
# Enable real-time monitoring
monitoring=true
# Alert threshold for anomalies
threshold=0.7
# Save alerts to file
save_alerts=true
[OSINT]
# Enable OSINT gathering
enabled=true
# External API timeout
api_timeout=10
# Cache results
cache_results=true
"""
if not Path("config.ini").exists():
with open("config.ini", "w") as f:
f.write(config_content)
print("✅ Created config.ini")
else:
print("✅ config.ini already exists")
def create_env_template():
"""Create environment template"""
env_content = """# IntelProbe Environment Configuration
# Created by: Lintshiwe Slade
# OpenAI API Key (for AI features)
OPENAI_API_KEY=your_openai_api_key_here
# Shodan API Key (for OSINT)
SHODAN_API_KEY=your_shodan_api_key_here
# VirusTotal API Key (for threat intelligence)
VIRUSTOTAL_API_KEY=your_virustotal_api_key_here
# Other API keys as needed
# CENSYS_API_ID=your_censys_api_id
# CENSYS_API_SECRET=your_censys_api_secret
"""
if not Path(".env.template").exists():
with open(".env.template", "w") as f:
f.write(env_content)
print("✅ Created .env.template")
print("💡 Copy .env.template to .env and add your API keys")
def test_installation():
"""Test basic functionality"""
print("\n🧪 Testing installation...")
try:
# Test core imports
from core.config import ConfigManager
from core.interface import IntelProbeInterface
print("✅ Core modules imported successfully")
# Test configuration
config = ConfigManager()
print("✅ Configuration loaded successfully")
# Test basic functionality
print("✅ Basic functionality test passed")
return True
except ImportError as e:
print(f"❌ Import error: {e}")
return False
except Exception as e:
print(f"❌ Test failed: {e}")
return False
def print_next_steps():
"""Print next steps for user"""
print("\n🎉 IntelProbe setup completed successfully!")
print("\n📋 Next steps:")
print("1. Copy .env.template to .env and add your API keys")
print("2. Review and customize config.ini as needed")
print("3. Run IntelProbe: python intelprobe.py --help")
print("4. Start with a basic scan: python intelprobe.py scan --help")
print("\n💡 For advanced features:")
print(" - Install scapy for packet analysis: pip install scapy")
print(" - Install AI libraries: pip install openai")
print(" - See README.md for complete documentation")
print("\n👨💻 Created by: Lintshiwe Slade (@lintshiwe)")
print("🔗 GitHub: https://github.com/lintshiwe/IntelProbe")
def main():
"""Main setup function"""
print_banner()
print("🚀 Welcome to IntelProbe Setup")
print("Setting up your AI-powered network forensics environment...")
# Check prerequisites
check_python_version()
# Setup steps
if install_dependencies():
create_directories()
create_config()
create_env_template()
if test_installation():
print_next_steps()
else:
print("\n⚠️ Installation completed with some issues")
print("Please check the error messages above")
else:
print("\n❌ Setup failed during dependency installation")
print("Please install dependencies manually and try again")
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print("\n\n⏹️ Setup cancelled by user")
sys.exit(1)
except Exception as e:
print(f"\n❌ Setup failed with error: {e}")
sys.exit(1)