/Automated-Vulnerability-Scanning-with-Agentic-AI

The system consists of multiple AI agents that collaborate to strategize, generate commands, and execute scans based on the client's description, without the need for human intervention.

Primary LanguagePythonMIT LicenseMIT

Automated Vulnerability Scanning with Agentic AI

This project demonstrates an automated vulnerability scanning system using an Agentic AI approach. The system consists of multiple AI agents that collaborate to strategize, generate commands, and execute scans based on the client's description, without the need for human intervention.

Please note that this project serves as a rough proof of concept, and not everything might work seamlessly. It's important to keep in mind that commands or scripts that are interactive and require user input, such as msfconsole, may not function as intended within this framework.

Prerequisites

Before running this project, it is recommended to install the kali-linux-default metapackage, which includes a set of tools commonly used for penetration testing and vulnerability scanning. To install the metapackage, follow these steps:

  1. Update your Kali Linux system:

    sudo apt update
    sudo apt full-upgrade -y
    
  2. Install the kali-linux-default metapackage:

    sudo apt install -y kali-linux-default
    

Alternatively, you can use kali-tweaks to install the metapackage:

  1. Run kali-tweaks
  2. Navigate to the "Metapackages" tab
  3. Select the desired metapackages (e.g., kali-linux-default)
  4. Click "Apply" and then "OK"
  5. Supply your password when prompted

For more information on Kali Linux metapackages, refer to the official documentation.

OpenAI API Requirement

This project requires an OpenAI API key to function properly. The code is currently configured to use the gpt-4-turbo model, but you can modify it to use any other available model. To obtain an API key:

  1. Sign up for an account at OpenAI if you haven't already.
  2. Go to the API Keys page in your account dashboard.
  3. Click on "Create new secret key" and copy the generated key.
  4. Set the API_KEY variable in the main.py file to your OpenAI API key.

Please note that using the OpenAI API incurs costs based on the number of tokens processed. Make sure to review the pricing and set up appropriate limits and monitoring for your usage.

WARNING

Please be aware that this script will execute commands on the system without prompting for authorization. Running this script implies that you grant permission for all commands suggested by the amazing Ammar. Exercise caution and ensure that you fully understand the implications before proceeding.

Note: This project is designed to run on Linux.

Overview

The vulnerability scanning process is automated through the coordination of several AI agents, each with specific roles and responsibilities:

  • Ammar: Generates the initial strategy and provides input when needed.
  • Hassan: Reviews strategies, command outputs, and the final report.
  • Kofahi: Handles error scenarios and suggests fixes.
  • Rakan: Monitors the command execution output and determines if additional input is required.
  • Salah: Executes the commands generated by the agents.
  • Sajed: Generates the final findings report.

The agents communicate with each other, exchanging information and feedback to iteratively refine the scanning process until a satisfactory result is achieved.

Flowchart

diagram

Usage

python main.py

The scanning process will continue until a satisfactory result is achieved or if the agents determine that no further actions are required. The findings and outputs will be logged and stored in the Logs directory.

A findings report is generated at the end in markdown format.

Findings Report

The findings_report.md file, generated by Sajed, provides a comprehensive overview of the vulnerability scanning results.

Configuration

The main configuration options can be found in the main.py file:

  • target_ip: Specify the target IP address for the vulnerability scan.
  • scan_description: Provide a description of the desired scan to guide the agents.

Logging

The system generates log files in the Logs directory, capturing the outputs, findings, and agent interactions during the scanning process.

Why an Agentic AI Approach Was Used

Recent research has demonstrated promising results in utilizing multi-agent systems based on Large Language Models (LLMs) for solving various complex tasks[1]. The agentic AI approach, where multiple autonomous agents collaborate to strategize, generate commands, and execute scans, offers several key benefits over relying on a single AI agent:

  1. Specialization and division of labor: Each agent in the system can specialize in a particular area (e.g., strategy generation, error handling, command execution), allowing them to develop deep expertise and perform their roles more effectively[1][2]. This division of labor mirrors how human teams tackle complex projects.

  2. Improved collaboration and problem-solving: By enabling interactions and information sharing between diverse specialized agents, the overall system gains enhanced capabilities to understand requirements, decompose problems, explore multiple solutions, and adapt to changing conditions[1][3]. This collaborative approach has been shown to boost problem-solving accuracy and efficiency.

  3. Robustness and adaptability: With multiple agents involved, the system can be more robust to errors or limitations of any single agent[3]. If one agent struggles, others can help compensate. Moreover, the multi-agent system can dynamically adjust roles, goals, and plans based on feedback and changing circumstances[1].

  4. Scalability: The agentic AI approach provides a scalable framework for tackling increasingly complex and open-ended problems that would overwhelm a single agent[1]. New specialized agents can be added to expand the system's capabilities as needed.

  5. Alignment with real-world problem-solving: Many real-world tasks, like vulnerability scanning, intrinsically involve multiple parties (e.g., scanners, strategists, reviewers) working together. The multi-agent approach more closely mirrors this reality compared to a single generalist agent[2].

While research on agentic AI systems is still in early stages, results so far point to their potential to enable more sophisticated, flexible, and effective problem-solving than single-agent approaches. As the technology matures, agentic AI could become an increasingly powerful paradigm to tackle complex challenges in cybersecurity and beyond.

Citations:

[1] Chen, Y., Perez, Y., & Shoham, Y. (2023). AgentVerse: Facilitating Multi-Agent Collaboration and Exploring Emergent Behaviors in Agents. arXiv preprint arXiv:2308.10848. https://arxiv.org/abs/2308.10848

[2] Quan, A., Jiang, L., Bing, L., & Lyu, M. R. (2023). Communicative Agents for Software Development. arXiv preprint arXiv:2307.07924. https://arxiv.org/abs/2307.07924

[3] Navigating Complexity: Orchestrated Problem Solving with Multi-Agent LLMs. (2024). https://arxiv.org/abs/2402.16713

Differences Between This Project and Automatic Vulnerability Scanners

  1. Multi-agent collaboration: This project uses multiple specialized AI agents that work together, while most scanners are monolithic systems.

  2. Adaptability: The agents iteratively refine the scanning strategy based on feedback and results, while traditional scanners follow a fixed, linear process.

  3. Natural language understanding: The agents can interpret natural language descriptions to guide the scanning process, while scanners typically require structured configurations.

  4. Contextual decision-making: The agents consider the context and results of each step to make decisions, while scanners simply execute a predefined set of checks.

This project leverages the context of previous scan results to determine the next logical scan to perform. The agents, particularly Hassan, review the output of each command and provide feedback on whether the results are satisfactory or if additional scans are needed. This iterative, context-aware approach allows the system to dynamically adapt the scanning process based on the findings at each stage, ensuring a more comprehensive and targeted vulnerability assessment.

Disclaimer

This project is intended for educational and research purposes only. The authors and contributors are not responsible for any misuse or damage caused by the use of this system. Always obtain proper authorization before performing vulnerability scans on any target system.