Skip to content

Dimont-Gattsu/VulnerabilityScanner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Vulnerability Scanner and Setup

Overview

This repository contains two Python scripts designed to assist in the detection of known vulnerabilities based on system services. The first script, setup.py, sets up a SQLite database and retrieves vulnerability data from the NVD (National Vulnerability Database). The second script, vulnScanner.py, analyzes the Nmap scan results, identifies running services, and cross-references them with the database to detect vulnerabilities.

Files

setup.py

This script performs two main functions:

  1. Database Setup (setup_database):

    • Creates a SQLite database called vulnerabilities.db and a table to store vulnerability information.
    • The table includes fields like CVE ID, description, publication date, CVSS score, and CPE URI (Common Platform Enumeration).
  2. Fetch and Store CVE Data (fetch_and_store_cve_data):

    • Retrieves vulnerability data from the National Vulnerability Database (NVD) API.
    • The data is parsed and stored in the SQLite database.
    • This process includes retry logic for failed API requests, using exponential backoff to avoid overwhelming the server.

To use this script, simply run it to create and populate the database with the latest CVE entries.

Key Steps:

  • Initializes a SQLite database.
  • Fetches data from the NVD API.
  • Saves vulnerability information (e.g., CVE ID, description, CVSS score) into the database.
python setup.py

vulnScanner.py

This script performs vulnerability scanning on a specified host by:

  1. Running an Nmap Scan:

    • Executes an Nmap scan using the -sC and -sV flags, which detect versions of services running on open ports.
  2. Parsing Nmap Output:

    • The XML output from Nmap is parsed to extract service details, such as port number, service name, version, and product information.
  3. Cross-referencing with Vulnerability Database:

    • After extracting service details, it queries the vulnerabilities.db database created by setup.py to find known vulnerabilities related to each service and version.
  4. Displaying Results:

    • The script outputs a detailed list of open ports, services, and associated vulnerabilities (if any).

Key Steps:

  • Runs a Nmap scan against the target host.
  • Extracts service details from Nmap's XML output.
  • Queries the vulnerabilities.db for vulnerabilities related to the identified services.
  • Displays found vulnerabilities for each service.

Usage:

  1. Set Up the Database: Run setup.py to create and populate the vulnerability database.

    python setup.py
  2. Scan for Vulnerabilities: Once the database is set up, use vulnScanner.py to scan your target host. Provide the target IP address as a command-line argument:

    python vulnScanner.py <host_ip>

    Example:

    python vulnScanner.py 192.168.1.10

    This will run an Nmap scan on the specified host and cross-reference the services with the stored vulnerabilities.


Prerequisites

Before running these scripts, ensure you have the following dependencies installed:

  • Python 3.x
  • requests library: For fetching data from the NVD API.
  • sqlite3 library: For database handling (comes pre-installed with Python).
  • xml.etree.ElementTree (for parsing XML data, included with Python).
  • subprocess: Used to execute Nmap from within the script.
pip install requests

Additionally, ensure that you have Nmap installed on your system, as it is required to run the vulnerability scanning portion of the script.


Notes

  • The NVD API is used to fetch vulnerability data, and the script handles retries in case of network or API failures.
  • The Nmap scan checks for open ports and identifies services, versions, and products, which are then cross-referenced with the stored CVE data to detect vulnerabilities.
  • This approach assumes the Nmap output contains version information for services. If a service version is not provided, it will be skipped during the vulnerability check.

Disclaimer This repository is for educational purposes only. It should not be used for malicious intent.

About

Banner grabs and compares to a database of known CVEs. In testing.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages