mirror of https://github.com/fail2ban/fail2ban
Enhanced Google domain detection in apache-fakegooglebot
Previously, an attacker could fake a domain like crawl-1-1-1-1.googlebot.com.fake.net and get resolved. This change avoids to resolve fake Google domains.pull/1226/head
parent
7e6964dd9d
commit
74fcb219ab
|
@ -26,7 +26,7 @@ def is_googlebot(ip):
|
||||||
from fail2ban.server.filter import DNSUtils
|
from fail2ban.server.filter import DNSUtils
|
||||||
|
|
||||||
host = DNSUtils.ipToName(ip)
|
host = DNSUtils.ipToName(ip)
|
||||||
if not host or not re.match('crawl-.*\.googlebot\.com', host):
|
if not host or not re.match('crawl-.*\.googlebot\.com$', host):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
host_ips = DNSUtils.dnsToIp(host)
|
host_ips = DNSUtils.dnsToIp(host)
|
||||||
sys.exit(0 if ip in host_ips else 1)
|
sys.exit(0 if ip in host_ips else 1)
|
||||||
|
|
Loading…
Reference in New Issue