SQL Injection
What is SQL Injection
SQL Injection is a type of cybersecurity vulnerability where an attacker manipulates a SQL query by injecting malicious SQL code into user inputs (e.g., login forms, search boxes) that are not properly sanitized. This allows the attacker to bypass authentication, access, modify, or delete database data, or even execute administrative operations on the database. SQL injection exploits occur when applications fail to validate or escape user-supplied input, making it possible to alter the intended behavior of SQL queries.
Video explaination
Types of SQL Injection

SQL Injection during code review
Below you can find examples of unsafe code leading to SQL Injection.
If you want to correct the sanatize the input and do not use string concatenation.
Exploiting SQL Injection
Fuzz String
BOOLEAN BASED
If outputs of the payloads differ application is probably vulnerable to SQL Injection.
Payload 1:
Payload 2:
TIME BASED
Change response times to avoid false positives.
Useful SQL commands
Additional info about hidden system tables in MSSQL:
Manual Code Execution
INTO OUTFILE
In some cases you can spawn the webshell using SQL Injection.
If xp_cmdshell is set to True we are able to execute shell commands on the system.
You can obtain reverse shell using COPY TO method (by providing malicious file and saving it to the system):
Another way to obtain RCE is uploading compiled malicious extension (.dll):
// TODO
Last updated