Skip to content

Commit 24a989b

Browse files
committed
Land rapid7#5249, Add Module for Enum on InfluxDB database
2 parents 7bbc171 + 005c36b commit 24a989b

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
##
2+
# This module requires Metasploit: http://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
8+
class Metasploit3 < Msf::Auxiliary
9+
10+
include Msf::Exploit::Remote::HttpClient
11+
include Msf::Auxiliary::Report
12+
13+
def initialize(info = {})
14+
super(update_info(info,
15+
'Name' => 'InfluxDB Enum Utility',
16+
'Description' => %q{
17+
This module enumerates databases on InfluxDB using the REST API
18+
(using default authentication - root:root).
19+
},
20+
'References' =>
21+
[
22+
['URL', 'http://influxdb.com/docs/v0.9/concepts/reading_and_writing_data.html']
23+
],
24+
'Author' => [ 'Roberto Soares Espreto <robertoespreto[at]gmail.com>' ],
25+
'License' => MSF_LICENSE
26+
))
27+
28+
register_options(
29+
[
30+
Opt::RPORT(8086),
31+
OptString.new('TARGETURI', [true, 'Path to list all the databases', '/db']),
32+
OptString.new('USERNAME', [true, 'The username to login as', 'root']),
33+
OptString.new('PASSWORD', [true, 'The password to login with', 'root'])
34+
], self.class)
35+
end
36+
37+
def run
38+
begin
39+
res = send_request_cgi(
40+
'uri' => normalize_uri(target_uri.path),
41+
'method' => 'GET'
42+
)
43+
rescue ::Errno::EPIPE, ::Timeout::Error, ::EOFError, ::IOError => e
44+
print_error("#{peer} - The following Error was encountered: #{e.class}")
45+
return
46+
end
47+
48+
unless res
49+
print_error("#{peer} - Server did not respond in an expected way.")
50+
return
51+
end
52+
53+
if res.code == 401 && res.body =~ /Invalid username\/password/
54+
print_error("#{peer} - Failed to authenticate. Invalid username/password.")
55+
return
56+
elsif res.code == 200 && res.headers.include?('X-Influxdb-Version') && res.body.length > 0
57+
print_status("#{peer} - Enumerating...")
58+
begin
59+
temp = JSON.parse(res.body)
60+
if temp.blank?
61+
print_status("#{peer} - Json data is empty")
62+
return
63+
end
64+
results = JSON.pretty_generate(temp)
65+
rescue JSON::ParserError
66+
print_error("#{peer} - Unable to parse JSON data.")
67+
return
68+
end
69+
print_good("Found:\n\n#{results}\n")
70+
path = store_loot(
71+
'influxdb.enum',
72+
'text/plain',
73+
rhost,
74+
results,
75+
'InfluxDB Enum'
76+
)
77+
print_good("#{peer} - File saved in: #{path}")
78+
else
79+
print_error("#{peer} - Unable to enum, received \"#{res.code}\"")
80+
end
81+
end
82+
end

0 commit comments

Comments
 (0)