-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom.py
148 lines (126 loc) · 3.51 KB
/
custom.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
import re
from config import (
DOMAIN_ENDS,
DOMAIN_STARTS,
LEGIT_DOMAINS,
PATH_CONTAINS,
PATH_ENDS,
PATH_EQUALS,
PATH_STARTS,
)
from utils import compare
def use_domain(domain: str, url_path: str, verbose: bool = False) -> bool:
# Ignore legit domains
if compare(domain, LEGIT_DOMAINS, 'endswith'):
return False
# Use domain if url_path is too short
if (
len(url_path.rstrip('.~!/')) <= 3 and
domain not in (
'gx.ax',
'reactstudio.it',
'supermario-game.com'
)
):
if verbose:
print_domain(domain, url_path)
return True
# .com- cases
if '.com-' in domain:
return True
# Social media
if (
domain.startswith('server.') and
domain.endswith('.com') and
url_path.startswith('/invite/')
):
return True
# USPS
if (
domain.startswith('info-tracking') and
domain.endswith('.cc')
):
return True
# Telegram
if (
domain.startswith('telegram-') and
domain.endswith('.com') and
url_path.startswith('/login/index.html')
):
return True
# Bet365
if (
domain.startswith('bte') and
domain.endswith('.com') and
url_path.startswith('/home')
):
return True
# Webmail
if (
url_path.startswith('/accounts/19') and
('/messages/' in url_path) and
('/clicks/' in url_path)
):
return True
# Auto return with matched strings
if (
compare(domain, DOMAIN_ENDS, 'endswith') or
compare(domain, DOMAIN_STARTS, 'startswith') or
compare(url_path.rstrip('.~!/'), PATH_ENDS, 'endswith') or
compare(url_path.rstrip('.~!/').lower(), PATH_EQUALS, 'equals') or
compare(url_path, PATH_STARTS, 'startswith') or
compare(url_path, PATH_CONTAINS, 'contains')
):
return True
# =========================================================================
# REMIND: always put these at end because of regex
# Telegram
if (
domain.startswith('telegram') and
domain.endswith('.com') and
re.match(r'telegram[a-z]{2}\.com$', domain)
):
return True
# Facebook
if (
url_path.startswith('/help/contact/') and
re.match(r'^\/help\/contact\/\d{15,17}\b', url_path)
):
return True
# Bet365
if (
domain.endswith('.com') and
re.match(r'^bet\d', domain)
):
return True
# .cc
if re.match(r'^\d+\.(?:cc|com)$', domain):
return True
# Steam
if (
domain.startswith('steam.') and
len(domain.split('.')) >= 3
):
return True
if (
not domain.startswith('st') and
not domain.startswith('sc')
):
return False
if (
not domain.endswith('.com') and
not domain.endswith('.ru')
):
return False
if re.match(r'^s[ct]y?[ace][aemn][a-z]{1,4}o[mn][a-z]{4,8}[iy][a-z]?\.(?:com|ru)$', domain):
return True
return False
def print_domain(domain: str, url_path: str):
if (
not domain.endswith('.top') and
not domain.endswith('.icu') and
not domain.endswith('.github.io') and
not domain.startswith('usps.com-') and
len(url_path) == 3
):
print(domain + url_path)