poeml / mirrorbrain

MirrorBrain
http://mirrorbrain.org/
Other
75 stars 37 forks source link

New rsyncd banner breaks scanner (protocol error) #187

Open elboulangero opened 1 year ago

elboulangero commented 1 year ago

In release 3.2.7, rsync changed the format of the banner sent by the daemon, cf. https://github.com/WayneD/rsync/commit/418e38a8789fd9b668961f945382c78806f2fb20. Before it was @RSYNCD: <version>.<subprotocol> and now it is @RSYNCD: <version>.<subprotocol> <digest1> <digestN>.

It breaks scanner, which is rather picky about what it expects, cf https://github.com/poeml/mirrorbrain/blob/master/tools/scanner.pl#L1230

In practice, here's what happens:

$ mb -b kali scan --enable md.mirrors.hacktegic.com
Wed Feb  8 05:25:20 2023 md.mirrors.hacktegic.com: starting
Wed Feb  8 05:25:22 2023 md.mirrors.hacktegic.com: total files before scan: 0
__DIE__: (=> /usr/bin/scanner 315 main::rsync_readdir => /usr/bin/scanner 1095 main::rsync_get_filelist)
md.mirrors.hacktegic.com: protocol error [@RSYNCD: 31.0 sha512 sha256 sha1 md5 md4
]
Completed in 2 seconds
elboulangero commented 1 year ago

Here's the patch (to apply on a system where scanner is installed at /usr/bin/scanner.pl, like it is in Debian):

From fd25b09f47b6afa3fbab9e868e39f25ef5702e91 Mon Sep 17 00:00:00 2001
From: Arnaud Rebillout <arnaudr@kali.org>
Date: Wed, 8 Feb 2023 15:12:22 +0700
Subject: [PATCH] Allow random string after rsyncd version in banner

---
 scanner | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git /usr/bin/scanner.pl /usr/bin/scanner.pl
index 3153eea..150a6d7 100755
--- /usr/bin/scanner.pl
+++ /usr/bin/scanner.pl
@@ -1202,7 +1202,7 @@ sub rsync_get_filelist
   alarm 600;
   sysread(S, $buf, 4096);
   alarm 0;
-  die("$identifier: protocol error [$buf]\n") if $buf !~ /^\@RSYNCD: ([\d.]+)\n/s;
+  die("$identifier: protocol error [$buf]\n") if $buf !~ /^\@RSYNCD: ([\d.]+).*\n/s;
   $peer->{rsync_protocol} = $1;
   $peer->{rsync_protocol} = 28 if $peer->{rsync_protocol} > 28;
   swrite(*S, "$module\n");