Skip to content

Commit 227c0f7

Browse files
committed
Record credentials when wordpress_login succeeds
1 parent bdeeb8e commit 227c0f7

File tree

1 file changed

+33
-10
lines changed
  • lib/msf/core/exploit/http/wordpress

1 file changed

+33
-10
lines changed

lib/msf/core/exploit/http/wordpress/login.rb

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,41 @@ def wordpress_login(user, pass, timeout = 20)
1414
'uri' => wordpress_url_login,
1515
'vars_post' => wordpress_helper_login_post_data(user, pass, redirect)
1616
}, timeout)
17-
if res && res.redirect? && res.redirection && res.redirection.to_s == redirect
18-
cookies = res.get_cookies
19-
# Check if a valid wordpress cookie is returned
20-
return cookies if
21-
# current Wordpress
22-
cookies =~ /wordpress(?:_sec)?_logged_in_[^=]+=[^;]+;/i ||
23-
# Wordpress 2.0
24-
cookies =~ /wordpress(?:user|pass)_[^=]+=[^;]+;/i ||
25-
# Wordpress 2.5
26-
cookies =~ /wordpress_[a-z0-9]+=[^;]+;/i
17+
cookies = res.get_cookies
18+
19+
if cookies && (
20+
# current Wordpress (2.6+)
21+
cookies =~ /wordpress_(?:sec|logged_in_)[^=]+=[^;]+;/i ||
22+
# Wordpress 2.5
23+
cookies =~ /wordpress_[a-f0-9]+=[^;]+;/i ||
24+
# Wordpress 2.0
25+
cookies =~ /wordpress(?:user|pass)_[^=]+=[^;]+;/i
26+
)
27+
28+
service_data = {
29+
address: rhost,
30+
port: rport,
31+
protocol: 'tcp',
32+
service_name: 'http',
33+
workspace_id: myworkspace.id,
34+
}
35+
36+
cdata = {
37+
module_fullname: self.fullname,
38+
origin_type: :service,
39+
username: user,
40+
private_data: pass,
41+
private_type: :password,
42+
}.merge(service_data)
43+
44+
core = create_credential(cdata)
45+
login_data = { core: core }.merge(service_data)
46+
47+
create_credential_login(login_data)
48+
return cookies
2749
end
2850

51+
2952
nil
3053
end
3154
end

0 commit comments

Comments
 (0)