-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.py
More file actions
361 lines (316 loc) · 11.8 KB
/
install.py
File metadata and controls
361 lines (316 loc) · 11.8 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
#!/usr/bin/env python3
"""
ChainAnalyzer Installation Script
==================================
Automated installation script for ChainAnalyzer.
This script will:
1. Check Python version
2. Install dependencies
3. Create configuration directory
4. Set up logging
5. Verify installation
"""
import sys
import subprocess
import os
import json
from pathlib import Path
import platform
def print_banner():
"""Print installation banner."""
print("=" * 60)
print("🔗 ChainAnalyzer - Installation Script")
print("=" * 60)
print("Advanced Multi-Blockchain Transaction Forensics Tool")
print("Built for Security Operations Centers (SOC) & DFIR Teams")
print("=" * 60)
def check_python_version():
"""Check if Python version is compatible."""
print("🐍 Checking Python version...")
if sys.version_info < (3, 8):
print("❌ Error: Python 3.8 or higher is required")
print(f" Current version: {sys.version}")
return False
print(f"✅ Python {sys.version.split()[0]} is compatible")
return True
def install_dependencies():
"""Install required dependencies."""
print("\n📦 Installing dependencies...")
# Core dependencies
core_deps = [
"typer>=0.9.0",
"rich>=13.0.0",
"requests>=2.31.0",
"pyfiglet>=1.0.0",
"aiohttp>=3.8.0",
"pandas>=2.0.0",
"python-dateutil>=2.8.0",
"jsonschema>=4.17.0"
]
try:
for dep in core_deps:
print(f" Installing {dep}...")
subprocess.check_call([sys.executable, "-m", "pip", "install", dep])
print("✅ Core dependencies installed successfully")
return True
except subprocess.CalledProcessError as e:
print(f"❌ Error installing dependencies: {e}")
return False
def create_config_directory():
"""Create configuration directory and default config."""
print("\n⚙️ Setting up configuration...")
# Determine config directory based on OS
if platform.system() == "Windows":
config_dir = Path.home() / ".chainanalyzer"
else:
config_dir = Path.home() / ".chainanalyzer"
try:
# Create directory
config_dir.mkdir(exist_ok=True)
print(f" Created config directory: {config_dir}")
# Create default config
config_file = config_dir / "config.json"
if not config_file.exists():
default_config = {
"api_keys": {
"etherscan": "",
"polygonscan": "",
"bscscan": "",
"trongrid": "",
"chainalysis": "",
"bitcoin_abuse": ""
},
"blockchain_configs": {
"bitcoin": {
"enabled": True,
"api_endpoints": [
"https://blockstream.info/api",
"https://mempool.space/api"
],
"rate_limit": 60,
"free": True
},
"ethereum": {
"enabled": True,
"api_endpoints": [
"https://api.etherscan.io/api",
"https://api.ethplorer.io"
],
"rate_limit": 5,
"free": True,
"use_free_tier": True
},
"solana": {
"enabled": True,
"api_endpoints": [
"https://api.mainnet-beta.solana.com",
"https://solana-api.projectserum.com",
"https://rpc.ankr.com/solana"
],
"rate_limit": 100,
"free": True
},
"tron": {
"enabled": True,
"api_endpoints": [
"https://api.trongrid.io",
"https://api.shasta.trongrid.io"
],
"rate_limit": 20,
"free": True
},
"polygon": {
"enabled": True,
"api_endpoints": [
"https://polygon-rpc.com",
"https://rpc-mainnet.maticvigil.com",
"https://rpc-mainnet.matic.network"
],
"rate_limit": 30,
"free": True
},
"bsc": {
"enabled": True,
"api_endpoints": [
"https://bsc-dataseed.binance.org",
"https://bsc-dataseed1.defibit.io",
"https://bsc-dataseed1.ninicoin.io"
],
"rate_limit": 30,
"free": True
}
},
"analysis_settings": {
"default_max_hops": 5,
"default_depth": 3,
"max_concurrent_requests": 10,
"request_timeout": 30,
"retry_attempts": 3,
"retry_delay": 1
},
"risk_thresholds": {
"low": 0.3,
"medium": 0.6,
"high": 0.8,
"critical": 0.9
},
"threat_intelligence": {
"enabled": True,
"update_interval": 3600,
"blacklist_sources": [
"cryptoscamdb",
"chainabuse",
"cryptoscam"
],
"reputation_sources": [
"etherscan_tags",
"bitcoin_abuse",
"chainalysis"
],
"free_only": True
},
"monitoring": {
"enabled": True,
"check_interval": 30,
"alert_thresholds": {
"volume": 10000,
"frequency": 10,
"suspicious_patterns": True
}
},
"logging": {
"level": "INFO",
"log_directory": "logs",
"max_file_size": 10485760,
"backup_count": 5,
"console_output": True,
"file_output": True
},
"export": {
"default_format": "json",
"output_directory": "exports",
"include_timestamps": True,
"compress_output": False
},
"ui": {
"theme": "dark",
"show_progress": True,
"verbose_output": False,
"color_output": True
},
"free_apis": {
"enabled": True,
"rate_limiting": True,
"fallback_endpoints": True,
"cache_responses": True
}
}
with open(config_file, 'w') as f:
json.dump(default_config, f, indent=2)
print(f" Created default configuration: {config_file}")
print("✅ Configuration setup complete")
return True
except Exception as e:
print(f"❌ Error setting up configuration: {e}")
return False
def create_directories():
"""Create necessary directories."""
print("\n📁 Creating directories...")
directories = ["logs", "exports", "reports"]
try:
for dir_name in directories:
Path(dir_name).mkdir(exist_ok=True)
print(f" Created directory: {dir_name}/")
print("✅ Directories created successfully")
return True
except Exception as e:
print(f"❌ Error creating directories: {e}")
return False
def verify_installation():
"""Verify that the installation was successful."""
print("\n🔍 Verifying installation...")
try:
# Test imports
import typer
import rich
import requests
import pyfiglet
import aiohttp
import pandas
print("✅ All dependencies imported successfully")
# Test main script
if os.path.exists("chain_analyzer.py"):
print("✅ Main script found")
else:
print("⚠️ Warning: chain_analyzer.py not found in current directory")
# Test configuration
config_dir = Path.home() / ".chainanalyzer"
config_file = config_dir / "config.json"
if config_file.exists():
print("✅ Configuration file found")
else:
print("⚠️ Warning: Configuration file not found")
print("✅ Installation verification complete")
return True
except ImportError as e:
print(f"❌ Import error: {e}")
return False
except Exception as e:
print(f"❌ Verification error: {e}")
return False
def print_usage_instructions():
"""Print usage instructions."""
print("\n" + "=" * 60)
print("🚀 Installation Complete!")
print("=" * 60)
print("\n📖 Usage Instructions:")
print("\n1. Basic transaction tracing:")
print(" python chain_analyzer.py trace --currency ethereum <address>")
print("\n2. Get help:")
print(" python chain_analyzer.py --help")
print("\n3. View configuration:")
print(" python chain_analyzer.py config show")
print("\n4. Monitor transactions:")
print(" python chain_analyzer.py monitor --address <address> --currency ethereum")
print("\n5. Threat intelligence analysis:")
print(" python chain_analyzer.py threat-intel --address <address> --currency ethereum")
print("\n🔗 Supported Blockchains:")
print(" • Bitcoin (BTC) - Blockstream API (free)")
print(" • Ethereum (ETH) - Etherscan free tier + Ethplorer")
print(" • Solana (SOL) - Public RPC endpoints")
print(" • Tron (TRX) - Public TronGrid API")
print(" • Polygon (MATIC) - Public RPC endpoints")
print(" • BSC - Public RPC endpoints")
print("\n🆓 All APIs are FREE - no paid subscriptions required!")
print("\n📚 Documentation:")
print(" • README.md - Complete documentation")
print(" • Examples and use cases included")
print("\n" + "=" * 60)
print("🕵️ ChainAnalyzer v2.0.0 - Ready for Action!")
print("=" * 60)
def main():
"""Main installation function."""
print_banner()
# Check Python version
if not check_python_version():
sys.exit(1)
# Install dependencies
if not install_dependencies():
print("\n❌ Installation failed. Please check the error messages above.")
sys.exit(1)
# Create configuration
if not create_config_directory():
print("\n❌ Configuration setup failed.")
sys.exit(1)
# Create directories
if not create_directories():
print("\n❌ Directory creation failed.")
sys.exit(1)
# Verify installation
if not verify_installation():
print("\n❌ Installation verification failed.")
sys.exit(1)
# Print usage instructions
print_usage_instructions()
if __name__ == "__main__":
main()