Skip to content

Commit 213fe23

Browse files
committed
Clean rsync_modules_list
1 parent 18f1bdb commit 213fe23

File tree

1 file changed

+36
-31
lines changed

1 file changed

+36
-31
lines changed

modules/auxiliary/scanner/rsync/rsync_modules_list.rb

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,39 +20,44 @@ def initialize
2020
)
2121
register_options(
2222
[
23-
Opt::RPORT(873),
24-
OptInt.new('TIMEOUT', [true, 'Timeout for the Rsync probe', 30])
25-
], self.class)
26-
end
27-
28-
def to
29-
return 30 if datastore['TIMEOUT'].to_i.zero?
30-
datastore['TIMEOUT'].to_i
23+
Opt::RPORT(873)
24+
], self.class)
3125
end
3226

3327
def run_host(ip)
34-
begin
35-
::Timeout.timeout(to) do
36-
connect()
37-
version = sock.recv(1024)
38-
# making sure we match the version of the server
39-
sock.puts("#{version}")
40-
# the listing command
41-
sock.puts("\n")
42-
listing = sock.get()
43-
# not interested in EXIT message
44-
listing = listing.to_s.gsub('@RSYNCD: EXIT', '')
45-
disconnect()
46-
47-
listing_sanitized = Rex::Text.to_hex_ascii(listing.to_s.strip)
48-
print_status("#{ip}:#{rport} #{version.rstrip} #{listing_sanitized}")
49-
report_service(:host => rhost, :port => rport, :name => 'rsync', :info => listing_sanitized)
50-
end
51-
rescue ::Rex::ConnectionError
52-
rescue Timeout::Error
53-
print_error("#{target_host}:#{rport}, Server timed out after #{to} seconds. Skipping.")
54-
rescue ::Exception => e
55-
print_error("#{e} #{e.backtrace}")
56-
end
28+
connect
29+
version = sock.get_once
30+
31+
print_good("#{ip}:#{rport} - rsync #{version.strip} found")
32+
report_service(:host => ip, :port => rport, :proto => 'tcp', :name => 'rsync')
33+
report_note(
34+
:host => ip,
35+
:proto => 'tcp',
36+
:port => rport,
37+
:type => 'rsync_version',
38+
:data => version.strip
39+
)
40+
41+
# making sure we match the version of the server
42+
sock.puts("#{version}")
43+
# the listing command
44+
sock.puts("\n")
45+
listing = sock.get(20)
46+
disconnect
47+
48+
return if listing.blank?
49+
50+
print_good("#{ip}:#{rport} - rsync listing found")
51+
listing.gsub!('@RSYNCD: EXIT', '') # not interested in EXIT message
52+
listing_sanitized = Rex::Text.to_hex_ascii(listing.strip)
53+
54+
vprint_status("#{ip}:#{rport} - #{version.rstrip} #{listing_sanitized}")
55+
report_note(
56+
:host => ip,
57+
:proto => 'tcp',
58+
:port => rport,
59+
:type => 'rsync_listing',
60+
:data => listing_sanitized
61+
)
5762
end
5863
end

0 commit comments

Comments
 (0)