2014-07-24 20:04:00 +00:00
|
|
|
##
|
2014-10-17 16:47:33 +00:00
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
2014-07-24 20:04:00 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
include Msf::Exploit::Remote::Tcp
|
|
|
|
include Msf::Auxiliary::Scanner
|
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => 'Rsync Unauthenticated List Command',
|
2014-07-24 21:26:41 +00:00
|
|
|
'Description' => 'List all (listable) modules from a rsync daemon',
|
|
|
|
'Author' => 'ikkini',
|
2014-08-28 23:47:56 +00:00
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
['URL', 'http://rsync.samba.org/ftp/rsync/rsync.html']
|
|
|
|
],
|
2014-07-24 20:04:00 +00:00
|
|
|
'License' => MSF_LICENSE
|
|
|
|
)
|
|
|
|
register_options(
|
|
|
|
[
|
2014-08-28 23:40:55 +00:00
|
|
|
Opt::RPORT(873)
|
|
|
|
], self.class)
|
2014-07-24 20:04:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def run_host(ip)
|
2014-08-28 23:40:55 +00:00
|
|
|
connect
|
|
|
|
version = sock.get_once
|
|
|
|
|
2014-10-18 22:29:36 +00:00
|
|
|
return if version.blank?
|
2015-10-12 16:51:00 +00:00
|
|
|
version.strip!
|
2014-10-18 22:29:36 +00:00
|
|
|
|
2015-10-12 16:05:01 +00:00
|
|
|
report_service(host: ip, port: rport, proto: 'tcp', name: 'rsync')
|
2014-08-28 23:40:55 +00:00
|
|
|
report_note(
|
2015-10-12 16:05:01 +00:00
|
|
|
host: ip,
|
|
|
|
proto: 'tcp',
|
|
|
|
port: rport,
|
|
|
|
type: 'rsync_version',
|
2015-10-12 16:51:00 +00:00
|
|
|
data: version
|
2014-08-28 23:40:55 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# making sure we match the version of the server
|
2015-10-12 16:51:00 +00:00
|
|
|
sock.puts("#{version}\n")
|
2014-08-28 23:40:55 +00:00
|
|
|
# the listing command
|
2015-10-12 16:51:00 +00:00
|
|
|
sock.puts("#list\n")
|
2014-08-28 23:40:55 +00:00
|
|
|
listing = sock.get(20)
|
|
|
|
disconnect
|
|
|
|
|
2015-10-12 16:51:00 +00:00
|
|
|
if listing.blank?
|
|
|
|
print_status("#{ip}:#{port} - rsync #{version}: no modules found")
|
|
|
|
else
|
|
|
|
listing.gsub!('@RSYNCD: EXIT', '') # not interested in EXIT message
|
|
|
|
listing.strip!
|
|
|
|
# build a table to store the module listing in
|
|
|
|
listing_table = Msf::Ui::Console::Table.new(
|
|
|
|
Msf::Ui::Console::Table::Style::Default,
|
|
|
|
'Header' => "rsync modules",
|
|
|
|
'Columns' =>
|
|
|
|
[
|
|
|
|
"Name",
|
|
|
|
"Comment"
|
|
|
|
])
|
2014-08-28 23:40:55 +00:00
|
|
|
|
2015-10-12 16:51:00 +00:00
|
|
|
# the module listing is the module name and comment separated by a tab, each module
|
|
|
|
# on its own line, lines separated with a newline
|
|
|
|
listing.split(/\n/).map do |share_line|
|
|
|
|
name, comment = share_line.split(/\t/).map(&:strip)
|
|
|
|
listing_table << [ name, comment ]
|
|
|
|
end
|
2014-08-28 23:40:55 +00:00
|
|
|
|
2015-10-12 16:51:00 +00:00
|
|
|
print_good("#{ip}:#{rport} - rsync #{version}: #{listing_table.rows.size} modules found")
|
|
|
|
vprint_line(listing_table.to_s)
|
|
|
|
|
|
|
|
report_note(
|
|
|
|
host: ip,
|
|
|
|
proto: 'tcp',
|
|
|
|
port: rport,
|
|
|
|
type: 'rsync_listing',
|
2015-10-12 17:41:36 +00:00
|
|
|
:data => { :modules => listing_table.rows },
|
|
|
|
:update => :unique_data
|
2015-10-12 16:51:00 +00:00
|
|
|
)
|
|
|
|
end
|
2014-07-24 20:04:00 +00:00
|
|
|
end
|
|
|
|
end
|