📕
Blog
  • 🐞Vulnerabilities & Techniques
    • Web Vulnerabilities
      • Open Redirect
      • HTTP Parameter Pollution (HPP)
      • Host Header Injection (HHI)
      • XSS
      • HTML-Injection
      • clickjacking
      • S3
      • EXternal Xml Entity (XXE)
      • XSS prevention | CSP
      • DOM-XSS
      • SQL Injection | SQLI
      • Response Manipulation Technique & How Burp Suite Works
    • API Vulnerabilities
      • Mass Assignment Vulnerability
  • 🚩CTF
    • ASCWG
  • ✍️Writeups
    • Read Writeups
      • REST API WriteUps
      • Web Vulnerabilities WriteUps
    • Technical Writeups
      • Reset Password Poisoning Via Host Header Injection Lead to (ATO)
      • OTP/2FA Bypasses
        • OTP bypasses
  • 😈TryHackMe
    • THM Advent of Cyber 3 (2021) NoSQL WriteUp
  • 🔱Web-CyberTalents
    • CyberTalents-Web-Easy
    • CyberTalents-Web-Medium
    • CyberTalents-Web-Hard
  • 🖇️Pentesting & Bug Hunting Tips
    • ATO Via Host Header Injection
    • OTP Bypass
    • OutLook Plugin Pentest Guide
  • 💻Port-Swigger Labs
    • XML external entity (XXE) injection
    • DOM-XSS
      • DOM XSS in the document.write sink using source location.search
      • Lab: DOM XSS in document.write sink using source location.search inside a select element
      • Lab: DOM XSS in innerHTML sink using source location.search
      • Lab: DOM XSS in jQuery anchor href attribute sink using location.search source
      • Lab: Reflected DOM XSS
      • Lab: Stored DOM XSS
    • SQL injection
      • Lab: SQL injection vulnerability in WHERE clause allowing retrieval of hidden data
      • Lab: SQL injection vulnerability allowing login bypass
      • Lab: SQL injection UNION attack, determining the number of columns returned by the query
      • Lab: SQL injection UNION attack, finding a column containing text
      • Lab: SQL injection UNION attack, retrieving data from other tables
      • Lab: SQL injection UNION attack, retrieving multiple values in a single column
      • Lab: SQL injection attack, querying the database type and version on Oracle
      • Lab: SQL injection attack, querying the database type and version on MySQL and Microsoft
      • Lab: SQL injection attack, listing the database contents on non-Oracle databases
  • 🛜Wireless Networks Penetration Testing
  • ⚔️Wi-Fi Attacks
    • 🕸️Network Scanning attack
    • 🌊DOS / Flooding
      • 1️⃣DoS - Frame Flooding (Deauth, EAPOL, Beacons)
      • 2️⃣DoS- Exploiting Countermeasures (MIC failure)
    • Jamming Attacks (هجمات التشويش)
    • Probe Requests Attack
    • Handshake Attacks
      • Dictionary Attack
      • Clientless Attack
      • KRACK Attack
      • Downgrad Attack
    • Rouge AP Attack
  • Lab Notes
  • RFID and NFC
  • Bluetooth
  • ZigBee
  • Google Map Test
Powered by GitBook
On this page
  • Intro to SQL Injection
  • 📚 What is SQLI?
  • 🤔 Why SQLI happen?
  • 🔎 Finding SQL Injection
  • 🌀 What are the types of SQLI?
  • In-band SQL injections:
  • Blind SQL injection:
  • 🌀 What is the impact of a successful SQL injection attack?
  • SQL injection examples
  • 🐍 SQLMAP
  • 🔬 Labs
  • 📕 Referance
  1. Vulnerabilities & Techniques
  2. Web Vulnerabilities

SQL Injection | SQLI

PreviousDOM-XSSNextResponse Manipulation Technique & How Burp Suite Works

Last updated 2 years ago

Intro to SQL Injection

📚 What is SQLI?

(SQLi) attack exploits the injection of SQL commands into the SQL queries of a web application.

A successful SQLi attack lets malicious hackers access and manipulate a web application’s backend database.

To interact with databases, entities such as systems operators, programmers, applications, and web applications use the Structured Query Language (SQL).


SQL Like:

SQL is a powerful interpreted language used to extract and manipulate data from a database.


🤔 Why SQLI happen?

A web developer's trust in users and missing to put any input validation or output encoding prevent users from interacting with database queries

Modern web frameworks nowadays solved this problem with predefined functions that defend against sqli like Laravel framework based on php

Example:

$id Parameter is vulnerable to sqli

try to provide the id parameter with the values payload above to achieve your sqli attack


🔎 Finding SQL Injection

The most straightforward way to find SQL injections within a web application is to probe its inputs with characters that are known to cause the SQL query to be syntactically invalid and thus forcing the web application to return an error.

Input parameters are carried through GET and POST requests,HEADERS, and COOKIES. So, we have to check all the channels where data is retrieved from the client.


🌀 What are the types of SQLI?

In-band SQL injections:

leverage the same channel used to inject the SQL code (i.e., the pages generated by the web application).

1. Error-Based SQL injection attack:

The penetration tester tries to force the DMBS to output an error message and then uses that information to perform data exfiltration.

2. Union-Based SQL injection attack:

The ability of the user to add another sql query to the original query to make some sql operation to retrieve data like this:

Blind SQL injection:

This does not reflect the results of the injection on the output. In this case, the penetration tester must find an inference method to exploit the vulnerability

1. Blind Boolean-Based SQLI: Currently, most production websites do not display such errors. This happens both because of the usability of the application; it is useless to display errors to end users who cannot understand or fix them, and to achieve security through obscurity.

IF SQL Statement is TRUE ✅ Render page Well. IF SQL Statement is FALSE ❌ Render page Bad.

2. Blind Time-Based SQLI Time is used to infer a TRUE condition from a FALSE condition.

This SQL syntax is used:

%SQL condition% waitfor delay '0:0:5’
If condition true response will wait 5 seconds

🌀 What is the impact of a successful SQL injection attack?

A successful SQL injection attack can result in:

unauthorized access to sensitive data such as

  1. passwords

  2. credit card details

  3. personal user information.

Many high-profile data breaches in recent years have been the result of SQL injection attacks, leading to reputational damage and regulatory fines. In some cases, an attacker can obtain a persistent backdoor into an organization’s systems, leading to a long-term compromise that can go unnoticed for an extended period.


SQL injection examples


🐍 SQLMAP

sqlmap is an open-source penetration testing tool developed by Bernardo Damele Assumpcao Guimaraes and Miroslav Stampar that automates the process of detecting and exploiting SQL injection flaws and taking over database servers. It comes with a powerful detection engine, many niche features for the ultimate penetration tester, and a broad range of switches lasting from database fingerprinting, and fetching data from the database to accessing the underlying file system and executing commands on the operating system via out-of-band connections.

you can automation find many sqli with SQLMAP

Automate using sqlmap


🔬 Labs


📕 Referance

You Can Know More About SQL

, where you can modify an SQL query to return additional results.

, where you can change a query to interfere with the application’s logic.

, where you can retrieve data from different database tables.

, where you can extract information about the version and structure of the database.

, where the results of a query you control are not returned in the application’s responses.

: Install this Machine and will have a lot of Labs like DVWA, BWAPP, Webgoat, etc

You can find my solution for portswigger

🐞
HERE
Retrieving hidden data
Subverting application logic
UNION attacks
Examining the database
Blind SQL injection
Portswigger
OWASP Broken Web Applications Project
HERE
Portswigger
OWASP
PayloadsAllTheThings
hacktricks
hackingarticles