-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapp.py
More file actions
1333 lines (1153 loc) · 52.4 KB
/
app.py
File metadata and controls
1333 lines (1153 loc) · 52.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
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
"""
Dorker Pro OSINT Edition v5.0 - Interface Streamlit
Multi-Domaines avec thèmes visuels interchangeables
+ Mode Chasseur de fuites
+ Extraction IOC
+ Améliorations UX/UI
"""
import streamlit as st
import asyncio
import aiohttp
import aiosqlite
import json
import time
import random
import urllib.parse
import hashlib
import csv
import io
import re
import plotly.express as px
import plotly.graph_objects as go
from pathlib import Path
from typing import List, Dict, Set, Optional, Tuple
from dataclasses import dataclass, asdict, field
from datetime import datetime
from collections import defaultdict, Counter
from email_validator import validate_email, EmailNotValidError
import phonenumbers
from phonenumbers import carrier, geocoder, timezone
import logging
import pandas as pd
# ============================================================================
# THÈMES CSS (version améliorée UX)
# ============================================================================
THEMES = {
"Terminal Rétro": {
"icon": "🖥️",
"css": """
@import url('https://fonts.googleapis.com/css2?family=VT323&family=Share+Tech+Mono&display=swap');
:root {
--bg-primary: #0a0a0a;
--bg-secondary: #111111;
--bg-card: #0d1a0d;
--accent: #00ff41;
--accent-dim: #00aa2a;
--accent-glow: rgba(0,255,65,0.15);
--text-primary: #00ff41;
--text-secondary: #00aa2a;
--text-dim: #005510;
--border: #00ff41;
--danger: #ff0040;
--warning: #ffaa00;
--info: #00aaff;
--font-main: 'Share Tech Mono', monospace;
--font-display: 'VT323', monospace;
}
.stApp {
background-color: var(--bg-primary) !important;
background-image:
repeating-linear-gradient(
0deg,
transparent,
transparent 2px,
rgba(0, 255, 65, 0.02) 2px,
rgba(0, 255, 65, 0.02) 4px
) !important;
font-family: var(--font-main) !important;
color: var(--text-primary) !important;
transition: all 0.3s ease !important;
}
.stApp::before {
content: '';
position: fixed;
top: 0; left: 0; right: 0; bottom: 0;
background: repeating-linear-gradient(
0deg,
rgba(0,0,0,0.15) 0px,
rgba(0,0,0,0.15) 1px,
transparent 1px,
transparent 2px
);
pointer-events: none;
z-index: 9999;
}
h1, h2, h3, h4 {
font-family: var(--font-display) !important;
color: var(--accent) !important;
text-shadow: 0 0 10px var(--accent), 0 0 20px var(--accent-dim) !important;
letter-spacing: 3px !important;
}
h1 { font-size: 3rem !important; }
.stSidebar {
background-color: #050f05 !important;
border-right: 1px solid var(--accent-dim) !important;
transition: transform 0.3s ease !important;
}
.stButton > button {
background: transparent !important;
color: var(--accent) !important;
border: 1px solid var(--accent) !important;
border-radius: 0 !important;
font-family: var(--font-main) !important;
font-size: 0.9rem !important;
letter-spacing: 2px !important;
text-transform: uppercase !important;
box-shadow: 0 0 10px var(--accent-glow) !important;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}
.stButton > button:hover {
background: var(--accent-glow) !important;
box-shadow: 0 0 20px var(--accent), 0 0 40px var(--accent-dim) !important;
transform: scale(1.02) !important;
}
/* Animation de chargement cyber */
@keyframes pulse-glow {
0% { box-shadow: 0 0 5px var(--accent); }
100% { box-shadow: 0 0 20px var(--accent), 0 0 30px var(--accent-dim); }
}
div[data-testid="stMetric"] {
background: var(--bg-card) !important;
border: 1px solid var(--accent-dim) !important;
border-radius: 0 !important;
padding: 10px !important;
transition: all 0.3s ease !important;
}
div[data-testid="stMetric"]:hover {
transform: translateY(-2px) !important;
border-color: var(--accent) !important;
box-shadow: 0 0 15px var(--accent-glow) !important;
}
.score-high {
color: #00ff41;
font-weight: bold;
animation: pulse-glow 2s infinite !important;
}
.score-med { color: #ffaa00; }
.score-low { color: #ff0040; }
.ioc-email {
background: rgba(0,255,65,0.1);
border-left: 3px solid #00aaff;
padding: 8px;
margin: 4px 0;
font-family: monospace;
}
.ioc-ip {
background: rgba(255,170,0,0.1);
border-left: 3px solid #ffaa00;
padding: 8px;
margin: 4px 0;
}
.leak-alert {
background: rgba(255,0,64,0.2);
border: 2px solid #ff0040;
animation: pulse-glow 1s infinite;
padding: 12px;
margin: 8px 0;
}
.compact-mode .stDataFrame {
font-size: 0.8rem !important;
}
.stProgress > div > div > div {
background: linear-gradient(90deg, var(--accent-dim), var(--accent), var(--accent-dim)) !important;
background-size: 200% 100% !important;
animation: shimmer 1s infinite linear !important;
}
@keyframes shimmer {
0% { background-position: 200% 0; }
100% { background-position: -200% 0; }
}
.terminal-box {
background: #000;
border: 1px solid #00ff41;
border-radius: 0;
padding: 16px;
font-family: 'Share Tech Mono', monospace;
font-size: 0.85rem;
color: #00ff41;
box-shadow: 0 0 20px rgba(0,255,65,0.1), inset 0 0 20px rgba(0,0,0,0.5);
white-space: pre-wrap;
max-height: 400px;
overflow-y: auto;
}
"""
},
"CyberPunk 2077": {
"icon": "⚡",
"css": """
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Rajdhani:wght@300;500;700&display=swap');
:root {
--bg-primary: #0a0014;
--bg-secondary: #120020;
--bg-card: #1a0030;
--accent: #fcee09;
--accent2: #ff003c;
--accent3: #00f0ff;
--accent-glow: rgba(252,238,9,0.15);
--text-primary: #f0e6ff;
--text-secondary: #9b7fd4;
--border: #fcee09;
--font-main: 'Rajdhani', sans-serif;
--font-display: 'Orbitron', monospace;
}
.stApp {
background-color: var(--bg-primary) !important;
background-image:
radial-gradient(ellipse at 20% 50%, rgba(100,0,255,0.08) 0%, transparent 50%),
radial-gradient(ellipse at 80% 20%, rgba(255,0,60,0.06) 0%, transparent 50%),
radial-gradient(ellipse at 60% 80%, rgba(0,240,255,0.06) 0%, transparent 50%) !important;
font-family: var(--font-main) !important;
color: var(--text-primary) !important;
}
h1, h2, h3, h4 {
font-family: var(--font-display) !important;
color: var(--accent) !important;
text-transform: uppercase !important;
letter-spacing: 4px !important;
}
h1 {
font-size: 2.5rem !important;
text-shadow: 0 0 10px var(--accent), 0 0 30px rgba(252,238,9,0.5), -2px 2px 0 var(--accent2) !important;
}
h2 {
text-shadow: 0 0 8px var(--accent3) !important;
color: var(--accent3) !important;
}
.stSidebar {
background: linear-gradient(180deg, #0e001f 0%, #180028 100%) !important;
border-right: 2px solid var(--accent2) !important;
}
.stButton > button {
background: linear-gradient(90deg, transparent, rgba(252,238,9,0.1), transparent) !important;
color: var(--accent) !important;
border: 1px solid var(--accent) !important;
border-radius: 2px !important;
font-family: var(--font-display) !important;
font-size: 0.75rem !important;
letter-spacing: 3px !important;
text-transform: uppercase !important;
box-shadow: 0 0 15px rgba(252,238,9,0.2), inset 0 0 15px rgba(252,238,9,0.05) !important;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}
.stButton > button:hover {
background: linear-gradient(90deg, rgba(255,0,60,0.1), rgba(252,238,9,0.2), rgba(0,240,255,0.1)) !important;
box-shadow: 0 0 25px rgba(252,238,9,0.5), 0 0 50px rgba(252,238,9,0.2) !important;
transform: scale(1.05) !important;
}
div[data-testid="stMetric"] {
background: linear-gradient(135deg, rgba(26,0,48,0.9), rgba(18,0,32,0.9)) !important;
border: 1px solid rgba(252,238,9,0.3) !important;
border-left: 3px solid var(--accent) !important;
border-radius: 2px !important;
padding: 12px !important;
box-shadow: 0 0 20px rgba(252,238,9,0.05) !important;
transition: all 0.3s ease !important;
}
div[data-testid="stMetric"]:hover {
transform: translateY(-3px) !important;
border-left-width: 5px !important;
}
.terminal-box {
background: rgba(0,0,20,0.9);
border: 1px solid rgba(0,240,255,0.4);
border-top: 2px solid var(--accent);
border-radius: 2px;
padding: 16px;
font-family: 'Rajdhani', monospace;
font-size: 0.9rem;
color: #00f0ff;
box-shadow: 0 0 30px rgba(0,240,255,0.1), inset 0 0 30px rgba(0,0,0,0.5);
white-space: pre-wrap;
max-height: 400px;
overflow-y: auto;
}
"""
},
"Corporate Intel": {
"icon": "🏢",
"css": """
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;700&family=IBM+Plex+Sans:wght@300;400;600&display=swap');
:root {
--bg-primary: #f4f4f4;
--bg-secondary: #e8e8e8;
--bg-card: #ffffff;
--accent: #0f62fe;
--accent2: #da1e28;
--accent3: #198038;
--text-primary: #161616;
--text-secondary: #525252;
--border: #8d8d8d;
--font-main: 'IBM Plex Sans', sans-serif;
--font-display: 'IBM Plex Mono', monospace;
}
.stApp {
background-color: var(--bg-primary) !important;
font-family: var(--font-main) !important;
color: var(--text-primary) !important;
}
h1, h2, h3, h4 {
font-family: var(--font-display) !important;
color: var(--text-primary) !important;
letter-spacing: -0.5px !important;
font-weight: 700 !important;
}
h1 {
font-size: 2rem !important;
border-bottom: 3px solid var(--accent) !important;
padding-bottom: 8px !important;
}
.stSidebar {
background-color: #161616 !important;
border-right: none !important;
}
.stButton > button {
background: var(--accent) !important;
color: white !important;
border: none !important;
border-radius: 0 !important;
font-family: var(--font-main) !important;
font-weight: 600 !important;
font-size: 0.875rem !important;
padding: 10px 24px !important;
transition: all 0.2s ease !important;
}
.stButton > button:hover {
background: #0043ce !important;
transform: translateY(-1px) !important;
box-shadow: 0 4px 8px rgba(0,0,0,0.1) !important;
}
div[data-testid="stMetric"] {
background: var(--bg-card) !important;
border-left: 4px solid var(--accent) !important;
border-radius: 0 !important;
padding: 16px !important;
box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important;
transition: all 0.2s ease !important;
}
div[data-testid="stMetric"]:hover {
transform: translateY(-2px) !important;
box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
}
.terminal-box {
background: #161616;
border: none;
padding: 16px;
font-family: 'IBM Plex Mono', monospace;
font-size: 0.825rem;
color: #42be65;
max-height: 400px;
overflow-y: auto;
white-space: pre-wrap;
}
"""
}
}
# ============================================================================
# IOC Extraction Engine
# ============================================================================
@dataclass
class IOC:
type: str # email, ip, domain, phone, url
value: str
source_url: str
source_query: str
context: str # snippet où il a été trouvé
confidence: float = 1.0
additional_info: Dict = field(default_factory=dict)
@dataclass
class LeakSignature:
pattern: str
severity: str # critical, high, medium, low
description: str
keywords: List[str]
class IOCExtractor:
"""Extraction d'indicateurs de compromission"""
# Patterns regex pour différents types d'IOC
EMAIL_PATTERN = re.compile(r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b')
IPV4_PATTERN = re.compile(r'\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b')
DOMAIN_PATTERN = re.compile(r'\b(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}\b')
URL_PATTERN = re.compile(r'https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+[^\s]*')
PHONE_PATTERN = re.compile(r'\b(?:\+?33|0)[1-9](?:[\s.-]?\d{2}){4}\b')
# Patterns pour le mode "chasseur de fuites"
LEAK_PATTERNS = [
LeakSignature(r'(?i)(mot de passe|password|passwd|pwd)', 'high', 'Mot de passe exposé', ['password', 'mot de passe']),
LeakSignature(r'(?i)(clé[ -]?api|api[ -]?key|apikey)', 'critical', 'Clé API exposée', ['api', 'key']),
LeakSignature(r'(?i)(confidentiel|secret|top secret|classified)', 'high', 'Document confidentiel', ['secret', 'confidentiel']),
LeakSignature(r'(?i)(token|jwt|bearer)', 'critical', 'Token d\'authentification', ['token', 'jwt']),
LeakSignature(r'(?i)(compte bancaire|iban|rib|credit card|carte bancaire)', 'critical', 'Information bancaire', ['bank', 'iban', 'credit']),
LeakSignature(r'(?i)(ssn|social security|numéro sécurité sociale|nir)', 'critical', 'Numéro de sécurité sociale', ['ssn', 'nir']),
LeakSignature(r'(?i)(breach|data leak|fuite de données|compromission)', 'medium', 'Mention de fuite de données', ['leak', 'breach']),
LeakSignature(r'(?i)(private|internal use only|do not share)', 'medium', 'Document interne', ['private', 'internal']),
LeakSignature(r'(?i)(vulnerability|cve|exploit|zero day)', 'high', 'Vulnérabilité mentionnée', ['cve', 'exploit']),
]
@classmethod
def extract_emails(cls, text: str) -> List[str]:
return list(set(cls.EMAIL_PATTERN.findall(text)))
@classmethod
def extract_ips(cls, text: str) -> List[str]:
ips = cls.IPV4_PATTERN.findall(text)
# Filtrer les IPs invalides
valid_ips = []
for ip in ips:
parts = ip.split('.')
if all(0 <= int(p) <= 255 for p in parts):
valid_ips.append(ip)
return list(set(valid_ips))
@classmethod
def extract_domains(cls, text: str) -> List[str]:
domains = cls.DOMAIN_PATTERN.findall(text)
# Filtrer les faux positifs (ex: des mots normaux)
exclude = {'com', 'org', 'net', 'fr', 'www', 'http', 'https', 'html', 'php', 'asp'}
valid_domains = []
for d in domains:
if len(d) > 4 and '.' in d and d.split('.')[-1] not in exclude:
valid_domains.append(d.lower())
return list(set(valid_domains))
@classmethod
def extract_urls(cls, text: str) -> List[str]:
return list(set(cls.URL_PATTERN.findall(text)))
@classmethod
def extract_phones(cls, text: str) -> List[str]:
phones = []
for match in cls.PHONE_PATTERN.findall(text):
try:
phone_num = phonenumbers.parse(match, "FR")
if phonenumbers.is_valid_number(phone_num):
phones.append(phonenumbers.format_number(phone_num, phonenumbers.PhoneNumberFormat.INTERNATIONAL))
except:
pass
return list(set(phones))
@classmethod
def detect_leaks(cls, text: str, url: str, query: str) -> List[Dict]:
"""Détection de fuites potentielles"""
leaks = []
text_lower = text.lower()
for signature in cls.LEAK_PATTERNS:
if re.search(signature.pattern, text_lower):
leaks.append({
'type': 'leak_signature',
'severity': signature.severity,
'description': signature.description,
'found_in': url,
'query': query,
'pattern': signature.pattern
})
# Détection de mots-clés sensibles supplémentaires
sensitive_keywords = ['admin', 'root', 'config', '.env', 'database', 'sql', 'dump', 'backup']
for kw in sensitive_keywords:
if kw in text_lower:
leaks.append({
'type': 'sensitive_keyword',
'severity': 'medium',
'description': f'Mot-clé sensible: {kw}',
'found_in': url,
'query': query,
'keyword': kw
})
return leaks
@classmethod
def extract_all_from_result(cls, result: Dict) -> Dict:
"""Extrait tous les IOC d'un résultat"""
text_to_scan = f"{result.get('title', '')} {result.get('snippet', '')}"
url = result.get('url', '')
query = result.get('query', '')
iocs = {
'emails': cls.extract_emails(text_to_scan),
'ips': cls.extract_ips(text_to_scan),
'domains': cls.extract_domains(text_to_scan),
'urls': cls.extract_urls(text_to_scan),
'phones': cls.extract_phones(text_to_scan),
'leaks': cls.detect_leaks(text_to_scan, url, query)
}
return iocs
# ============================================================================
# LOGIQUE MÉTIER (version améliorée)
# ============================================================================
@dataclass
class SearchResult:
title: str
url: str
snippet: str
source_engine: str
query: str
timestamp: str = ""
rank: int = 0
http_status: int = 0
response_time: float = 0.0
osint_relevance_score: float = 0.0
iocs: Dict = field(default_factory=dict)
leak_score: float = 0.0
def __post_init__(self):
if not self.timestamp:
self.timestamp = datetime.now().isoformat()
def to_dict(self) -> Dict:
return asdict(self)
DEFAULT_CONFIG = {
"profile_name": "default",
"profile_description": "Configuration par défaut",
"trusted_domains": {},
"excluded_patterns": ['pinterest.', 'facebook.', 'twitter.', 'x.com', 'instagram.', 'tiktok.', 'amazon.', 'ebay.'],
"excluded_extensions": ['.pdf', '.doc', '.docx', '.xls', '.xlsx', '.zip', '.exe'],
"priority_keywords": [],
"search_engines": ['DuckDuckGo'],
"max_results_per_engine": 10,
"max_concurrent_requests": 3,
"delay_between_queries_min": 3,
"delay_between_queries_max": 7,
"delay_between_engines_min": 2,
"delay_between_engines_max": 5,
"http_timeout_total": 30,
"http_timeout_connect": 10,
"min_relevance_score": 50.0,
"user_agents": ['Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'],
"api_keys": {"brave": "", "serpapi": "", "searxng": "https://searx.be"},
"output_formats": ["csv", "json"],
"database_name": "osint_searches.db"
}
def calculate_osint_score(result: SearchResult, domain: str, config: Dict) -> float:
trusted_domains = config.get("trusted_domains", {})
priority_keywords = config.get("priority_keywords", [])
score = 0.0
score += trusted_domains.get(domain, 0) * 3
content = (result.title + " " + result.snippet).lower()
keyword_score = sum(5 for kw in priority_keywords if kw.lower() in content)
score += min(keyword_score, 50)
if any(x in domain for x in ['osint', 'geospatial', 'satellite', 'bellingcat', 'geoconfirmed']):
score += 10
if any(x in domain for x in ['.org', '.edu', '.gouv', '.gov']):
score += 5
# Bonus pour présence d'IOC
if result.iocs:
ioc_count = len(result.iocs.get('emails', [])) + len(result.iocs.get('ips', []))
score += min(ioc_count * 5, 20)
score += min(len(result.iocs.get('leaks', [])) * 10, 30)
return min(score, 100.0)
def is_relevant(result: SearchResult, config: Dict) -> bool:
url_lower = result.url.lower()
for pattern in config.get("excluded_patterns", []):
if pattern in url_lower:
return False
for ext in config.get("excluded_extensions", []):
if url_lower.endswith(ext):
return False
return True
def normalize_url(url: str) -> str:
if not url:
return ""
url = url.lower().strip()
url = url.replace('https://', '').replace('http://', '').replace('www.', '').rstrip('/')
return url
def extract_ddg_url(ddg_url: str) -> str:
if not ddg_url:
return ""
if ddg_url.startswith('http') and 'duckduckgo.com' not in ddg_url:
return ddg_url
if 'uddg=' in ddg_url:
try:
parsed = urllib.parse.urlparse(ddg_url)
params = urllib.parse.parse_qs(parsed.query)
if 'uddg' in params:
return urllib.parse.unquote(params['uddg'][0])
except:
pass
return ""
DEFAULT_USER_AGENTS = [
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36',
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36',
]
async def search_duckduckgo(session, query: str, config: Dict, log_fn=None) -> List[SearchResult]:
max_results = config.get("max_results_per_engine", 10)
results = []
try:
encoded_query = urllib.parse.quote(query)
url = f"https://html.duckduckgo.com/html/?q={encoded_query}"
headers = {
'User-Agent': random.choice(config.get("user_agents", DEFAULT_USER_AGENTS)),
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'fr-FR,fr;q=0.9,en;q=0.8',
}
start_time = time.time()
async with session.get(url, headers=headers, timeout=aiohttp.ClientTimeout(total=30)) as response:
response_time = time.time() - start_time
if response.status == 200:
from bs4 import BeautifulSoup
html = await response.text()
soup = BeautifulSoup(html, 'html.parser')
for idx, result_div in enumerate(soup.find_all('div', class_='result')[:max_results]):
title_tag = result_div.find('a', class_='result__a')
if title_tag:
title = title_tag.get_text(strip=True)
raw_link = title_tag.get('href', '')
real_url = extract_ddg_url(raw_link)
snippet_tag = result_div.find('a', class_='result__snippet')
snippet = snippet_tag.get_text(strip=True) if snippet_tag else ""
if real_url and real_url.startswith('http'):
r = SearchResult(title=title, url=real_url, snippet=snippet,
source_engine="DuckDuckGo", query=query,
rank=idx+1, http_status=200, response_time=response_time)
results.append(r)
if log_fn:
log_fn(f" ✓ DuckDuckGo: {len(results)} résultats")
else:
if log_fn:
log_fn(f" ✗ DuckDuckGo: HTTP {response.status}")
except Exception as e:
if log_fn:
log_fn(f" ✗ DuckDuckGo erreur: {str(e)[:60]}")
return results
async def search_searxng(session, query: str, config: Dict, log_fn=None) -> List[SearchResult]:
max_results = config.get("max_results_per_engine", 10)
results = []
searxng_instance = config.get("api_keys", {}).get("searxng", "")
if not searxng_instance:
return results
try:
instance = searxng_instance.rstrip('/')
params = {'q': query, 'format': 'json', 'engines': 'google,bing,duckduckgo', 'language': 'fr', 'pageno': 1}
start_time = time.time()
async with session.get(f"{instance}/search", params=params, timeout=aiohttp.ClientTimeout(total=30)) as response:
response_time = time.time() - start_time
if response.status == 200:
data = await response.json()
for idx, item in enumerate(data.get('results', [])[:max_results]):
r = SearchResult(title=item.get('title', ''), url=item.get('url', ''),
snippet=item.get('content', ''),
source_engine=f"SearXNG/{item.get('engine', '?')}",
query=query, rank=idx+1, http_status=200, response_time=response_time)
results.append(r)
if log_fn:
log_fn(f" ✓ SearXNG: {len(results)} résultats")
except Exception as e:
if log_fn:
log_fn(f" ✗ SearXNG erreur: {str(e)[:60]}")
return results
async def search_brave(session, query: str, config: Dict, log_fn=None) -> List[SearchResult]:
max_results = config.get("max_results_per_engine", 10)
results = []
brave_key = config.get("api_keys", {}).get("brave", "")
if not brave_key:
if log_fn:
log_fn(" ⚠ Brave: clé API manquante")
return results
try:
headers = {'X-Subscription-Token': brave_key, 'Accept': 'application/json'}
params = {'q': query, 'count': max_results}
start_time = time.time()
async with session.get('https://api.search.brave.com/res/v1/web/search',
headers=headers, params=params,
timeout=aiohttp.ClientTimeout(total=30)) as response:
response_time = time.time() - start_time
if response.status == 200:
data = await response.json()
for idx, item in enumerate(data.get('web', {}).get('results', [])[:max_results]):
r = SearchResult(title=item.get('title', ''), url=item.get('url', ''),
snippet=item.get('description', ''),
source_engine="Brave", query=query,
rank=idx+1, http_status=200, response_time=response_time)
results.append(r)
if log_fn:
log_fn(f" ✓ Brave: {len(results)} résultats")
except Exception as e:
if log_fn:
log_fn(f" ✗ Brave erreur: {str(e)[:60]}")
return results
async def search_qwant(session, query: str, config: Dict, log_fn=None) -> List[SearchResult]:
max_results = config.get("max_results_per_engine", 10)
results = []
try:
params = {'q': query, 't': 'web', 'count': max_results, 'locale': 'fr_FR'}
headers = {'User-Agent': random.choice(config.get("user_agents", DEFAULT_USER_AGENTS))}
start_time = time.time()
async with session.get('https://api.qwant.com/v3/search/web',
params=params, headers=headers,
timeout=aiohttp.ClientTimeout(total=30)) as response:
response_time = time.time() - start_time
if response.status == 200:
data = await response.json()
items_raw = data.get('data', {}).get('result', {}).get('items', {}).get('mainline', [])
idx = 0
for item in items_raw:
if item.get('type') == 'web':
for web_result in item.get('items', []):
if idx >= max_results:
break
r = SearchResult(title=web_result.get('title', ''),
url=web_result.get('url', ''),
snippet=web_result.get('desc', ''),
source_engine="Qwant", query=query,
rank=idx+1, http_status=200, response_time=response_time)
results.append(r)
idx += 1
if log_fn:
log_fn(f" ✓ Qwant: {len(results)} résultats")
except Exception as e:
if log_fn:
log_fn(f" ✗ Qwant erreur: {str(e)[:60]}")
return results
async def run_osint_search(queries: List[str], config: Dict,
selected_engines: List[str],
progress_bar, status_text, log_container,
extract_iocs: bool = True,
leak_hunter: bool = True) -> List[Dict]:
"""Moteur de recherche principal asynchrone avec IOC extraction"""
all_results = []
logs = []
def log(msg):
logs.append(f"[{datetime.now().strftime('%H:%M:%S')}] {msg}")
engine_map = {
'DuckDuckGo': search_duckduckgo,
'SearXNG': search_searxng,
'Brave': search_brave,
'Qwant': search_qwant,
}
connector = aiohttp.TCPConnector(limit=10, force_close=True)
async with aiohttp.ClientSession(connector=connector) as session:
seen_urls: Set[str] = set()
total = len(queries)
for i, query in enumerate(queries):
log(f"━━━ [{i+1}/{total}] {query[:70]}")
status_text.text(f"Requête {i+1}/{total}: {query[:60]}...")
progress_bar.progress((i) / total)
for engine_name in selected_engines:
fn = engine_map.get(engine_name)
if not fn:
continue
log(f" 🔍 {engine_name}...")
engine_results = await fn(session, query, config, log_fn=log)
delay = random.uniform(
config.get("delay_between_engines_min", 1),
config.get("delay_between_engines_max", 3)
)
await asyncio.sleep(delay)
for r in engine_results:
norm = normalize_url(r.url)
if norm and norm not in seen_urls and is_relevant(r, config):
seen_urls.add(norm)
# Extraction IOC
if extract_iocs or leak_hunter:
r.iocs = IOCExtractor.extract_all_from_result(r.to_dict())
# Calcul du leak_score
if leak_hunter and r.iocs.get('leaks'):
r.leak_score = min(len(r.iocs['leaks']) * 20, 100)
domain = urllib.parse.urlparse(r.url).netloc.replace('www.', '')
score = calculate_osint_score(r, domain, config)
r.osint_relevance_score = score
# Alerte pour fuites critiques
if leak_hunter and r.leak_score >= 40:
log(f" ⚠️⚠️ FUITE CRITIQUE détectée dans {r.url[:60]}... (score: {r.leak_score})")
all_results.append(r.to_dict())
log_container.markdown(
f'<div class="terminal-box">' + '\n'.join(logs[-40:]) + '</div>',
unsafe_allow_html=True
)
if i < total - 1:
delay = random.uniform(
config.get("delay_between_queries_min", 2),
config.get("delay_between_queries_max", 5)
)
await asyncio.sleep(delay)
progress_bar.progress(1.0)
status_text.text(f"✅ Terminé — {len(all_results)} résultats collectés")
return all_results
def parse_queries(text: str) -> List[str]:
queries = []
for line in text.splitlines():
line = line.strip()
if line and not line.startswith('#'):
queries.append(line)
return queries
def results_to_csv(results: List[Dict]) -> str:
if not results:
return ""
output = io.StringIO()
fieldnames = ['query', 'title', 'url', 'snippet', 'source_engine', 'rank', 'osint_relevance_score', 'leak_score', 'timestamp']
writer = csv.DictWriter(output, fieldnames=fieldnames, extrasaction='ignore')
writer.writeheader()
writer.writerows(results)
return output.getvalue()
# ============================================================================
# APP STREAMLIT
# ============================================================================
def get_theme_names():
return list(THEMES.keys())
def apply_theme(theme_name: str):
theme = THEMES.get(theme_name, THEMES["Terminal Rétro"])
st.markdown(f"<style>{theme['css']}</style>", unsafe_allow_html=True)
def render_banner(theme_name: str):
theme = THEMES[theme_name]
if theme_name == "Terminal Rétro":
st.markdown("""
<div style="border:1px solid #00ff41; padding:20px; margin-bottom:20px;
box-shadow: 0 0 20px rgba(0,255,65,0.2);">
<pre style="color:#00ff41; font-family:'Share Tech Mono',monospace; margin:0; font-size:0.85rem;">
╔══════════════════════════════════════════════════════════════╗
║ ██████╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗ ║
║ ██╔══██╗██╔═══██╗██╔══██╗██║ ██╔╝██╔════╝██╔══██╗ ║
║ ██║ ██║██║ ██║██████╔╝█████╔╝ █████╗ ██████╔╝ ║
║ ██║ ██║██║ ██║██╔══██╗██╔═██╗ ██╔══╝ ██╔══██╗ ║
║ ██████╔╝╚██████╔╝██║ ██║██║ ██╗███████╗██║ ██║ ║
║ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ PRO ║
║ OSINT v5.0 - HUNTER EDITION ║
╚══════════════════════════════════════════════════════════════╝
</pre>
</div>
""", unsafe_allow_html=True)
elif theme_name == "CyberPunk 2077":
st.markdown("""
<div style="border:1px solid rgba(252,238,9,0.4); border-top:3px solid #fcee09;
padding:24px; margin-bottom:20px;
background:linear-gradient(135deg,rgba(26,0,48,0.8),rgba(10,0,20,0.9));
box-shadow:0 0 40px rgba(252,238,9,0.1);">
<h1 style="margin:0; font-family:'Orbitron',monospace; font-size:2rem;
color:#fcee09; text-shadow:0 0 15px #fcee09,-2px 2px 0 #ff003c;
letter-spacing:6px;">DORKER<span style="color:#ff003c;">_</span>PRO</h1>
<p style="margin:8px 0 0 0; font-family:'Rajdhani',sans-serif; color:#9b7fd4;
letter-spacing:4px; font-size:0.85rem;">
⚡ OSINT v5.0 // HUNTER EDITION // IOC EXTRACTION ACTIVE
</p>
</div>
""", unsafe_allow_html=True)
else:
st.markdown("""
<div style="border-left:4px solid #0f62fe; padding:16px 24px; margin-bottom:20px; background:#fff; box-shadow:0 1px 3px rgba(0,0,0,0.1);">
<h1 style="margin:0; font-family:'IBM Plex Mono',monospace; color:#161616; font-size:1.75rem;">Dorker Pro OSINT v5.0</h1>
<p style="margin:4px 0 0; font-family:'IBM Plex Sans',sans-serif; color:#525252; font-size:0.875rem;">
Intelligence Collection Platform — avec extraction automatique d'IOC
</p>
</div>
""", unsafe_allow_html=True)
def render_ioc_dashboard(iocs_data: List[Dict]):
"""Affiche le tableau de bord des IOC"""
if not iocs_data:
return
all_emails = []
all_ips = []
all_domains = []
all_phones = []
all_leaks = []
for item in iocs_data:
iocs = item.get('iocs', {})
all_emails.extend(iocs.get('emails', []))
all_ips.extend(iocs.get('ips', []))
all_domains.extend(iocs.get('domains', []))
all_phones.extend(iocs.get('phones', []))
all_leaks.extend(iocs.get('leaks', []))
st.markdown("### 🎯 Indicateurs de Compromission (IOC) extraits")
col1, col2, col3, col4, col5 = st.columns(5)
with col1:
st.metric("📧 Emails", len(set(all_emails)))
with col2:
st.metric("🌐 IPs", len(set(all_ips)))
with col3:
st.metric("🏠 Domaines", len(set(all_domains)))
with col4:
st.metric("📞 Téléphones", len(set(all_phones)))
with col5:
critical_leaks = sum(1 for l in all_leaks if l.get('severity') in ['critical', 'high'])
st.metric("⚠️ Fuites critiques", critical_leaks, delta_color="off")
# Affichage détaillé
tabs = st.tabs(["📧 Emails", "🌐 IPs", "🏠 Domaines", "📞 Téléphones", "⚠️ Fuites détectées"])
with tabs[0]:
if all_emails:
for email in sorted(set(all_emails)):
st.markdown(f'<div class="ioc-email">📧 {email}</div>', unsafe_allow_html=True)
else:
st.info("Aucun email détecté")
with tabs[1]:
if all_ips:
for ip in sorted(set(all_ips)):
st.markdown(f'<div class="ioc-ip">🌐 {ip}</div>', unsafe_allow_html=True)
else:
st.info("Aucune IP détectée")
with tabs[2]:
if all_domains:
domain_counts = Counter(all_domains)
for domain, count in domain_counts.most_common(30):