# SQL-Map Basics

<figure><img src="https://miro.medium.com/v2/resize:fit:875/1*WljqtpNteg1b0dKZwL688Q.png" alt="" height="362" width="700"><figcaption></figcaption></figure>

> **Intro :**
>
> **Sqlmap** is a software utility for automated discovering of **SQL injection** vulnerabilities in web applications. It is a awesome tool. It is automated Tool.

TryHackMe gives us a room to test this vulnerability. I only complete the **‘sqlmap challenge’** here. SQLMap use some **flags** to check the vulnerability and for exploiting that issue. You can type **‘sqlmap -h’** in the Terminal to see the all flags.

> **Tip : Website →** [**https://github.com/sqlmapproject/sqlmap/wiki/Usage**](https://github.com/sqlmapproject/sqlmap/wiki/Usage)
>
> ***For checking all flags.***

So let’s jump into the Website.

<figure><img src="https://miro.medium.com/v2/resize:fit:875/1*bR9GykpB_3DeZaVRDu0bwQ.png" alt="" height="341" width="700"><figcaption></figcaption></figure>

This is Blood Donation website and ‘search blood group’ functionality is vulnerable. So we have to check that request. I am comfortable to use **‘BurpSuite’**.

It is a awesome tool to check this type of vulnerability. So I open it and intercept the **‘search’** request.

<figure><img src="https://miro.medium.com/v2/resize:fit:875/1*pWuB7Etvt-7maSAw5kzUfQ.png" alt="" height="331" width="700"><figcaption></figcaption></figure>

<figure><img src="https://miro.medium.com/v2/resize:fit:875/1*cd1u7lBw_Kwjt9hlftC5xw.png" alt="" height="394" width="700"><figcaption></figcaption></figure>

There is a **blood\_group** parameter. And this is vulnerable to **SQL Injection**. So I saved the request in a text file.

<figure><img src="https://miro.medium.com/v2/resize:fit:639/1*Uwqh_P_wf4Deugi9oT1Jpg.png" alt="" height="602" width="511"><figcaption></figcaption></figure>

The output will be like. I set **\*** in the **‘blood\_group’** parameter. This is a wildcard to check only that parameter.

<figure><img src="https://miro.medium.com/v2/resize:fit:875/1*Q16QWAOQB2WsmNFz3KtShA.png" alt="" height="304" width="700"><figcaption></figcaption></figure>

Then I start my **sqlmap**.

> **Tip : sqlmap -r req.txt — batch**

<figure><img src="https://miro.medium.com/v2/resize:fit:875/1*xy_zIDE6OYNVpc4qaPdHHw.png" alt="" height="262" width="700"><figcaption></figcaption></figure>

This will show us if the parameter is vulnerable or not.

<figure><img src="https://miro.medium.com/v2/resize:fit:875/1*E5BpMGuBtVD3V19iCZP5mQ.png" alt="" height="139" width="700"><figcaption></figcaption></figure>

It show us the parameter is Injectable. Mission Successful. This is the brief output.

<figure><img src="https://miro.medium.com/v2/resize:fit:875/1*rxUf6N2WaYR0wfPH5hTlzA.png" alt="" height="366" width="700"><figcaption></figcaption></figure>

So let’s explore the database with **‘ — dbs’** flag. I use **‘ — batch’** flag to automate things… asking noting to me or it ask yes or no etc.

> **Tip : sqlmap -r req.txt — batch — dbs**

<figure><img src="https://miro.medium.com/v2/resize:fit:875/1*MWJ_cvH-cmmIZJtn9L2LYA.png" alt="" height="257" width="700"><figcaption></figcaption></figure>

And we get the all Databases. How amazing! Here 6 databases are present and the **‘blood’** database seems Interesting. So let’s see what tables are present in that Database.

<figure><img src="https://miro.medium.com/v2/resize:fit:741/1*35FskqMpciJlmFvSopQdSw.png" alt="" height="260" width="593"><figcaption></figcaption></figure>

> **Tip : sqlmap -r req.txt — batch -D blood — tables**
>
> **1> -D → To specify database name.**
>
> **2> — tables → To list all tables present in the Database.**

<figure><img src="https://miro.medium.com/v2/resize:fit:875/1*jI876jIEdUTL4yVhOvNIxA.png" alt="" height="290" width="700"><figcaption></figcaption></figure>

And this is the output. Here 3 tables are present where ‘flag’ table contains the flag that **‘TryHackMe’** want.

<figure><img src="https://miro.medium.com/v2/resize:fit:735/1*-10_x3vm0qaROwwViar1Xg.png" alt="" height="260" width="588"><figcaption></figcaption></figure>

So Let’s go for it.

> **Tip : sqlmap -r req.txt — batch -D blood -T flag — dump**
>
> **1> -T → To specify the table name**
>
> **2> — dump → To dump all contents of that table.**

<figure><img src="https://miro.medium.com/v2/resize:fit:875/1*Vkzxin3_thY2GQl4EN13mA.png" alt="" height="269" width="700"><figcaption></figcaption></figure>

Get the flag.

<figure><img src="https://miro.medium.com/v2/resize:fit:423/1*76W7Rkk9StBdppDdMX-gQQ.png" alt="" height="167" width="338"><figcaption></figcaption></figure>

Now let’s check the other tables. Here we want all users present in the Database.

<figure><img src="https://miro.medium.com/v2/resize:fit:875/1*XjMmMHo95nt7hd5murTrkQ.png" alt="" height="262" width="700"><figcaption></figcaption></figure>

And Here we get the output.

<figure><img src="https://miro.medium.com/v2/resize:fit:875/1*wZDKW7Y8GxjCVbz7mM0dZQ.png" alt="" height="417" width="700"><figcaption></figcaption></figure>

There are 3 users : **nare, google** and **test** along with their Information. There is another table called **‘blood\_db’**. Let’s check that also.

<figure><img src="https://miro.medium.com/v2/resize:fit:875/1*SRYApE2CeRClMDQZ_dSXiw.png" alt="" height="260" width="700"><figcaption></figcaption></figure>

I get the output below.

<figure><img src="https://miro.medium.com/v2/resize:fit:875/1*NMaWAMDqHISM0vjcNIuZyw.png" alt="" height="215" width="700"><figcaption></figcaption></figure>

This contains user(**nare**) Information.

So **SQL Injection** is a Critical Vulnerability and can easily exploited by this automated tool. So always check every Input parameter while testing a website.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://foothold.gitbook.io/blog/sql-map-basics.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
