Block-Bad-IP

Block-Bad-IP is intelligent system to reduce possibility abuse online systeme.

Download Version 1.0.0.1
Quelltext auf GitLab


Cyber attacks often begin by looking for vulnerabilities that can be exploited remotely, e.g. in web servers or other online services such as VPN, remote desktop, SSH etc. Scanners try to find known vulnerabilities or weak passwords. Most of these attempts leave traces in log files. Block-Bad-IP (further bbip) recognizes these anomalies in log files and blocks IP addresses of these scanners. Another method to identify scanners is honeypot. bbip opens the ports of popular online services. Any IP address trying to connect to the port will be blocked because these are the scanners looking for vulnerabilities. To avoid false alarms bbip has lists with trusted IP addresses and FQDN e.g. for known web crawlers. Besides detecting a scanner, bbip can prevent over usage.

For blocking used iptables /usr/sbin/iptables. If an IP address is identified as a scanner (further “Bad IP”), it will be blocked for an hour. Blocked for a day the second time. Blocked for a week on the third time or more. If Bad-IP does not occur again for two weeks, then this IP will be removed from the database.

Structure of the application

/usr/local/bin/bbip - the executable. Start parameters:

/usr/local/bin/bbipd - the start script. Start parameters: start|stop|status|restart

/etc/bbip/setvar - the configuration file for the start script.

/etc/bbip/trusted-dns.txt - the list of regular expressions (patterns) for trusted FQDN. All Bad-IP via DNS will be converted to FQDN and checked whether this one is in the list. E.g. ”.yandex.ru$” all FQDN ending with “.yandex.ru” are ignored.

/etc/bbip/trusted-ip.txt - the regular expression list (pattern) for trusted IP addresses. E.g. “^95.223.75.”- all IP addresses starting with 95.223.75, will be ignored.

Configuration file

Sample scanner detection based on patterns in the Apache log file.

<logfilerule>
    <name>Web scanner 1</name>
    <logpath>/var/log/httpd/access.log</logpath>
    <error>" [4,5]\d\d \d{1,3} ".*$</error>
    <exclude>robots.txt</exclude>
    <ip>(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) </ip>
    <timesmax>1</timesmax>
    <interval>2</interval>
    <enable>true</enable>
    </logfilerule>

Honeypot example.

<honeypotrule>
    <name>Microsoft RDP Server</name>
    <bind>127.0.0.1:3389</bind>
    <enable>false</enable>
    </honeypotrule>

See /etc/bbip/config-example for more examples.

Configuration parameters

Configurationsparameter for monitoring logfile

Konfigurationsparameter for monitoring online-service


Copyright (c) 2021, Andrej Koslov. Distributed under BSD-3 License