CLI tool for Detecting SQL Injections
Project description
SQShield: SQL Injection Detection Tool
SQShield is a command-line tool designed to detect potential SQL injection (SQLi) attacks in your queries. It leverages a custom-trained machine learning model to classify queries as either malicious or benign, helping you secure your applications against common database threats.
Features
- SQLi Detection: Classifies SQL queries to identify potential injection attacks.
- Easy to Use: Simple and intuitive command-line interface.
- Detailed Reporting: Provides a detailed feature report for in-depth query analysis.
- Lightweight: Minimal dependencies and a small footprint.
Installation
You can install SQShield directly from this repository.
-
Clone the repository:
git clone https://github.com/your-username/sqshield.git cd sqshield
-
Install the package: For development or local installation, use
pipwith the editable flag:pip install -e .
This will install the package and make the
sqshieldcommand available in your shell.
Usage
The primary command is sqshield, which accepts a SQL query string as an argument.
Basic Prediction
To check a query, pass it as an argument:
sqshield "SELECT * FROM users WHERE id = '1' OR '1'='1'"
Expected Output:
Query is MALICIOUS
To check a benign query:
sqshield "SELECT * FROM products WHERE category = 'electronics'"
Expected Output:
Query is BENGIN
Get a Detailed Report
For a more detailed analysis, use the --report or -r flag. This shows the feature vector used by the model for its prediction.
sqshield "SELECT * FROM users" --report
Expected Output:
query_length ... semicolon_count
19 ... 0
(Note: The output will be a full DataFrame representation of the query's features.)
Check Version
To display the installed version of SQShield, use the --version or -v flag:
sqshield --version
Expected Output:
sqshield version : 0.1.0
How It Works
SQShield processes each input query by extracting a set of lexical features. These features, which include query length, keyword counts (e.g., SELECT, UNION), special character frequencies, and structural properties, are fed into a LightGBM classification model trained specifically on SQL query patterns. The model then predicts whether the query is MALICIOUS or BENGIN.
The model (sql_injection_model.pkl) is included with the package.
Contributing
Contributions are welcome! If you have suggestions for improvements or find any bugs, please feel free to open an issue or submit a pull request.
- Fork the repository.
- Create a new feature branch (
git checkout -b feature/your-feature). - Commit your changes (
git commit -m 'Add some feature'). - Push to the branch (
git push origin feature/your-feature). - Open a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sqshield-0.1.1.tar.gz.
File metadata
- Download URL: sqshield-0.1.1.tar.gz
- Upload date:
- Size: 132.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b9d7c3ab60f4f32940f8eb652a25c0b0d3f558afeced7fc155859374b4b8f06
|
|
| MD5 |
18c53fb0088b816a64d1ec947fbc870f
|
|
| BLAKE2b-256 |
f07867ae3d5432cbe7427871fecbc6cea95d98cdb91a8454c31f79dada9355b2
|
File details
Details for the file sqshield-0.1.1-py3-none-any.whl.
File metadata
- Download URL: sqshield-0.1.1-py3-none-any.whl
- Upload date:
- Size: 131.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e030374fb7e0b670352c3ca20d587ce05418862586871638a63db52d983b0a7
|
|
| MD5 |
3bcf2f864efcf39712ae694120a8947e
|
|
| BLAKE2b-256 |
c66f26d9cf793636d18329208c819aff177b1114a1bae7d260be2f662233e359
|