Decision tree based AI model that detects malicious actions on the network and adds them to a blacklist. This model utilizes the classification and regression trees (CART), utilizing the Gini Index as the measure of impurity. The model has an accuracy of 94.5%.
The program utilizes python3.6 to run the model. The python libraries needed are as follows:
Also needed is an API-key for the IPInfoDB API. This can be obtained here.
-
Clone or download this repo to a folder on the machine of your web server.
-
Copy the
ip-blacklist.conf
file to the configuration directory of your server: For Apache2 web servers:/etc/apache2/
For HTTPD web servers:/etc/httpd/
-
Include the
ip-blacklist.conf
file in the main.conf
file, whose location is specified in step 2. Apache2 conf:apache2.conf
HTTPD conf:httpd.conf
-
Enable the combined log format for access logs located within the main
.conf
file in your system. More detailed instructions can be found here on how to enable this log format. -
Edit the
main.py
file (located in the folder of the cloned repo) and include the path of the following files your your system:- Access Log File: e.g.
accessLogPath = '/var/log/apache2/access_log'
- CSV file for the blacklist (Entire working directory of the
/files/iplist.csv
file) : e.g.ipBlackListCsv = "/your_directory/files/iplist.csv"
- Key for the IPInfoDB API. e.g.
ipDBkey = "1234567891011121314151617181920"
- Location of the
ip-blacklist.conf
file placed in step 2. e.g.ipBlackListConf = "/etc/apache2/ip-blacklist.conf"
- Access Log File: e.g.
-
Edit the
script1.sh
file in the cloned repo and replace thepython3.6 main.py
command to include the entire location path for themain.py
file. For example the new line will bepython3.6 /your_directory/main.py
. Also edit the: > ACCESSLOGPATH
line to include the path for the access log of your system. For example the command would be ': > /var/log/httpd/access_log'. The last lineservice httpd restart
is set up for httpd server by default. If you use an apache server, replace this line with the restart command for the apache server. -
The initial set up is now complete. You can schedule the running of the
script1.sh
file through the use of the cron scheduler. To learn more about the cron scheduler click here.