Skip to content

kowsik11/SQL_Injection_Detection_System

Repository files navigation

🔐 SQL Injection Detection System 💻

This project focuses on developing a SQL Injection Detection System to safeguard web applications from SQL Injection attacks. SQL Injection is a common and dangerous security vulnerability that allows attackers to manipulate SQL queries to execute malicious commands on the database. This system detects and prevents SQL injection attacks in real-time by analyzing user inputs and applying machine learning techniques to identify malicious patterns.

📑 Table of Contents

📝 Project Description

The SQL Injection Detection System aims to detect and mitigate SQL injection attacks in web applications. By leveraging machine learning algorithms and input validation techniques, the system detects harmful SQL queries and prevents unauthorized access to the database. The system can identify potential attacks by analyzing user input patterns and flagging suspicious activity before it reaches the database.

🔑 Key Features:

  • Real-Time Detection: Identifies and flags SQL injection attempts in real-time.
  • Machine Learning-Based Approach: Uses machine learning models to detect malicious SQL queries and patterns.
  • Input Validation: Validates user inputs to ensure they are free from malicious SQL injection content.
  • False Positive Minimization: Minimizes false positives by using advanced detection algorithms.
  • Web Application Security: Enhances web application security by preventing unauthorized database access.

🧠 Features of the System

  • Input Sanitization: Filters user input for malicious characters or keywords commonly used in SQL injection attacks.
  • SQL Injection Detection: Analyzes SQL queries for suspicious patterns and flags potentially harmful ones.
  • Machine Learning Models: Trains classifiers on a dataset of SQL injection and normal queries to identify malicious inputs.
  • Real-Time Monitoring: Continuously monitors web requests to detect SQL injection attempts in real time.
  • Database Protection: Safeguards the database by blocking harmful queries before they reach it.

🔧 Technologies Used

  • Programming Language: Python
  • Machine Learning: Scikit-learn
  • Libraries: Pandas, NumPy
  • Web Framework: Flask (for demo web application)
  • Database: SQLite (for storing logs and detected queries)
  • Input Sanitization: Regular expressions, String Matching techniques
  • Deployment: Docker (for easy deployment)

🚀 How to Run

📥 Prerequisites

Ensure you have the following installed:

  • Python 3.x
  • Flask (for demo app)
  • Required libraries listed in requirements.txt

⚙️ Installation Steps

  1. Clone the repository:

    git clone https://github.com/your-username/sql-injection-detection.git
    cd sql-injection-detection
    
  2. Install the required dependencies: pip install -r requirements.txt

  3. Train the machine learning model: python train_model.py

  4. Run the Flask web application: python app.py

  5. Open the web application in your browser and test the SQL injection detection by entering sample inputs, including malicious SQL queries.

  6. View the detected SQL injection attempts and flagged inputs in the system logs.

🧠 Model Details

Text Preprocessing

  • Tokenizes and cleans input data by removing special characters, SQL keywords, and potential attack vectors.

Feature Extraction

  • Extracts features from SQL queries, such as the presence of SQL-specific keywords like DROP, SELECT, OR 1=1, etc.

Model Selection

Several machine learning classifiers are tested, such as:

  • Random Forest: Used for its ability to classify complex data patterns.
  • Support Vector Machine (SVM): Effective in detecting malicious patterns in input data.
  • Naive Bayes: For probabilistic classification of SQL queries.

Evaluation Metrics

  • Accuracy, Precision, Recall, and F1-score are used to evaluate the performance of the detection system.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published