UNIVERSITY OF WEST ATTICA
SCHOOL OF ENGINEERING
DEPARTMENT OF COMPUTER ENGINEERING AND INFORMATICS
University of West Attica · Department of Computer Engineering and Informatics
Information Technology Security
Vasileios Evangelos Athanasiou
Student ID: 19390005
Supervision
Supervisor: Ioanna Kantzavelou, Associate Professor
Co-supervisor: Angelos Georgoulas, Assistant Professor
Athens, May 2023
This guide describes how to set up the required environment and reproduce the SQL Injection laboratory exercises using MySQL in a controlled academic setting.
The project is part of the Information Technology Security course at the University of West Attica (UNIWA).
Warning
This project demonstrates real security vulnerabilities.
It must be executed only in an isolated laboratory environment (local machine or virtual machine).
Never apply these techniques to production systems.
Recommended environments:
- Linux (preferred)
- Ubuntu 16.04 / 18.04 / 20.04
- SEED Ubuntu VM (fully compatible)
The laboratory uses MySQL as the backend database.
Install MySQL:
sudo apt update
sudo apt install -y mysql-serverVerify installation:
mysql --versionStart MySQL service:
sudo systemctl start mysql
sudo systemctl enable mysqlInstalled automatically with MySQL Server.
Verify:
mysql -u root -pIf you want to reproduce web-form SQL injection scenarios:
Install LAMP stack:
bash
sudo apt install -y apache2 php php-mysql
Verify Apache:
http://localhostgit clone https://github.com/Information-Technology-Security/SQL-Injection.git
cd SQL-Injectionsudo mysql -u rootCREATE DATABASE Users;
USE Users;CREATE TABLE credential (
ID INT PRIMARY KEY,
Name VARCHAR(50),
EID VARCHAR(20),
Salary INT,
birth DATE,
SSN VARCHAR(20),
PhoneNumber VARCHAR(20),
Address VARCHAR(100),
Email VARCHAR(50),
NickName VARCHAR(50),
Password VARCHAR(100)
);INSERT INTO credential VALUES
(1, 'Samy', 'E001', 50000, '1990-01-01', '123-45-6789', '2101234567', 'Athens', 'samy@example.com', 'samy', 'hash1'),
(2, 'Alice', 'E002', 52000, '1992-03-10', '987-65-4321', '2107654321', 'Piraeus', 'alice@example.com', 'alice', 'fdbe918bdae83000aa54747fc95fe0470fff4976');SELECT * FROM credential WHERE Name='Samy';Malicious Input:
' OR 1=1 --Resulting Query:
SELECT * FROM credential WHERE Name='' OR 1=1 --';Returns all records, demonstrating data leakage.
UPDATE credential SET Password='hacked_hash' WHERE ID=7 OR 1=1;Updates all users, demonstrating privilege escalation.
Prepared Statements (Conceptual Example)
SELECT * FROM credential WHERE Name = ?;- SQL logic is compiled separately
- User input is treated strictly as data
- Injection payloads are neutralized
| Issue | Cause | Solution |
|---|---|---|
| Cannot connect to MySQL | Service not running | sudo systemctl start mysql |
| Access denied for root | Auth plugin issue | Use sudo mysql |
| Queries fail | Wrong database | USE Users; |
| Injection not working | Input sanitized | Verify unsafe query logic |
- Navigate to the
docs/directory - Open the report corresponding to your preferred language:
- English:
SQL-Injection.pdf - Greek:
Έγχυση-SQL.pdf
- English:
