Commit d47dbb44 authored by Gamage G.G.I.V.M's avatar Gamage G.G.I.V.M

Delete vuln1.py

parent 84f0ded7
import sqlite3
# Function to create the vulnerabilities table
def create_vulnerabilities_table():
vulnerability_connection = sqlite3.connect("vulnerabilities.db")
vulnerability_cursor = vulnerability_connection.cursor()
# Create the 'vulnerabilities' table with columns for details
vulnerability_cursor.execute('''CREATE TABLE IF NOT EXISTS vulnerabilities
(id INTEGER PRIMARY KEY AUTOINCREMENT,
protocol TEXT,
source TEXT,
destination TEXT,
length INTEGER,
vulnerability_info TEXT)''')
vulnerability_connection.commit()
vulnerability_connection.close()
# Function to detect vulnerabilities and store them in a database
def detect_vulnerabilities():
# Connect to the SQLite database containing captured packets
connection = sqlite3.connect("captured_packets.db")
cursor = connection.cursor()
# Connect to the vulnerabilities database
vulnerability_connection = sqlite3.connect("vulnerabilities.db")
vulnerability_cursor = vulnerability_connection.cursor()
# Protocol to check for vulnerability
target_protocol = 'DATA'
# Query to retrieve packets with the target protocol
query = "SELECT protocol, source, destination, length FROM packets WHERE protocol = ?"
cursor.execute(query, (target_protocol,))
packets = cursor.fetchall()
for packet in packets:
protocol, source, destination, length = packet
vulnerability_info = f"Vulnerability detected: Protocol is '{protocol}', Source: {source}, Destination: {destination}, Length: {length}"
vulnerability_query = "INSERT INTO vulnerabilities (protocol, source, destination, length, vulnerability_info) VALUES (?, ?, ?, ?, ?)"
vulnerability_cursor.execute(vulnerability_query, (protocol, source, destination, length, vulnerability_info))
vulnerability_connection.commit()
connection.close()
vulnerability_connection.close()
# Call the function to create the 'vulnerabilities' table
create_vulnerabilities_table()
# Call the function to detect 'DATA' protocol as a vulnerability and store it
detect_vulnerabilities()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment