Sitemap
Ruth Barkat

Ruth Barkat

TryHackMe — SQLMAP

--

Learn about and use Sqlmap to exploit the web application

You can skip the theory and jump to the Interesting part, The Challenge

Task1: Introduction

In this room, we will learn about sqlmap and how it can be used to exploit SQL Injection vulnerabilities.

What is Sqlmap?

SQLmap is a widely-used open-source tool designed to automate the process of discovering and exploiting SQL injection vulnerabilities. It helps cyber security professionals to identify vulnerabilities in web applications and databases by identifying potential weaknesses and providing insights for remediation. With its detection tools and range of features, SQLmap is an invaluable asset for penetration testers and security analysts alike.

Installing Sqlmap

If you’re using Kali Linux, sqlmap is pre-installed. Otherwise, you can download it here:

Using Sqlmap

Here are important commands and descriptions given in the room that are worth reading, so do give it a shot.

Task2: Using Sqlmap

  • Which flag or option will allow you to add a URL to the command?

-u

  • Which flag would you use to add data to a POST request?

— data

  • There are two parameters: username and password. How would you tell sqlmap to use the username parameter for the attack?

-p username

  • Which flag would you use to show the advanced help menu?

-hh

  • Which flag allows you to retrieve everything?

-a

  • Which flag allows you to select the database name?

d

  • Which flag would you use to retrieve database tables?

— tables

  • Which flag allows you to retrieve a table’s columns?

— columns

  • Which flag allows you to dump all the database table entries?

— dump-all

  • Which flag will give you an interactive SQL Shell prompt?

— sql-shell

  • You know the current db type is ‘MYSQL’. Which flag allows you to enumerate only MySQL databases?

— dbms=MySQL

Task3: SQLMap Challenge

Deploy the machine attached to this task, then navigate to MACHINE_IP (this machine can take up to 3 minutes to boot)
Task: We have deployed an application to collect ‘Blood Donations’. The request seems to be vulnerable.
Exploit a SQL Injection vulnerability on the vulnerable application to find the flag.

Get Ruth Barkat’s stories in your inbox

Join Medium for free to get updates from this writer.

To solve this challenge, I open the web application ‘Blood Donations’.

Press enter or click to view image in full size

However, there was nothing much that I saw so I simply move to the next step that is doing the scanning on the IP using “nmap -Pn -v — open 10.10.101.163”, and found that only one port is opened that is tcp 80 where the application was running.

So, I go for inspecting the source code and there was just a simple text, and so I just simply tired with robust.txt

Press enter or click to view image in full size

Since I need the directory name so I go do the directory busting on this. I used the tool ffuf along with small.txt wordlist for directory busting.

Press enter or click to view image in full size
ffuf results

Found directory named “blood”, so let see what we have in this directory.

  • What is the name of the interesting directory ?
    blood
Press enter or click to view image in full size
contents of blood directory

Looks like some login and registration page.

Press enter or click to view image in full size
results of login page
Press enter or click to view image in full size
results of register directory

I’ve used SQLMap to enumerate the Databases for usernames, tables, and all data that can be found in it.

I used the following command to know the current user of the database.

sqlmap -u http://10.10.153.126/blood/login.php — current-user — forms

SQLMap results

. Who is the current db user?
root

Now for flag you need to have tables and its contents, so I used sqlmap tool. I use command sqlmap -u http://10.10.153.126/blood/ -dbs — forms to get the name of the database.

name of the database

So now I have the name of the database I can get the tables and their contents, I used the command sqlmap -u http://10.10.153.126/blood/ -D blood — tables — forms , which gives me the tables of the database which are as follows

name of tables

Finally, for the contents of the table I have used sqlmap -u http://10.10.153.126/blood/ -D blood -T flag — dump — forms that dumps the content and from where we get the final flag

flag table contents
  • What is the final flag?
    thm{sqlm@p_is_L0ve}

Congrats! you got this room completed!

Press enter or click to view image in full size

--

--