metasploit-framework/modules/auxiliary/scanner/redis/redis_server.rb

50 lines
1.4 KiB
Ruby
Raw Normal View History

##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'msf/core'
2016-03-08 13:02:44 +00:00
class MetasploitModule < Msf::Auxiliary
include Msf::Auxiliary::Redis
include Msf::Auxiliary::Report
include Msf::Auxiliary::Scanner
def initialize(info = {})
super(update_info(info,
'Name' => 'Redis Command Execute Scanner',
2016-01-06 00:23:10 +00:00
'Description' => %q(
This module locates Redis endpoints by attempting to run a specified
Redis command.
),
'Author' => [ 'iallison <ian[at]team-allison.com>', 'Nixawk' ],
'License' => MSF_LICENSE))
2016-01-06 00:23:10 +00:00
register_options(
[
Opt::RPORT(6379),
OptString.new('COMMAND', [ true, 'The Redis command to run', 'INFO' ])
]
)
end
def command
datastore['COMMAND']
end
def run_host(_ip)
2016-02-01 22:06:34 +00:00
vprint_status("Contacting redis")
begin
connect
2016-01-06 00:23:10 +00:00
return unless (data = redis_command(command))
report_service(host: rhost, port: rport, name: "redis server", info: "#{command} response: #{data}")
2016-02-01 22:06:34 +00:00
print_good("Found redis with #{command} command: #{Rex::Text.to_hex_ascii(data)}")
2016-01-05 16:54:22 +00:00
rescue Rex::AddressInUse, Rex::HostUnreachable, Rex::ConnectionTimeout,
Rex::ConnectionRefused, ::Timeout::Error, ::EOFError, ::Errno::ETIMEDOUT => e
2016-02-01 22:06:34 +00:00
vprint_error("Error while communicating: #{e}")
ensure
disconnect
end
end
end