Task 12
Task 12
ID: RS_1802
SQL Injection
What is SQL?
SQL is Structured Query Language, which is a computer language for storing, manipulating
and retrieving data stored in a relational database.
SQL is the standard language for Relational Database System. All the Relational Database
Management Systems (RDMS) like MySQL, MS Access, Oracle, Sybase, Informix, Postgres and
SQL Server use SQL as their standard database language.
Applications will often need dynamic SQL queries to be able to display content based on
different conditions set by the user. To allow for dynamic SQL queries, developers often
concatenate user input directly into the SQL statement. Without checks on the received input, string
concatenation becomes the most common mistake that leads to SQL injection vulnerability.
Without input sensitization, the user can make the database interpret the user input as a SQL
statement instead of as data. In other words, the attacker must have access to a parameter that they
can control, which goes into the SQL statement. With control of a parameter, the attacker can inject
a malicious query, which will be executed by the database. If the application does not sanitize the
given input from the attacker-controlled parameter, the query will be vulnerable to SQL injection
attack.
In-band SQLi
The attacker uses the same channel of communication to launch their attacks and to gather
their results. In-band SQLi’s simplicity and efficiency make it one of the most common types of
SQLi attack. There are two sub-variations of this method:
• Error-based SQLi—the attacker performs actions that cause the database to produce error
messages. The attacker can potentially use the data provided by these error messages to
gather information about the structure of the database.
Eg: https://tryhackme.com/room/id=1’
• Union-based SQLi—this technique takes advantage of the UNION SQL operator, which
fuses multiple select statements generated by the database to get a single HTTP response.
This response may contain data that can be leveraged by the attacker.
Eg: https://tryhackme.com/room/id=1 UNION SELECT 1,2,3
References:
https://www.w3schools.com/sql
https://www.tutorialspoint.com/sql/sql-overview.htm
https://www.imperva.com/learn/application-security/sql-injection-sqli/
https://tryhackme.com/room/sqlinjectionlm
https://infosecwriteups.com/sql-injection-lab-tryhackme-writeup-fcf30f846e82
https://portswigger.net/web-security/sql-injection