Minor
Minor
INJECTION DETECTION
BACHELOR OF TECHNOLOGY
(Information Technology)
The increasing frequency and severity of SQL injection attacks have made web application
security a top priority for organizations. This project, SQL-Guard: Automated SQL
Injection Detection is designed to analyze web request data and automatically detect
potential SQL injection attacks. Implemented using Flask, this tool allows users to upload
network request logs in CSV format and then analyzes them for common SQL injection
patterns. The tool extracts useful details such as source IP addresses, the count of detected
SQLi attempts, the first and last malicious requests, and potential payload formatting
issues.
Through this project, we aim to contribute a lightweight yet effective defense mechanism to
bolster web application security against SQL injection threats. The scope of this tool can
be extended further to incorporate detection of other web attacks such as XSS or CSRF,
and can potentially integrate with real-time security monitoring systems.
1
ACKNOWLEDGEMENT
We are highly grateful to Dr. Sehijpal Singh, Principal, Guru Nanak Dev Engineering
College (GNDEC), Ludhiana, for providing this opportunity to carry out the minor project
work at the campus.
The constant guidance and encouragement received from Dr. K.S. Maan, H.O.D., IT
Department, GNDEC Ludhiana, has been of great help in carrying out the project work
and is acknowledged with reverential thanks.
We would like to express a deep sense of gratitude and thanks profusely to Dr.Sachin Bagga
, without his wise counsel and able guidance, it would have been impossible to complete
the project in this manner.
Finally, we are indebted to all whosoever have contributed in this report work.
Rajanjot Singh
Rahul Sharma
Manjot Singh
2
LIST OF FIGURES
3
TABLE OF CONTENTS
Abstract i
Acknowledgement ii
List of Figures iii
Table of Contents iv
4
CHAPTER 1: INTRODUCTION
Developed using Python and the Flask web framework, SQL-Guard provides a lightweight and
user-friendly interface for detection without the need for complex setup or database integration.
This makes it especially suitable for educational institutions, small businesses, or individual de-
velopers who require basic protection but lack access to advanced commercial intrusion detection
systems.
Through automation and simplicity, this project aims to minimize human error, reduce analysis
time, and provide a foundation for future integration with more advanced monitoring tools and
machine learning systems. Ultimately, SQL-Guard is not only a practical utility for basic SQL
injection detection, but also a stepping stone for further exploration into web application security.
5
1.2 Objectives
1. To extract and analyse attack data by identifying the attacker’s IP and counting SQL
injection attempts to improve cybersecurity monitoring and response..
2. To automate SQL Injection detection by creating a Python tool that scans network logs
(CSV files) to find attacks making threat detection faster for SOC (Security Operations
Centre) analysts.
6
1.3 Problem Formulation
Web applications are increasingly becoming the backbone of modern business operations, offering
services that range from e-commerce to online banking. However, this convenience comes with a
significant security risk—SQL Injection (SQLi), one of the most prevalent and dangerous forms
of web-based attacks. SQLi allows malicious actors to manipulate database queries by injecting
specially crafted inputs, which can result in unauthorized data access, modification, or deletion.
Traditional methods of detecting SQL injection attacks often rely on manual inspection of server
logs or the deployment of complex, enterprise-level intrusion detection systems. These approaches
are either time-consuming, error-prone, or financially unfeasible for smaller organizations and
developers.
The core problem, therefore, is the lack of an accessible, automated, and easy-to-use tool that
can efficiently detect SQL injection attempts from web server logs or request data. Without such
a tool, there is a risk of delayed detection, data breaches, and compromised systems.
This project aims to solve this problem by developing a lightweight, web-based solution—SQL-
Guard—that automates the process of detecting potential SQL injection payloads from uploaded
CSV logs. By providing a simple interface and using pattern-matching techniques, SQL-Guard
enables users to perform preliminary security analysis quickly and without requiring advanced
cybersecurity expertise.
One of the most common ways hackers try to break into websites is through SQL Injection attacks.
In this type of attack, the hacker enters special code into input fields (like login boxes or search
bars) to trick the website into revealing or changing data in the database. This can lead to serious
problems like leaking passwords, deleting information, or even taking full control of the website.
Even though SQL injection is a well-known threat, many small organizations or student projects
do not have advanced tools or professional security experts to protect their websites. They may
not be able to afford costly security systems or spend time manually checking server logs for signs
of attacks.
7
Because of this, there is a need for a simple, low-cost tool that can help detect SQL injection
attacks automatically. The tool should be easy to use, even for beginners, and should not require
deep technical knowledge.
Our project, SQL-Guard, was created to solve this problem. It lets users upload logs in CSV
format and automatically checks for suspicious SQL injection patterns. This makes it easier for
students, small teams, or anyone managing a web application to spot possible security issues early
and take action before any damage is done.
The main idea of the proposed system is to make SQL injection detection fast, automated, and
user-friendly. It is especially helpful for students, small businesses, and developers who may not
have access to professional tools or cybersecurity experts.
How it works:
• The system scans each request for suspicious patterns and keywords that are commonly
used in SQL injection attacks (like SELECT, DROP, UNION, OR 1=1, –, etc.).
• Once the scan is complete, the system shows the results on a clean and simple webpage.
This includes the number of suspicious requests, their details (IP address, payload, etc.),
and when they were first and last seen.
• The system is built using Flask, a lightweight Python web framework, and does not require
a database to run, which keeps it fast and easy to deploy.
8
Main Features of the Proposed System:
• Provides detailed insights like attack count, source IP, and suspected payloads.
The goal of the proposed system is to offer a low-cost, quick-to-use solution for identifying SQL
injection attacks and improving the overall security awareness of users managing web applications.
It acts as a stepping stone for better protection and encourages safe coding practices.
• Automatic SQL Injection Detection: The system can automatically scan uploaded
CSV files and detect potential SQL injection attempts using pattern matching, without
any manual effort.
• Simple Web Interface: The user interface is clean and easy to use. Users can upload
files and view results within seconds. No command-line knowledge is needed.
• Lightweight and Fast: Built with Python and Flask, the application runs quickly and
uses minimal system resources. It can be hosted locally or on the cloud with ease.
• Detailed Report Generation: After analyzing the CSV file, the system shows useful
details such as:
9
• Beginner-Friendly: No advanced setup is required. The tool is designed to help students,
developers, and small teams who may not be security experts.
• Open Source and Customizable: The system is developed using open-source technolo-
gies and can be modified or expanded easily for future use or learning purposes
10
CHAPTER 2: Requirement Analysis and System
Specification
a) Technical Feasibility
• The SQL-Guard project is technically feasible and can be implemented using simple and
proven technologies. The main components of the system include the Python programming
language, Flask web framework, and built-in or lightweight libraries like csv, re (regular
expressions), and pandas.
• These tools are well-documented, reliable, and widely supported across platforms, making
them an excellent choice for developing a security analysis tool. The system performs
pattern matching to identify SQL injection attempts in uploaded log files, and this task
does not require complex algorithms or heavy processing power.
• Furthermore, the system does not require any database, which simplifies the architecture
and reduces technical dependencies. It can be easily run on any standard computer without
special hardware, making it technically practical for small teams, educational institutions,
or individual developers.
b) Economic Feasibility
• The hardware requirements are minimal, and the application can be run on existing sys-
tems or hosted on free/low-cost cloud platforms if needed. As a result, the overall cost of
development and deployment is very low.
11
helps prevent attacks earlier, and minimizes potential damage, thus saving money in the
long run..
c) Operational Feasibility
• From an operational perspective, the system is designed to be simple, efficient, and easy to
use. It has a user-friendly web interface that allows users to upload a log file and view the
analysis results immediately. There is no need for deep technical knowledge, which makes
the system accessible to both beginners and experienced users.
• The tool can be smoothly integrated into existing security workflows, especially in environ-
ments where log analysis and threat monitoring are already taking place. SOC analysts
and developers can use this system to quickly identify suspicious SQL injection attacks,
generate reports, and take action accordingly.
• Since the tool does not require complex installation or setup, it can be used immediately
after deployment with very little training. Its lightweight design ensures it can run efficiently
without interfering with other systems or requiring constant maintenance.
12
2.2.2 Software Requirements
Component Specification
Operating System Windows 10/11, Linux, or macOS
Programming Language Python 3.8 or above
Web Framework Flask (Python-based web framework)
Libraries/Packages pandas, csv, re, flask
Text Editor / IDE Visual Studio Code / PyCharm / Sublime
Web Browser Chrome, Firefox, or Edge (latest version)
This setup ensures that the system is accessible to users with basic computing environments,
making it a practical tool for students, developers, and small organizations alike.
• The system shall allow the user to upload a .CSV file containing web traffic logs or
HTTP request records.
• The uploaded file should be validated for format and size before processing.
• The system shall scan each entry in the CSV file for suspicious patterns and SQL
keywords (such as SELECT, DROP, OR 1=1, –, etc.).
• Pattern matching will be done using regular expressions to identify potential SQL
injection attacks.
3. Display of Results
• The system shall display the following results on the web interface:
13
– Number of detected suspicious entries
4. User Interface
• The system shall provide a user-friendly web interface using HTML templates rendered
via Flask.
• The interface will include pages for uploading files, viewing results, and navigating
through detected threats.
• The system shall validate user input to prevent incorrect file types or malicious files
from being processed.
6. No Database Integration
• The system shall not use any database. All processing is performed in-memory during
the session.
• Results are displayed immediately after processing, and no data is stored permanently.
• The system may include an option to export the detection report as a downloadable
text or CSV file (optional enhancement).
8. Platform Compatibility
• The system shall be compatible with major browsers and operating systems.
14
• Input Validation
– The system checks whether the uploaded file is in the correct format (.csv).
– If an unsupported file format is uploaded (e.g., .txt, .pdf), the system displays an error
message.
– The file is also checked for empty rows or missing values to avoid processing errors.
– Example:
• Functional Validation
Each core feature of the system is validated to ensure it works as intended:
– Pattern Matching: Verified using test cases with known SQL injection payloads (e.g.,
”OR 1=1”, ”DROP TABLE”)
– Detection Output:Confirmed that suspicious entries are correctly flagged and displayed
– A set of sample log files (with both safe and malicious entries) were tested.
– The tool was expected to detect all malicious payloads while ignoring safe entries.
– The output was reviewed to ensure there were no false positives or negatives (within
the limits of pattern-based detection).
– All elements (upload button, result section, error messages) were verified for proper
functioning.
• Boundary Testing
– The system was tested with very small and very large CSV files to ensure stability.
– It handled large files with several hundred lines without crashing or freezing.
• Manual Cross-Check
– Outputs from the tool were cross-verified with manual inspection of the same CSV
data.
– This helped ensure that the tool correctly highlights genuine SQL injection patterns.
15
• No Persistent Data Validation
– Since the tool does not store data, it was verified that uploaded files are not saved
and results disappear after session ends.
After multiple rounds of testing, SQL-Guard was found to meet its functional and usability goals.
While advanced AI/ML-based detection could improve accuracy further, the current implemen-
tation effectively serves its purpose as a lightweight detection tool.
– Mitigation Strategy:
∗ Refine regular expression patterns based on common and evolving SQLi tech-
niques.
– Challenge: The system currently scans only predefined patterns and may not recognize
newer or less common SQL injection methods.
– Mitigation Strategy:
– Challenge: Processing very large CSV files with thousands of rows may slow down the
system or cause memory issues.
16
– Mitigation Strategy:
∗ Set file size limits and alert users if the input exceeds optimal limits.
• No Real-Time Detection
– Challenge: SQL-Guard is a passive detection tool that analyzes logs offline, not real-
time traffic.
– Mitigation Strategy:
∗ Suggest integration into a pipeline that periodically exports server logs for auto-
mated analysis.
– Challenge: Users may upload the wrong file format, corrupted files, or files with
missing data.
– Mitigation Strategy:
∗ Display user-friendly error messages and input guidelines on the upload page.
17
CHAPTER 3: SYSTEM DESIGN
• To create a lightweight and efficient tool for detecting SQL injection patterns in log files.
• To keep the system easy to maintain, test, and extend in the future.
• To ensure the system works without the need for a backend database or complex deployment
infrastructure.
• Provides a simple upload form for the user to select and submit a CSV file.
• Displays the analysis results, including number of attacks detected, IP addresses, and
patterns found.
• Parses the file and extracts relevant fields such as IP address, request content, and
timestamps.
3. Detection Engine
• Uses regular expressions (regex) to scan each request for known SQL injection key-
words and patterns (e.g., ’OR 1=1’, ’–’, ’DROP’, ’UNION’).
4. Result Generator
18
• Displays metrics such as total suspicious entries, IP addresses involved, and first/last
occurrence.
• Developed using HTML and styled with CSS, the UI provides a clean and user-friendly
experience.
• Displays the results of SQL injection detection in a structured and readable format.
• This component is responsible for validating and securely handling uploaded files.
• It checks the file format (ensures it is .csv) and handles errors such as missing files or
unsupported formats.
• Once validated, the file is passed on to the detection engine for analysis.
3. CSV Parser
• Reads the uploaded CSV file and extracts relevant data such as:
– IP addresses
– Timestamps
• Ensures data is properly formatted and handles missing or corrupted entries gracefully.
19
4. SQL Injection Detection Engine
• Uses a set of predefined regular expression (regex) patterns to scan for common SQL injec-
tion indicators (e.g., OR 1=1, –, SELECT, UNION, DROP),
5. Result Generator
– Suspicious payloads
• Manages routing (e.g., file upload, results page), handles HTTP requests, and connects
components.
20
• Clear and Readable Output:
The results should be presented clearly, showing:
• Browser Compatibility:
Users should be able to access the tool on any modern web browser such as Chrome, Firefox,
or Edge.
The interface is built using standard web technologies such as HTML, CSS, and Flask’s Jinja2
templating engine.
Key UI Elements:
21
∗ Upload button
• Validation Messages
– If the user tries to upload an invalid file (e.g., wrong format, empty file), the system
shows an error message.
– Example:
• Result Page
• Digital bill.
Admin Side
• Login-protected dashboard.
22
3.5 Flowchart
3.6 Methodology
The methodology outlines the systematic process followed in the design, development, and testing
of the SQL-Guard project. A structured methodology ensures that the system meets its goals,
works reliably, and can be easily maintained or improved in the future.
Step-by-Step Workflow:
1. Requirement Gathering: In the initial phase, we identified the core needs of users,
especially system administrators and security analysts. We gathered requirements such as:
23
• Keeping the interface simple
2. System Analysis: After defining the problem, we analyzed how SQL injection attacks
work, studied common patterns, and explored how such attacks appear in HTTP traffic or
log files. This helped us determine the key features the system must have and guided the
design of the detection engine.
3. System Design: We created the architecture of the system by dividing it into modular
components:
• CSV Parser
5. Testing and Validation: We created test cases with both malicious and clean log data
to evaluate the accuracy and performance of the detection engine. We validated:
• Detection reliability
• Result accuracy
• Interface usability
24
CHAPTER 4:RESULTS AND DISCUSSIONS
Workflow
1. Upload Page (Home Interface)
It allow the user to upload a CSV file containing HTTP request logs.
25
4.2 Module Description
Technologies Used
• Python 3
• Flask
• HTML
• CSS
• re (Regular Expressions)
• csv module
26
CHAPTER 5:CONCLUSIONN AND FUTURE SCOPE
Conclusion
• In this project, we designed and developed SQL-Guard, a lightweight and user-friendly tool
for detecting SQL injection attempts from HTTP request logs in CSV format. SQL injection
remains one of the most critical and commonly exploited vulnerabilities in web applications,
and SQL-Guard provides a practical solution for identifying such threats without the need
for complex infrastructure or deep technical expertise.
• The application successfully allows users to upload CSV log files and automatically scans
each entry using pattern-matching techniques to detect suspicious SQL keywords and pay-
loads. Built using Python and Flask, the system ensures ease of use, portability, and quick
deployment across various platforms.
• SQL-Guard achieves its goal of making security analysis more accessible and highlights the
importance of proactive measures against web-based attacks
Future Scope
• Future versions can integrate with live server logs or proxy tools to enable real-time SQL
injection detection instead of only static CSV file analysis.
• Adding features to export results as PDF/CSV and providing a visual dashboard can en-
hance usability and help users maintain security records more effectively.
27
Bibliography
• OWASP Foundation, “SQL Injection,” OWASP Top 10 Web Application Security Risks.
[Online]. Available: https://owasp.org/www-community/attacks/SQL_Injection.
28