-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
357 lines (279 loc) · 12.3 KB
/
main.py
File metadata and controls
357 lines (279 loc) · 12.3 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
#!/usr/bin/env python3
"""
Raven Trace - OSINT Intelligence Tool
Recherche avancée par Email, Téléphone, Pseudo
CLI complète avec toutes les fonctionnalités
"""
import click
from rich.console import Console
from rich.table import Table
from rich.panel import Panel
import sys
from pathlib import Path
from datetime import datetime
from typing import Dict, Optional
# Import des modules locaux
from core.engine import SearchEngine
from cli.interface import (
show_banner, setup_logging, show_help, show_menu,
search_email_interactive, search_phone_interactive,
search_username_interactive, show_config_menu, show_history,
show_success, show_error, show_warning, show_info,
show_results_table, confirm_action
)
from utils.formatter import (
format_results, create_results_table, export_html,
export_json, export_csv
)
console = Console()
class RavenTrace:
def __init__(self):
self.engine = SearchEngine(max_workers=5)
self.logger = setup_logging()
def search_email(self, email: str, deep_scan: bool = False,
export_format: Optional[str] = None) -> Dict:
"""Recherche par email"""
console.print(f"\n[bold cyan]🔍 Recherche par Email: {email}[/bold cyan]\n")
try:
results = self.engine.search_email(email, deep_scan)
if 'error' in results:
show_error(results['error'])
return results
# Affichage formaté
output = format_results(results)
console.print(Panel(output, title="[bold]Résultats Email[/bold]", border_style="green"))
# Table de résumé
create_results_table(results)
# Export si demandé
if export_format:
self._export_results(results, export_format)
return results
except Exception as e:
show_error(f"Erreur recherche email: {e}")
return {"error": str(e)}
def search_phone(self, phone: str, country: str = "FR", deep_scan: bool = False,
export_format: Optional[str] = None) -> Dict:
"""Recherche par téléphone"""
console.print(f"\n[bold cyan]📱 Recherche par Téléphone: {phone}[/bold cyan]\n")
try:
results = self.engine.search_phone(phone, country, deep_scan)
if 'error' in results:
show_error(results['error'])
return results
# Affichage formaté
output = format_results(results)
console.print(Panel(output, title="[bold]Résultats Téléphone[/bold]", border_style="green"))
# Table de résumé
create_results_table(results)
# Export si demandé
if export_format:
self._export_results(results, export_format)
return results
except Exception as e:
show_error(f"Erreur recherche phone: {e}")
return {"error": str(e)}
def search_username(self, username: str, deep_scan: bool = False,
export_format: Optional[str] = None) -> Dict:
"""Recherche par pseudo"""
console.print(f"\n[bold cyan]👤 Recherche par Pseudo: {username}[/bold cyan]\n")
try:
results = self.engine.search_username(username, deep_scan)
if 'error' in results:
show_error(results['error'])
return results
# Affichage formaté
output = format_results(results)
console.print(Panel(output, title="[bold]Résultats Username[/bold]", border_style="green"))
# Table de résumé
create_results_table(results)
# Export si demandé
if export_format:
self._export_results(results, export_format)
return results
except Exception as e:
show_error(f"Erreur recherche username: {e}")
return {"error": str(e)}
def _export_results(self, results: Dict, export_format: str) -> None:
"""Exporter les résultats"""
try:
export_dir = Path.home() / '.raven_trace' / 'exports'
export_dir.mkdir(parents=True, exist_ok=True)
query = results.get('email') or results.get('username') or results.get('phone', 'search')
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
filepath = export_dir / f"{query}_{timestamp}.{export_format}"
if export_format == 'json':
export_json(results, str(filepath))
elif export_format == 'csv':
export_csv(results, str(filepath))
elif export_format == 'html':
export_html(results, str(filepath))
show_success(f"Résultats exportés: {filepath}")
except Exception as e:
show_error(f"Erreur export: {e}")
def interactive_mode(self) -> None:
"""Mode interactif complet"""
while True:
show_banner()
show_menu()
choice = click.prompt(
"[bold cyan]Sélectionnez une option[/bold cyan]",
type=click.Choice(['1', '2', '3', '4', '5', '6', '7', '8'])
)
if choice == '1':
# Email
params = search_email_interactive()
self.search_email(
params['query'],
deep_scan=params['deep'],
export_format=params['export'] if params['export'] != 'none' else None
)
elif choice == '2':
# Phone
params = search_phone_interactive()
self.search_phone(
params['query'],
country=params['country'],
deep_scan=params['deep'],
export_format=params['export'] if params['export'] != 'none' else None
)
elif choice == '3':
# Username
params = search_username_interactive()
self.search_username(
params['query'],
deep_scan=params['deep'],
export_format=params['export'] if params['export'] != 'none' else None
)
elif choice == '4':
# Recherche combinée
query = click.prompt("[bold cyan]Entrez votre recherche[/bold cyan]")
results = self.engine.search_combined(query)
console.print(Panel(str(results), title="[bold]Résultats Combinés[/bold]", border_style="yellow"))
elif choice == '5':
# Historique
show_history()
elif choice == '6':
# Configuration
show_config_menu()
elif choice == '7':
# Aide
show_help()
elif choice == '8':
# Quitter
show_info("Au revoir!")
sys.exit(0)
# Pause
click.pause()
# CLI avec Click
@click.group()
@click.version_option(version='1.0.0', prog_name='RavenTrace')
def cli():
"""🐦 RavenTrace - Advanced OSINT Intelligence Tool"""
pass
@cli.command()
@click.argument('email')
@click.option('--deep', is_flag=True, help='Deep scan mode')
@click.option('--export', type=click.Choice(['json', 'csv', 'html']), help='Format export')
def email(email: str, deep: bool, export: Optional[str]) -> None:
"""Recherche par Email"""
rt = RavenTrace()
rt.search_email(email, deep, export)
@cli.command()
@click.argument('phone')
@click.option('--country', default='FR', help='Code pays (FR, US, etc)')
@click.option('--deep', is_flag=True, help='Deep scan mode')
@click.option('--export', type=click.Choice(['json', 'csv', 'html']), help='Format export')
def phone(phone: str, country: str, deep: bool, export: Optional[str]) -> None:
"""Recherche par Téléphone"""
rt = RavenTrace()
rt.search_phone(phone, country, deep, export)
@cli.command()
@click.argument('username')
@click.option('--deep', is_flag=True, help='Deep scan mode')
@click.option('--export', type=click.Choice(['json', 'csv', 'html']), help='Format export')
def username(username: str, deep: bool, export: Optional[str]) -> None:
"""Recherche par Pseudo"""
rt = RavenTrace()
rt.search_username(username, deep, export)
@cli.command()
@click.argument('query', required=False)
def interactive(query: Optional[str]) -> None:
"""Mode interactif"""
rt = RavenTrace()
if query:
# Recherche directe en mode interactif
results = rt.engine.search_combined(query)
console.print(Panel(str(results), title="[bold]Résultats[/bold]", border_style="yellow"))
else:
# Menu interactif complet
rt.interactive_mode()
@cli.command()
def info() -> None:
"""Afficher les informations du système"""
from config import get_config, get_cache_config
config = get_config()
cache_config = get_cache_config()
table = Table(title="🐦 RavenTrace - Information Système", show_header=True, header_style="bold magenta")
table.add_column("Paramètre", style="cyan")
table.add_column("Valeur", style="green")
table.add_row("Version", "1.0.0")
table.add_row("Cache Directory", str(cache_config.directory))
table.add_row("Cache TTL", f"{cache_config.ttl_hours} heures")
table.add_row("Log Directory", str(Path.home() / '.raven_trace' / 'logs'))
table.add_row("Export Directory", str(Path.home() / '.raven_trace' / 'exports'))
console.print(table)
@cli.command()
def clear_cache() -> None:
"""Nettoyer le cache"""
rt = RavenTrace()
if confirm_action("Êtes-vous sûr de vouloir nettoyer le cache?"):
rt.engine.clear_cache(days=0)
show_success("Cache nettoyé avec succès")
else:
show_warning("Opération annulée")
@cli.command()
def show_config() -> None:
"""Afficher la configuration"""
from config import get_config
config = get_config()
table = Table(title="⚙️ Configuration RavenTrace", show_header=True, header_style="bold magenta")
table.add_column("Clé", style="cyan")
table.add_column("Valeur", style="green")
for key, value in config.to_dict().items():
if isinstance(value, dict):
for subkey, subvalue in value.items():
table.add_row(f"{key}.{subkey}", str(subvalue))
else:
table.add_row(key, str(value))
console.print(table)
@cli.command()
@click.argument('email')
@click.argument('username')
@click.argument('phone', required=False)
def batch(email: str, username: str, phone: Optional[str]) -> None:
"""Recherche par batch"""
rt = RavenTrace()
results = {
'email': rt.search_email(email) if email else None,
'username': rt.search_username(username) if username else None,
'phone': rt.search_phone(phone) if phone else None,
}
# Export résultats
export_dir = Path.home() / '.raven_trace' / 'exports'
export_dir.mkdir(parents=True, exist_ok=True)
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
filepath = export_dir / f"batch_search_{timestamp}.json"
export_json(results, str(filepath))
show_success(f"Recherche batch exportée: {filepath}")
@cli.command()
def version() -> None:
"""Afficher la version"""
console.print("[bold cyan]🐦 RavenTrace v2.0.1[/bold cyan]")
console.print("[yellow]Advanced OSINT Intelligence Tool[/yellow]")
console.print("[dim]© 2025 - Samy Nyx[/dim]")
@cli.command()
def help_cmd() -> None:
"""Afficher l'aide complète"""
show_help()
if __name__ == '__main__':
cli()