A Flask-based machine-learning web application that classifies SQL payloads as SQL Injection or Benign using a TF-IDF vectorizer and Logistic Regression model. The app provides a stylish Bootstrap UI, real-time probability scoring, and an adjustable threshold slider for fine-grained detection.
- Python 3
- Flask
- scikit-learn
- pandas
- Bootstrap 5
- HTML + CSS
SQL-Injection-ML-Detector/
├── app.py
├── SQL_Dataset.csv
├── Payloads.txt
├── requirements.txt
└── README.md
- Python 3.9+
- pip installed
- Any IDE (VS Code recommended)
- Dataset file:
SQL_Dataset.csv - Columns required:
- Query (payload)
- Label (0 or 1)
- flask
- pandas
- scikit-learn
- Loads dataset
- Vectorizes text using TF-IDF (1–2 n-grams)
- Trains Logistic Regression classifier
- Predicts SQL Injection probability for user inputs
- User enters a payload in the UI
- App vectorizes input → ML model
- Model returns:
- SQL Injection (if probability ≥ threshold)
- Benign (otherwise)
- Threshold controlled by slider(0.50–0.99)
- Dark theme
- Modern card layout
- Resizable text area
- Gradient badges for SQLi/Benign
- Smooth user experience
- Clone the repository:
git clone https://github.com/rahul07890-dev/SQL-Injection-Detector-ML.git
- Install the dependencies:
pip install -r requirements.txt
- Ensure dataset is in the same directory as
app.py - Start the Flask server:
python app.py
- Open the application:
http://localhost:5000
- Home Page
- Video Demo
SQLi.mp4
- Machine Learning–powered SQL Injection detection
- Real-time probability scoring
- Adjustable threshold slider
- Clean modern Bootstrap UI
- Fully offline and local
- Easy to customize and extend
- Save trained model using
joblib - Add REST API endpoint (
/predict) - Add Docker support
- Deploy on Render / Railway
- Add logs for prediction activity
- Expand dataset with more SQL payloads
- Pull requests are welcome.
- For major changes, open an issue first.
- scikit-learn documentation
- Bootstrap 5
- Open-source SQL injection datasets

