Skip to content

Commit cba045a

Browse files
committed
Make additional changes to the module
1 parent a94d078 commit cba045a

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

modules/auxiliary/scanner/couchdb/couchdb_enum.rb

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
##
2+
# This file is part of the Metasploit Framework and may be subject to
3+
# redistribution and commercial restrictions. Please see the Metasploit
4+
# web site for more information on licensing and terms of use.
5+
# http://metasploit.com/
6+
##
7+
18
require 'msf/core'
29

310
class Metasploit3 < Msf::Auxiliary
@@ -29,22 +36,28 @@ def run
2936
username = datastore['USERNAME']
3037
password = datastore['PASSWORD']
3138

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-
}
39+
uri = normalize_uri(target_uri.path)
40+
res = send_request_cgi({
41+
'uri' => uri,
42+
'method' => datastore['HTTP_METHOD'],
43+
'authorization' => basic_auth(username, password),
44+
'headers' => {
45+
'Cookie' => 'Whatever?'
46+
}
4047
})
4148

4249
if res.nil?
4350
print_error("No response for #{target_host}")
4451
return nil
4552
end
4653

47-
temp = JSON.parse(res.body)
54+
begin
55+
temp = JSON.parse(res.body)
56+
rescue JSON::ParserError
57+
print_error("Unable to parse JSON")
58+
return
59+
end
60+
4861
results = JSON.pretty_generate(temp)
4962

5063
if (res.code == 200)
@@ -58,8 +71,8 @@ def run
5871
print_error("Received #{res.code} - Not Found to #{target_host}:#{rport}")
5972
print_error("Response from server:\n\n #{results}\n")
6073
else
61-
print_status("#{res.code}")
62-
print_status("#{results}")
74+
print_status("Received #{res.code}")
75+
print_line("#{results}")
6376
end
6477

6578
if res and res.code == 200 and res.headers['Content-Type'] and res.body.length > 0
@@ -68,9 +81,5 @@ def run
6881
else
6982
print_error("Failed to save the result")
7083
end
71-
72-
rescue ::Exception => e
73-
print_error("Error: #{e.to_s}")
74-
return nil
7584
end
7685
end

0 commit comments

Comments
 (0)