-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
source_search.py
242 lines (217 loc) · 11.4 KB
/
source_search.py
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
import requests
import re
from colorama import init, Fore
# Initialize colorama
init()
def check_domain_in_blocklist(source_url, target_domain):
try:
response = requests.get(source_url)
response.raise_for_status()
lines = [
line.strip()
for line in response.text.split("\n")
if line.strip() and not line.startswith(("#", "!"))
]
pattern = rf"(?:^|\s|\.|\|){re.escape(target_domain)}(?=\^|\s|$)"
matches = [re.search(pattern, line, flags=re.MULTILINE) for line in lines]
return any(matches)
except requests.exceptions.RequestException as e:
print(f"Error checking {source_url}: {e}")
return False
def find_blocking_blocklists(
target_domain, green_sources, blue_sources, bog_sources, search_sources
):
blocking_green_blocklists = {category: [] for category in green_sources}
blocking_blue_blocklists = {category: [] for category in blue_sources}
blocking_bog_blocklists = {category: [] for category in bog_sources}
if search_sources in ("g", "green", "green sources", "a", "all", "all sources"):
for category, sources in green_sources.items():
for name, source in sources.items():
if check_domain_in_blocklist(source, target_domain):
blocking_green_blocklists[category].append(name)
if search_sources in ("b", "blue", "blue sources", "a", "all", "all sources"):
for category, sources in blue_sources.items():
for name, source in sources.items():
if check_domain_in_blocklist(source, target_domain):
blocking_blue_blocklists[category].append(name)
if search_sources in ("o", "bog", "bog sources", "a", "all", "all sources"):
for category, sources in bog_sources.items():
for name, source in sources.items():
if check_domain_in_blocklist(source, target_domain):
blocking_bog_blocklists[category].append(name)
if any(blocking_green_blocklists.values()):
print(
Fore.GREEN
+ f"Domain '{target_domain}' found in the following green sources:\n"
)
for category, blocklists in blocking_green_blocklists.items():
if blocklists:
print(Fore.RESET + f"{category}:\n")
for blocklist in blocklists:
print(Fore.GREEN + f" - {blocklist}\n")
if any(blocking_blue_blocklists.values()):
print(
Fore.BLUE
+ f"Domain '{target_domain}' found in the following blue sources:\n"
)
for category, blocklists in blocking_blue_blocklists.items():
if blocklists:
print(Fore.RESET + f"{category}:\n")
for blocklist in blocklists:
print(Fore.BLUE + f" - {blocklist}\n")
if any(blocking_bog_blocklists.values()):
print(
Fore.CYAN
+ f"Domain '{target_domain}' found in the following bog sources:\n"
)
for category, blocklists in blocking_bog_blocklists.items():
if blocklists:
print(Fore.RESET + f"{category}:\n")
for blocklist in blocklists:
print(Fore.CYAN + f" - {blocklist}\n")
if (
not any(blocking_green_blocklists.values())
and not any(blocking_blue_blocklists.values())
and not any(blocking_bog_blocklists.values())
):
print(Fore.RED + f"Domain '{target_domain}' not found in any sources.")
# Reset the text color to default
print(Fore.RESET, end="")
if __name__ == "__main__":
green_blocklist_sources = {
"Suspicious": {
"Add.Spam": "https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.Spam/hosts",
"KADhosts": "https://raw.githubusercontent.com/FiltersHeroes/KADhosts/master/KADomains.txt",
"WaLLy3K List": "https://v.firebog.net/hosts/static/w3kbl.txt",
},
"Advertising": {
"Adaway": "https://adaway.org/hosts.txt",
"Adguard DNS Filter": "https://v.firebog.net/hosts/AdguardDNS.txt",
"anudeepND List": "https://raw.githubusercontent.com/anudeepND/blacklist/master/adservers.txt",
"Easylist Mirror": "https://v.firebog.net/hosts/Easylist.txt",
"GetAdmiral Domains": "https://raw.githubusercontent.com/LanikSJ/ubo-filters/main/filters/getadmiral-domains.txt",
"hostsVN": "https://raw.githubusercontent.com/bigdargon/hostsVN/master/hosts",
"Pete Lowe List": "https://pgl.yoyo.org/adservers/serverlist.php?hostformat=adblockplus&showintro=1&mimetype=plaintext",
"Unchecky": "https://raw.githubusercontent.com/FadeMind/hosts.extras/master/UncheckyAds/hosts",
},
"Tracking": {
"Add.2o7Net": "https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.2o7Net/hosts",
"Easyprivacy Mirror": "https://v.firebog.net/hosts/Easyprivacy.txt",
"Geoffrey Frogeye First-Party Trackers": "https://hostfiles.frogeye.fr/firstparty-trackers-hosts.txt",
"Prigent Ads": "https://v.firebog.net/hosts/Prigent-Ads.txt",
"Windows Spy List": "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt",
},
"Malicious": {
"Add.Risk": "https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.Risk/hosts",
"DandelionSprout AntiMalware": "https://raw.githubusercontent.com/DandelionSprout/adfilt/master/Alternate%20versions%20Anti-Malware%20List/AntiMalwareHosts.txt",
"Mandiant_APT1_Report_Appendix_D": "https://bitbucket.org/ethanr/dns-blacklists/raw/8575c9f96e5b4a1308f2f12394abd86d0927a4a0/bad_lists/Mandiant_APT1_Report_Appendix_D.txt",
"Phishing Army": "https://phishing.army/download/phishing_army_blocklist_extended.txt",
"Prigent Crypto": "https://v.firebog.net/hosts/Prigent-Crypto.txt",
"Quidsup Malware": "https://gitlab.com/quidsup/notrack-blocklists/-/raw/master/malware.hosts",
"RPiList Malware": "https://raw.githubusercontent.com/RPiList/specials/master/Blocklisten/malware",
"RPiList Phishing": "https://raw.githubusercontent.com/RPiList/specials/master/Blocklisten/Phishing-Angriffe",
"Spam404": "https://raw.githubusercontent.com/Spam404/lists/master/main-blacklist.txt",
"Stalkerware Indicators": "https://raw.githubusercontent.com/AssoEchap/stalkerware-indicators/master/generated/hosts_full",
"Threat Intel List": "https://osint.digitalside.it/Threat-Intel/lists/latestdomains.txt",
"URLHaus Malware": "https://malware-filter.gitlab.io/malware-filter/urlhaus-filter-hosts.txt",
},
"Miscellaneous": {
"ZeroDot1 CoinBlocker": "https://gitlab.com/ZeroDot1/CoinBlockerLists/-/raw/master/hosts",
},
}
blue_blocklist_sources = {
"Suspicious": {
"BarbBlock": "https://raw.githubusercontent.com/paulgb/BarbBlock/main/blocklists/ublock-origin.txt",
"Dan Pollock Hosts": "https://someonewhocares.org/hosts/zero/hosts",
"MVPS Hosts": "https://winhelp2002.mvps.org/hosts.txt",
"neoFelhz neoHosts": "https://cdn.jsdelivr.net/gh/neoFelhz/neohosts@gh-pages/full/hosts.txt",
"Referrer Spam": "https://raw.githubusercontent.com/matomo-org/referrer-spam-blacklist/master/spammers.txt",
"RooneyMcNibNug SNAFU": "https://raw.githubusercontent.com/RooneyMcNibNug/pihole-stuff/master/SNAFU.txt",
"VeleSila Hosts": "https://raw.githubusercontent.com/VeleSila/yhosts/master/hosts",
},
"Advertising": {
"Jdlingyu Ad-wars": "https://raw.githubusercontent.com/jdlingyu/ad-wars/master/hosts",
},
"Tracking": {
"Lightswitch05 Ads Tracking": "https://www.github.developerdan.com/hosts/lists/ads-and-tracking-extended.txt",
"Perflyst Android Trackers": "https://raw.githubusercontent.com/Perflyst/PiHoleBlocklist/master/android-tracking.txt",
"Perflyst SmartTV Domains": "https://raw.githubusercontent.com/Perflyst/PiHoleBlocklist/master/SmartTV.txt",
"Perflyst Amazon FireTV Domains": "https://raw.githubusercontent.com/Perflyst/PiHoleBlocklist/master/AmazonFireTV.txt",
"Quidsup Tracker": "https://gitlab.com/quidsup/notrack-blocklists/-/raw/master/trackers.hosts",
},
"Malicious": {
"Phishing Blocklist": "https://malware-filter.gitlab.io/malware-filter/phishing-filter-agh.txt",
"Prigent Malware": "https://v.firebog.net/hosts/Prigent-Malware.txt",
},
"Miscellaneous": {
"Porn List": "https://raw.githubusercontent.com/chadmayfield/my-pihole-blocklists/master/lists/pi_blocklist_porn_top1m.list",
},
}
bog_blocklist_sources = {
"Suspicious": {
"The Hosts File Project": "https://hostsfile.mine.nu/hosts0.txt",
"hostsfile.org": "https://hostsfile.org/Downloads/hosts.txt",
"Mahakala": "https://adblock.mahakala.is/",
},
"Advertising": {
"Disconnect-Me Ad": "https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt",
},
"Tracking": {
"Geoffrey Frogeye Multi-Party Trackers": "https://hostfiles.frogeye.fr/multiparty-trackers-hosts.txt",
"Kees1958 Top Ads-Trackers": "https://raw.githubusercontent.com/Kees1958/W3C_annual_most_used_survey_blocklist/master/EU_US_MV3_most_common_ad%2Btracking_networks.txt",
},
"Malicious": {
"Disconnect-Me Malvertising": "https://s3.amazonaws.com/lists.disconnect.me/simple_malvertising.txt",
},
}
while True:
target_domain = input("Enter a domain to find (or type 'exit' to close): ")
if target_domain.lower() == "exit":
print("Exiting the script.")
break
if (
"." not in target_domain
or target_domain.startswith(".")
or target_domain.endswith(".")
or ".." in target_domain
):
print(Fore.YELLOW + "Invalid domain")
print(Fore.RESET, end="")
continue
while True:
search_option = input(
"Search in (g)reen, (b)lue, b(o)g, (a)ll sources, (r)eset, or (e)xit: "
).lower()
if search_option == "r" or search_option == "reset":
break # Break to the outer loop and start over
elif search_option in (
"g",
"green",
"green sources",
"b",
"blue",
"blue sources",
"o",
"bog",
"bog sources",
"a",
"all",
"all sources",
):
find_blocking_blocklists(
target_domain,
green_blocklist_sources,
blue_blocklist_sources,
bog_blocklist_sources,
search_option,
)
break
elif search_option == "e" or search_option == "exit":
print("Exiting the script.")
exit() # Exit the script entirely
else:
print(
Fore.YELLOW
+ "Invalid. Please enter 'g', 'b', 'o', 'a', 'r', or 'e'."
)
print(Fore.RESET, end="")