@@ -10,12 +10,12 @@ module Msf::Exploit::Remote::HTTP::Wordpress::Helpers
10
10
# @param pass [String] Password
11
11
# @param redirect URL [String] to redirect after successful login
12
12
# @return [Hash] The post data for vars_post Parameter
13
- def wordpress_helper_login_post_data ( user , pass , redirect = nil )
13
+ def wordpress_helper_login_post_data ( user , pass , redirect = nil )
14
14
post_data = {
15
- 'log' => user . to_s ,
16
- 'pwd' => pass . to_s ,
17
- 'redirect_to' => redirect . to_s ,
18
- 'wp-submit' => 'Login'
15
+ 'log' => user . to_s ,
16
+ 'pwd' => pass . to_s ,
17
+ 'redirect_to' => redirect . to_s ,
18
+ 'wp-submit' => 'Login'
19
19
}
20
20
post_data
21
21
end
@@ -31,23 +31,23 @@ def wordpress_helper_login_post_data(user, pass, redirect=nil)
31
31
# @return [String,nil] The location of the new comment/post, nil on error
32
32
def wordpress_helper_post_comment ( comment , comment_post_id , login_cookie , author , email , url )
33
33
vars_post = {
34
- 'comment' => comment ,
35
- 'submit' => 'Post+Comment' ,
36
- 'comment_post_ID' => comment_post_id . to_s ,
37
- 'comment_parent' => '0'
34
+ 'comment' => comment ,
35
+ 'submit' => 'Post+Comment' ,
36
+ 'comment_post_ID' => comment_post_id . to_s ,
37
+ 'comment_parent' => '0'
38
38
}
39
39
vars_post . merge! ( {
40
- 'author' => author ,
41
- 'email' => email ,
42
- 'url' => url ,
40
+ 'author' => author ,
41
+ 'email' => email ,
42
+ 'url' => url
43
43
} ) unless login_cookie
44
44
45
45
options = {
46
- 'uri' => normalize_uri ( target_uri . path , 'wp-comments-post.php' ) ,
47
- 'method' => 'POST'
46
+ 'uri' => normalize_uri ( target_uri . path , 'wp-comments-post.php' ) ,
47
+ 'method' => 'POST'
48
48
}
49
- options . merge! ( { 'vars_post' => vars_post } )
50
- options . merge! ( { 'cookie' => login_cookie } ) if login_cookie
49
+ options . merge! ( { 'vars_post' => vars_post } )
50
+ options . merge! ( { 'cookie' => login_cookie } ) if login_cookie
51
51
res = send_request_cgi ( options )
52
52
if res && res . redirect? && res . redirection
53
53
return wordpress_helper_parse_location_header ( res )
@@ -65,7 +65,7 @@ def wordpress_helper_post_comment(comment, comment_post_id, login_cookie, author
65
65
# @param comments_enabled [Boolean] If true try to find a post id with comments enabled, otherwise return the first found
66
66
# @param login_cookie [String] A valid login cookie to perform the bruteforce as an authenticated user
67
67
# @return [Integer,nil] The post id, nil when nothing found
68
- def wordpress_helper_bruteforce_valid_post_id ( range , comments_enabled = false , login_cookie = nil )
68
+ def wordpress_helper_bruteforce_valid_post_id ( range , comments_enabled = false , login_cookie = nil )
69
69
range . each { |id |
70
70
vprint_status ( "Checking POST ID #{ id } ..." ) if ( id % 100 ) == 0
71
71
body = wordpress_helper_check_post_id ( wordpress_url_post ( id ) , comments_enabled , login_cookie )
@@ -81,15 +81,15 @@ def wordpress_helper_bruteforce_valid_post_id(range, comments_enabled=false, log
81
81
# @param comments_enabled [Boolean] Check if comments are enabled on this post
82
82
# @param login_cookie [String] A valid login cookie to perform the check as an authenticated user
83
83
# @return [String,nil] the HTTP response body of the post, nil otherwise
84
- def wordpress_helper_check_post_id ( uri , comments_enabled = false , login_cookie = nil )
84
+ def wordpress_helper_check_post_id ( uri , comments_enabled = false , login_cookie = nil )
85
85
options = {
86
- 'method' => 'GET' ,
87
- 'uri' => uri
86
+ 'method' => 'GET' ,
87
+ 'uri' => uri
88
88
}
89
- options . merge! ( { 'cookie' => login_cookie } ) if login_cookie
89
+ options . merge! ( { 'cookie' => login_cookie } ) if login_cookie
90
90
res = send_request_cgi ( options )
91
91
# post exists
92
- if res and res . code == 200
92
+ if res && res . code == 200
93
93
# also check if comments are enabled
94
94
if comments_enabled
95
95
if res . body =~ /form.*action.*wp-comments-post\. php/
@@ -123,8 +123,8 @@ def wordpress_helper_parse_location_header(res)
123
123
#
124
124
# @param cookie [String] A valid admin session cookie
125
125
# @return [String,nil] The nonce, nil on error
126
- def wordpress_helper_get_plugin_upload_nonce ( cookie )
127
- uri = normalize_uri ( wordpress_url_backend , 'plugin-install.php' )
126
+ def wordpress_helper_get_plugin_upload_nonce ( cookie , path = nil )
127
+ uri = path || normalize_uri ( wordpress_url_backend , 'plugin-install.php' )
128
128
options = {
129
129
'method' => 'GET' ,
130
130
'uri' => uri ,
@@ -134,6 +134,9 @@ def wordpress_helper_get_plugin_upload_nonce(cookie)
134
134
res = send_request_cgi ( options )
135
135
if res && res . code == 200
136
136
return res . body . to_s [ /id="_wpnonce" name="_wpnonce" value="([a-z0-9]+)"/i , 1 ]
137
+ elsif res && res . redirect? && res . redirection
138
+ path = wordpress_helper_parse_location_header ( res )
139
+ return wordpress_helper_get_plugin_upload_nonce ( cookie , path )
137
140
end
138
141
end
139
142
end
0 commit comments