Skip to content

Commit 18ee9af

Browse files
committed
Added couchdb_enum.rb to list essential information about CouchDB
1 parent 3d5eb24 commit 18ee9af

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
require 'msf/core'
2+
3+
class Metasploit3 < Msf::Auxiliary
4+
5+
include Msf::Exploit::Remote::HttpClient
6+
include Msf::Auxiliary::Report
7+
8+
def initialize(info = {})
9+
super(update_info(info,
10+
'Name' => 'CouchDB Enum Utility',
11+
'Description' => %q{
12+
Send a "send_request_cgi()" to enumerate databases and your values on CouchDB (Without authentication by default)
13+
},
14+
'Author' => [ 'espreto <robertoespreto[at]gmail.com>' ],
15+
'License' => MSF_LICENSE
16+
))
17+
18+
register_options(
19+
[
20+
Opt::RPORT(5984),
21+
OptString.new('TARGETURI', [true, 'Path to list all the databases', '/_all_dbs']),
22+
OptEnum.new('HTTP_METHOD', [true, 'HTTP Method, default GET', 'GET', ['GET', 'POST', 'PUT', 'DELETE'] ]),
23+
OptString.new('USERNAME', [false, 'The username to login as']),
24+
OptString.new('PASSWORD', [false, 'The password to login with'])
25+
], self.class)
26+
end
27+
28+
def run
29+
username = datastore['USERNAME']
30+
password = datastore['PASSWORD']
31+
32+
uri = normalize_uri(datastore['TARGETURI'])
33+
res = send_request_cgi({
34+
'uri' => uri,
35+
'method' => datastore['HTTP_METHOD'],
36+
'authorization' => basic_auth(username, password),
37+
'headers' => {
38+
'Cookie' => 'Whatever?'
39+
}
40+
})
41+
42+
if res.nil?
43+
print_error("No response for #{target_host}")
44+
end
45+
46+
temp = JSON.parse(res.body)
47+
results = JSON.pretty_generate(temp)
48+
49+
if (res.code == 200)
50+
print_good("#{target_host}:#{rport} -> #{res.code}")
51+
print_good("Response Headers:\n\n #{res.headers}")
52+
print_good("Response Body:\n\n #{results}\n")
53+
elsif (res.code == 403) # Forbidden
54+
print_error("Received #{res.code} - Forbidden to #{target_host}:#{rport}")
55+
print_error("Response from server:\n\n #{results}\n")
56+
elsif (res.code == 404) # Not Found
57+
print_error("Received #{res.code} - Not Found to #{target_host}:#{rport}")
58+
print_error("Response from server:\n\n #{results}\n")
59+
else
60+
print_status("#{res.code}")
61+
print_status("#{results}")
62+
end
63+
64+
if res and res.code == 200 and res.headers['Content-Type'] and res.body.length > 0
65+
path = store_loot("couchdb.enum.file", "text/plain", rhost, res.body, "CouchDB Enum Results")
66+
print_status("Results saved to #{path}")
67+
else
68+
print_error("Failed to save the result")
69+
end
70+
71+
rescue ::Exception => e
72+
print_error("Error: #{e.to_s}")
73+
return nil
74+
end
75+
end

0 commit comments

Comments
 (0)