SQLi Penetration Testing
Introduction to the SQLi
SQL Injection (SQLi) is an attack that allows execution of arbitrary SQL queries on a database through a vulnerable web application. Imagine a nightclub where the bouncer's job is to verify the age of each guest to ensure they're over 21. Instead of checking IDs properly, the bouncer just glances at whatever is shown and lets everyone in, assuming it's valid. This lack of scrutiny allows individuals who are underage and/or have fake IDs to enter the club, potentially causing trouble.
In the case of SQL injection, the web application (bouncer) is supposed to validate and sanitize user inputs (IDs) to ensure only safe and legitimate queries (guests) interact with the database (club). However, if the application fails to properly check and sanitize these inputs, malicious actors (underage individuals) can inject harmful SQL code (fake IDs) into the query, gaining unauthorized access to sensitive data (entering the club) and potentially causing damage.

This walkthrough demonstrates using SQLMap to exploit a vulnerable URL parameter on a MySQL-based website. Steps include confirming the vulnerability, enumerating databases, and extracting data from the "wordpress" database. The scenario highlights the impact of SQLi vulnerabilities, such as unauthorized data access, and concludes with preparing a pentest report to document findings and recommendations.
SQLMap: SQLi Scenario
Step 1: Identify the Target
Assess the security of a website, http://example.com. The target URL is http://example.com/products.php?id=1.
Step 2: Initial Reconnaissance
Use basic browser testing and tools like Burp Suite to determine if the id parameter in the URL might be vulnerable to SQL injection.
Step 3: Running SQLMap for SQL Injection
Use SQLMap to test and exploit the SQL injection vulnerability.
sqlmap -u "http://example.com/products.php?id=1" --dbms=mysql --batch --banner
Command Explanation
-u "http://example.com/products.php?id=1": Specifies the URL with the potential SQL injection point.--dbms=mysql: Forces the backend database type to MySQL.--batch: Runs in non-interactive mode, using default options.--banner: Retrieves the database server's banner to confirm the database type and version.












