项目作者: HovhannesTamoyan

项目描述 :
AI based Web Application Firewall
高级语言: PHP
项目地址: git://github.com/HovhannesTamoyan/grad_secure.git
创建时间: 2020-03-01T09:22:15Z
项目社区:https://github.com/HovhannesTamoyan/grad_secure

开源协议:

下载


AI based WAF (Web application Firewall) - GradSecure

This project is commited to the idea of providing security for web developers, by preventing from SQL injections and XSS attacks.

The system uses AI based ML model called RandomForest, with 2Gram CountVectorizer, sklearn models are used to make the overall processe possible. You can also find out the datasets on /vendor/discriminator/data directory.
However if you are not interested in ML part the trained model is already stored in /vendor/discriminator/finalized_model.sav file you can just load it.
You can also find some test(dummy) webapps stored in /web_apps directory, there are web apps writen in: Python(Flask), PHP(Vanila, WP, Laravel) …

Overall Schema

Prerequisite

OS: Linux (tested on Deb and Kali)
Programming Languages: Python3.6.0 >=
Python packages: http.server, requests, pickle, pandas, json, sklearn
WebApp: Any webapp writen in PHP, NodeJS, Python, Ruby etc.

Configurations and setup for details

  1. Download the directory (or clone it) and unzip it anywhere you want, best possible directory can be /var/www/grad_secure
  2. Open grad_secure/config.json and set your configurarions: gradsecurity - where the WAF should be running, webapp - where your web application is running, for example
  1. {
  2. "gradsecurity": {
  3. "protocol": "http",
  4. "host": "127.0.0.1",
  5. "port": "8085"
  6. },
  7. "webapp": {
  8. "protocol": "http",
  9. "host": "127.0.0.1",
  10. "port": "9090"
  11. },
  12. "score_restrictions": {
  13. "gray_client_score_max": 3,
  14. "black_client_score_max": 5,
  15. "days_to_unblock": 20
  16. }
  17. }
  1. Open your web provider service configurations and configure it as required bellow:
    3.1 For Apache2 open, /etc/apache2/000-default.conf , it should be hosting :80 port (if not make sure it does), copy and paste the following lines before closing tag, where xxxx is the port on which grad_secure should be running (use the same port you put on step 2), the second line is used to prevent reverse proxy on the metnioned directory

    1. ProxyPreserveHost On
    2. ProxyPass /xxxx/ !
    3. ProxyPass / http://127.0.0.1:xxxx/
    4. ProxyPassReverse / http://127.0.0.1:xxxx/

    for our example the following should be used

    1. ProxyPreserveHost On
    2. ProxyPass /phpmyadmin/ !
    3. ProxyPass / http://127.0.0.1:8055/
    4. ProxyPassReverse / http://127.0.0.1:8055/

    3.2 For Nginx open, /etc/nginx/sites-available/default , it should be hosting :80 port (if not make sure it does), copy and paste the following lines before “server” s closing currly braces, where xxxx is the port on which grad_secure should be running (use the same port you put on step 2)

    1. location / {
    2. proxy_pass http://localhost:xxxx/;
    3. }

    for our example the following should be used

    1. location / {
    2. proxy_pass http://localhost:8055/;
    3. }
  2. Run the following commands on terminal to activate proxy service, and restart to make changes take place.

    1. sudo a2enmod proxy
    2. sudo a2enmod proxy_http
    3. systemctl restart apache2
  3. Run the following commands to install python3 requirements
    1. sudo chmod +x requirements.txt
    2. ./requirements.txt
  4. Run grad_secure, by opening terminal in the corresponding location and typing
    1. sudo python3 main.py
  5. Run your WebApp on the port you specified on the config.json file