
SQLMap is a popular open-source penetration testing tool used to automate the process of detecting and exploiting SQL injection vulnerabilities in web applications. It provides a wide range of options and features to help testers identify and exploit database vulnerabilities. Here’s a step-by-step guide on how to use SQLMap effectively:
1. Installation:
SQLMap is written in Python, so you’ll need to ensure that Python is installed on your system. You can download SQLMap from the official GitHub repository: https://github.com/sqlmapproject/sqlmap
2. Target Selection:
Identify the target web application you want to test for SQL injection vulnerabilities. Make sure you have permission to test the application, as unauthorized testing can be illegal.
3. Discovery:
The discovery phase involves identifying if the target application is vulnerable to SQL injection. Use the following command to initiate the scan:
“`
python sqlmap.py -u <target_URL>
“`
Replace `<target_URL>` with the URL of the vulnerable page. SQLMap will automatically analyze the URL and try various SQL injection techniques to detect vulnerabilities.
4. Enumeration:
Once SQL injection vulnerabilities are identified, you can proceed with enumerating the database management system (DBMS) and extracting information from the database. Use the `–dbs` option to list the available databases:
“`
python sqlmap.py -u <target_URL> –dbs
“`
This command will return a list of database names if successful.
5. Database Selection:
After obtaining the list of databases, you need to select a specific database to explore. Use the `–current-db` option to specify the database to use:
“`
python sqlmap.py -u <target_URL> -D <database_name> –current-db
“`
Replace `<database_name>` with the name of the selected database.
6. Table Enumeration:
Once the database is selected, you can enumerate the tables within that database using the `–tables` option:
“`
python sqlmap.py -u <target_URL> -D <database_name> –tables
“`
This command will provide a list of tables within the selected database.
7. Column Enumeration:
After obtaining the list of tables, you can proceed with enumerating the columns within a specific table. Use the `–columns` option along with the `-T` parameter to specify the table name:
“`
python sqlmap.py -u <target_URL> -D <database_name> -T <table_name> –columns
“`
Replace `<table_name>` with the name of the table to enumerate.
8. Data Extraction:
Once you have identified the columns of interest, you can extract data from those columns using the `–dump` option. Specify the table name and column names as follows:
“`
python sqlmap.py -u <target_URL> -D <database_name> -T <table_name> -C “<column1>,<column2>,…” –dump
“`
Replace `<column1>,<column2>,…` with a comma-separated list of column names.
9. Exploiting:
SQLMap also provides the ability to exploit the SQL injection vulnerability further by executing custom SQL statements. Use the `–sql-shell` option to get an interactive SQL shell:
“`
python sqlmap.py -u <target_URL> –sql-shell
“`
This will open an interactive shell where you can execute SQL queries.
10. Advanced Techniques:
SQLMap offers various advanced techniques and options to fine-tune the scanning process. You can explore options such as `–technique`, `–tamper`, `–level`, and `–risk` to customize the exploitation process