mirror of https://gitlab.com/bashrc2/epicyon
Additional block check on short domain
parent
8eb659b55b
commit
1caa61c94a
25
blocking.py
25
blocking.py
|
@ -149,20 +149,37 @@ def getDomainBlocklist(baseDir: str) -> str:
|
||||||
globalBlockingFilename = baseDir + '/accounts/blocking.txt'
|
globalBlockingFilename = baseDir + '/accounts/blocking.txt'
|
||||||
if not os.path.isfile(globalBlockingFilename):
|
if not os.path.isfile(globalBlockingFilename):
|
||||||
return blockedStr
|
return blockedStr
|
||||||
with open(globalBlockingFilename, 'r') as file:
|
with open(globalBlockingFilename, 'r') as fpBlocked:
|
||||||
blockedStr += file.read()
|
blockedStr += fpBlocked.read()
|
||||||
return blockedStr
|
return blockedStr
|
||||||
|
|
||||||
|
|
||||||
def isBlockedDomain(baseDir: str, domain: str) -> bool:
|
def isBlockedDomain(baseDir: str, domain: str) -> bool:
|
||||||
"""Is the given domain blocked?
|
"""Is the given domain blocked?
|
||||||
"""
|
"""
|
||||||
|
if '.' not in domain:
|
||||||
|
return False
|
||||||
|
|
||||||
if isEvil(domain):
|
if isEvil(domain):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
# by checking a shorter version we can thwart adversaries
|
||||||
|
# who constantly change their subdomain
|
||||||
|
sections = domain.split('.')
|
||||||
|
noOfSections = len(sections)
|
||||||
|
shortDomain = None
|
||||||
|
if noOfSections > 2:
|
||||||
|
shortDomain = domain[noOfSections-2] + '.' + domain[noOfSections-1]
|
||||||
|
|
||||||
globalBlockingFilename = baseDir + '/accounts/blocking.txt'
|
globalBlockingFilename = baseDir + '/accounts/blocking.txt'
|
||||||
if os.path.isfile(globalBlockingFilename):
|
if os.path.isfile(globalBlockingFilename):
|
||||||
if '*@' + domain in open(globalBlockingFilename).read():
|
with open(globalBlockingFilename, 'r') as fpBlocked:
|
||||||
return True
|
blockedStr = fpBlocked.read()
|
||||||
|
if '*@' + domain in blockedStr:
|
||||||
|
return True
|
||||||
|
if shortDomain:
|
||||||
|
if '*@' + shortDomain in blockedStr:
|
||||||
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue