Have you ever wondered about the potential of a Fork Bomb? It is the smallest and simplest code which can be written in most of the programming languages to crash your system.

In Unix/Linux Operating systems, the fork() system call is used to create a new process, called child process, which will be a copy of the caller process, called parent process. It takes no arguments but it will return a Process ID (PID).

The fork bombs are created by recursively calling the fork() which creates new process exponentially which results in the exhaustion of the system resources. This is a type of Denial of Service (DoS) attack as it leads to starvation of other processes in the system. The fork bombs can make the system slow or run out of resources which results in crashing the system.

In C, we can write a fork bomb as shown below,

#include <unistd.h>
int main(void)
 while(1) fork();

In Bash shell,

:(){ :|:& };:

Where the :() is a function ‘:’ without parameters.

The parenthesis ‘{‘ and ’}’ are used to start and end function block.

:|: loads two copies of the function’:’

& is used to make the process run in background.

; is used to end the function definition

: at the end is used for recursively calling the function, each time it starts two more.

If you want to stop the fork bomb, you have to kill/stop all the running instance of the fork() call or the easiest way is to reboot your system.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s