This script is designed to test multiple websites for vulnerabilities to ensure that their Web Application Firewalls (WAFs) are functioning correctly. It uses OWASP ZAP, sqlmap, nikto and wpscan to perform various security scans. The script is set to run these tests every 10 minutes.
- Kali Linux or another Linux distribution with the necessary tools installed.
- OWASP ZAP installed on your system.
- Python 3 and the following Python packages:
zapv2schedulelogging
-
Install OWASP ZAP:
sudo apt-get update sudo apt-get install zaproxy
-
Install Python Packages:
pip install python-owasp-zap-v2.4 schedule
-
Install sqlmap and nikto:
sudo apt-get install sqlmap nikto
-
Install WPScan:
sudo gem install wpscan
-
Update the target URLs: Edit the
TARGET_URLSlist in the script to include the websites you want to test. -
Update the ZAP API key: Set your OWASP ZAP API key in the
ZAP_API_KEYvariable.
-
Ensure ZAP is not already running: Make sure there are no other instances of OWASP ZAP running.
-
Run the Script:
python waf_test_script.py
The script will start OWASP ZAP, check its status, and then proceed to run security scans on each target URL using OWASP ZAP, sqlmap, nikto, w3af, and wpscan. The results are logged to both the console and a log file (waf_test.log).
start_zap(): Starts OWASP ZAP in daemon mode.check_zap_status(): Checks if OWASP ZAP is running and ready.run_zap_scan(target_url): Runs an active scan using OWASP ZAP on the specified target URL.fetch_zap_results(target_url): Fetches the results of the ZAP scan.run_sqlmap(target_url): Runs sqlmap against the specified target URL.run_nikto(target_url): Runs nikto against the specified target URL.run_wpscan(target_url): Runs wpscan against the specified target URL.test_waf(): Orchestrates the entire testing cycle for all target URLs.
The script uses the schedule library to run the test_waf function every 10 minutes. You can adjust the frequency by modifying the scheduling line in the script.
The script logs its actions and results to both the console and a log file (waf_test.log). This helps in monitoring the script's progress and diagnosing any issues.
- ZAP is not starting: Ensure no other instances of ZAP are running and that the correct API key is used. In some cases the api url for zap may be 8082 or different, If you encounter problems just open ZAP and check this manually.
- Script hangs or crashes: Check the log file (
waf_test.log) for detailed error messages and ensure all dependencies are installed correctly.