Skip to content

Commit e2fe70d

Browse files
committed
convert store_valid_credential to named params
1 parent 3bc4ac6 commit e2fe70d

16 files changed

+21
-25
lines changed

lib/msf/core/module/auth.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Msf::Module::Auth
2-
def store_valid_credential(user, private, private_type, proof = nil)
2+
def store_valid_credential(user:, private:, private_type: :password, proof: nil)
33
service_data = {}
44
if self.respond_to? ("service_details")
55
service_data = service_details

modules/auxiliary/admin/http/wp_custom_contact_forms.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def run
113113
# login successful
114114
if cookie
115115
print_status("User #{username} with password #{password} successfully created")
116-
store_valid_credential(username, password, :password, cookie)
116+
store_valid_credential(user: username, private: password, proof: cookie)
117117
else
118118
print_error("User creation failed")
119119
return

modules/auxiliary/admin/http/wp_easycart_privilege_escalation.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def run
7878
print_error("Failed to authenticate with WordPress")
7979
return
8080
end
81-
store_valid_credential(username, password, :password, cookie)
81+
store_valid_credential(user: username, private: password, proof: cookie)
8282
print_good("Authenticated with WordPress")
8383

8484
new_email = "#{Rex::Text.rand_text_alpha(5)}@#{Rex::Text.rand_text_alpha(5)}.com"

modules/auxiliary/admin/http/wp_wplms_privilege_escalation.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def run
9898
print_status("Authenticating with WordPress using #{username}:#{password}...")
9999
cookie = wordpress_login(username, password)
100100
fail_with(Failure::NoAccess, 'Failed to authenticate with WordPress') if cookie.nil?
101-
store_valid_credential(username, password, :password, cookie)
101+
store_valid_credential(user: username, private: password, proof: cookie)
102102
print_good("Authenticated with WordPress")
103103

104104
new_email = "#{Rex::Text.rand_text_alpha(5)}@#{Rex::Text.rand_text_alpha(5)}.com"

modules/auxiliary/dos/http/wordpress_long_password_dos.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def user_exists(user)
8484
exists = wordpress_user_exists?(user)
8585
if exists
8686
print_good("Username \"#{username}\" is valid")
87-
store_valid_credential(user, nil, :password, "WEBAPP=\"Wordpress\", VHOST=#{vhost}")
87+
store_valid_credential(user: user, private: nil, proof: "WEBAPP=\"Wordpress\", VHOST=#{vhost}")
8888
return true
8989
else
9090
print_error("\"#{user}\" is not a valid username")

modules/auxiliary/scanner/http/cisco_ironport_enum.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def do_login(user, pass)
150150
if res and res.get_cookies.include?('authenticated=')
151151
print_good("#{rhost}:#{rport} - SUCCESSFUL LOGIN - #{user.inspect}:#{pass.inspect}")
152152

153-
store_valid_credential(user, pass, :password, res.get_cookies.inspect)
153+
store_valid_credential(user: user, private: pass, proof: res.get_cookies.inspect)
154154
return :next_user
155155

156156
else

modules/auxiliary/scanner/http/wordpress_login_enum.rb

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ def service_details
110110
module_fullname: fullname,
111111
origin_type: :service,
112112
last_attempted_at: DateTime.now,
113-
status: Metasploit::Model::Login::Status::SUCCESSFUL
113+
# infer status from state when called
114+
status: (@validate_only ? Metasploit::Model::Login::Status::UNTRIED : Metasploit::Model::Login::Status::SUCCESSFUL)
114115
}
115116
end
116117

@@ -120,14 +121,9 @@ def validate_user(user=nil)
120121
exists = wordpress_user_exists?(user)
121122
if exists
122123
print_good("#{target_uri} - WordPress User-Validation - Username: '#{user}' - is VALID")
123-
124-
report_cred(
125-
ip: rhost,
126-
port: rport,
127-
user: user,
128-
status: Metasploit::Model::Login::Status::UNTRIED
129-
)
130-
124+
@validate_only = true
125+
store_valid_credential(user: user, private: nil)
126+
@validate_only = false
131127
@users_found[user] = :reported
132128
return :next_user
133129
else
@@ -145,7 +141,7 @@ def do_login(user=nil, pass=nil)
145141
if cookie
146142
print_good("#{target_uri} - WordPress Brute Force - SUCCESSFUL login for '#{user}' : '#{pass}'")
147143

148-
store_valid_credential(user, pass, :password, cookie)
144+
store_valid_credential(user: user, private: pass, proof: cookie)
149145

150146
return :next_user
151147
else

modules/auxiliary/scanner/http/wp_nextgen_galley_file_read.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def run_host(ip)
9898
print_error("Unable to login as: #{user}")
9999
return
100100
end
101-
store_valid_credential(user, password, :password, cookie)
101+
store_valid_credential(user: user, private: password, proof: cookie)
102102

103103
vprint_status("Trying to get nonce...")
104104
nonce = get_nonce(cookie)

modules/auxiliary/scanner/http/wp_subscribe_comments_file_read.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def run_host(ip)
120120
print_error("Unable to login as: #{user}")
121121
return
122122
end
123-
store_valid_credential(user, password, :password, cookie)
123+
store_valid_credential(user: user, private: password, proof: cookie)
124124

125125
vprint_status("Trying to get nonce...")
126126
nonce = get_nonce(cookie)

modules/exploits/unix/webapp/wp_admin_shell_upload.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def exploit
7171
cookie = wordpress_login(username, password)
7272
fail_with(Failure::NoAccess, 'Failed to authenticate with WordPress') if cookie.nil?
7373
print_good("Authenticated with WordPress")
74-
store_valid_credential(username, password, :password, cookie)
74+
store_valid_credential(user: username, private: password, proof: cookie)
7575

7676
print_status("Preparing payload...")
7777
plugin_name = Rex::Text.rand_text_alpha(10)

0 commit comments

Comments
 (0)