0

I accidentally ran a malicious script. The script was

for i in {1..10000}  
 do
sudo kill -9  $i
 done

Did I destroy my machine?

GAD3R
  • 66,769

1 Answers1

1

Let's go through this in detail:

  1. {1..10000} expands to a space-separated list of numbers 1 through 10,000. This may or may not be a large number of currently running PIDs:

    $ cat /proc/sys/kernel/pid_max
    4194304
    

    It is still likely to kill various important processes started shortly after boot, such as various services. Your machine is likely going to be unusable, and you might need to reboot.

  2. PID 1 is special and can't be killed this way.

  3. To run sudo commands on a typical system you must have either run sudo successfully recently or you'll need to enter your password to run it. If you entered your password the malicious script could easily have read it. The script could also have done more than you've shown, in ways which would be hard to detect, to give permanent access to your machine either from the Internet or using some new account. Basically, once you've run a malicious script which does anything with sudo you want to consider your computer compromised. If you're completely sure the command you ran was only and exactly what you posted you should be fine, but there are ways to poison the clipboard from web pages, copying more code than is visible.

l0b0
  • 51,350