Bash Fork Bomb
Hello everyone! This post will be about a famous bash script the purpose of which is to harm a system by consuming a big amount of its resources.
This script is commonly known as “Fork Bomb” and this is how it works :
- We create a function called
: - We write the function’s code, which will be calling itself recursively and creating two child processes, which can’t be terminated by themselves because they are running in the background (this loop will be run forever)
- We call the function to trigger the bomb
Bash code :
:(){ :|: & };:
Detailed explanation
1.- :() creates the function with name :
2.- Inside {}we write the code, which will be :|: &
:calls the function,|pipes its output into another call to:, and we tell it to run in the background with&
3.- More specifically, what & does is disowning the function, which makes the child processes unable to be auto-killed when the father process is terminated. You can find more information in here
4.- Finally, we use the ; as a command separator and we run the function with :
DISCLAIMER
Please do not use this command unless you are ready to see your PC crash and reboot it.
The command doesn’t require super-user privileges to run.
I hope this little article was of good interest to you, see you later :)