Skip to content

Commit 0720356

Browse files
committed
Performed changes to the correct operation of the module.
1 parent 3d7c9a9 commit 0720356

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

modules/auxiliary/scanner/couchdb/couchdb_login.rb

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ def initialize(info={})
2323
register_options(
2424
[
2525
Opt::RPORT(5984),
26-
OptString.new('TARGETURI', [false, "TARGETURI for CouchDB. Default here is /_users/_all_docs", "/"]),
26+
OptString.new('TARGETURI', [false, "TARGETURI for CouchDB. Default here is /", "/"]),
2727
OptPath.new('USERPASS_FILE', [ false, "File containing users and passwords separated by space, one pair per line",
2828
File.join(Msf::Config.install_root, "data", "wordlists", "http_default_userpass.txt") ]),
2929
OptPath.new('USER_FILE', [ false, "File containing users, one per line",
3030
File.join(Msf::Config.install_root, "data", "wordlists", "http_default_users.txt") ]),
3131
OptPath.new('PASS_FILE', [ false, "File containing passwords, one per line",
32-
File.join(Msf::Config.install_root, "data", "wordlists", "http_default_pass.txt") ])
32+
File.join(Msf::Config.install_root, "data", "wordlists", "http_default_pass.txt") ]),
33+
OptBool.new('USER_AS_PASS', [ false, "Try the username as the password for all users", false]),
3334
], self.class)
3435
end
3536

@@ -38,9 +39,17 @@ def run_host(ip)
3839
user = datastore['USERNAME'].to_s
3940
pass = datastore['PASSWORD'].to_s
4041

42+
if user.nil? || user.strip == ''
43+
each_user_pass do |user, pass|
44+
do_login(user, pass)
45+
end
46+
return
47+
end
48+
4149
vprint_status("#{rhost}:#{rport} - Trying to login with '#{user}' : '#{pass}'")
4250

4351
uri = target_uri.path
52+
4453
res = send_request_cgi({
4554
'uri' => normalize_uri(uri, '_users/_all_docs'),
4655
'method' => 'GET',
@@ -55,18 +64,16 @@ def run_host(ip)
5564
vprint_good("#{rhost}:#{rport} - Successful login with '#{user}' : '#{pass}'")
5665
else
5766
vprint_error("#{rhost}:#{rport} - Failed login with '#{user}' : '#{pass}'")
58-
print_status("Brute-forcing... >:-} ")
59-
each_user_pass do |user, pass|
60-
do_login(user, pass)
61-
end
6267
end
68+
6369
rescue ::Rex::ConnectionError
6470
vprint_error("'#{rhost}':'#{rport}' - Failed to connect to the web server")
6571
end
6672

6773
def do_login(user, pass)
6874
vprint_status("Trying username:'#{user}' with password:'#{pass}'")
6975
begin
76+
7077
uri = target_uri.path
7178
res = send_request_cgi(
7279
{

0 commit comments

Comments
 (0)