2013-05-13 21:42:33 +00:00
|
|
|
##
|
2014-10-17 16:47:33 +00:00
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
2013-10-15 18:50:46 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2013-05-13 21:42:33 +00:00
|
|
|
##
|
|
|
|
|
2013-05-11 02:18:48 +00:00
|
|
|
require 'msf/core'
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Auxiliary
|
2013-05-11 02:18:48 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
include Msf::Exploit::Remote::HttpClient
|
|
|
|
include Msf::Auxiliary::Report
|
2013-05-11 02:18:48 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => 'CouchDB Enum Utility',
|
|
|
|
'Description' => %q{
|
2015-04-16 02:47:18 +00:00
|
|
|
This module enumerates databases on CouchDB using the REST API
|
|
|
|
(without authentication by default).
|
2013-08-30 21:28:54 +00:00
|
|
|
},
|
2015-04-16 02:47:18 +00:00
|
|
|
'References' =>
|
2015-04-15 05:58:51 +00:00
|
|
|
[
|
|
|
|
['URL', 'https://wiki.apache.org/couchdb/HTTP_database_API']
|
|
|
|
],
|
|
|
|
'Author' => [ 'Roberto Soares Espreto <robertoespreto[at]gmail.com>' ],
|
2013-08-30 21:28:54 +00:00
|
|
|
'License' => MSF_LICENSE
|
2015-04-16 02:47:18 +00:00
|
|
|
))
|
2013-05-11 02:18:48 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
Opt::RPORT(5984),
|
|
|
|
OptString.new('TARGETURI', [true, 'Path to list all the databases', '/_all_dbs']),
|
|
|
|
OptString.new('USERNAME', [false, 'The username to login as']),
|
|
|
|
OptString.new('PASSWORD', [false, 'The password to login with'])
|
|
|
|
], self.class)
|
2015-04-15 05:58:51 +00:00
|
|
|
end
|
2013-05-11 02:18:48 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def run
|
|
|
|
username = datastore['USERNAME']
|
|
|
|
password = datastore['PASSWORD']
|
2013-05-11 02:18:48 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
begin
|
2015-04-16 02:47:18 +00:00
|
|
|
res = send_request_cgi(
|
2015-04-15 05:58:51 +00:00
|
|
|
'uri' => normalize_uri(target_uri.path),
|
|
|
|
'method' => 'GET',
|
|
|
|
'authorization' => basic_auth(username, password)
|
2015-04-16 02:47:18 +00:00
|
|
|
)
|
2015-04-15 05:58:51 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
temp = JSON.parse(res.body)
|
2015-04-15 05:58:51 +00:00
|
|
|
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, JSON::ParserError => e
|
2016-02-01 22:06:34 +00:00
|
|
|
print_error("The following Error was encountered: #{e.class}")
|
2013-08-30 21:28:54 +00:00
|
|
|
return
|
|
|
|
end
|
2013-05-13 21:42:33 +00:00
|
|
|
|
2015-04-16 02:47:18 +00:00
|
|
|
if res.code == 200 && res.headers['Server'].include?('CouchDB')
|
2015-04-15 05:58:51 +00:00
|
|
|
print_status('Enumerating...')
|
|
|
|
results = JSON.pretty_generate(temp)
|
|
|
|
print_good("Found:\n\n#{results}\n")
|
|
|
|
|
|
|
|
path = store_loot(
|
|
|
|
'couchdb.enum',
|
|
|
|
'text/plain',
|
|
|
|
rhost,
|
|
|
|
results,
|
|
|
|
'CouchDB Enum'
|
|
|
|
)
|
2013-05-11 02:18:48 +00:00
|
|
|
|
2016-02-01 22:06:34 +00:00
|
|
|
print_good("File saved in: #{path}")
|
2013-08-30 21:28:54 +00:00
|
|
|
else
|
2016-02-01 22:06:34 +00:00
|
|
|
print_error("Unable to enum, received \"#{res.code}\"")
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
|
|
|
end
|
2013-05-11 02:18:48 +00:00
|
|
|
end
|