Writing a Simple Fork Bomb on Windows
A fork bomb is a denial-of-service (DoS) attack that rapidly creates new processes to exhaust system resources, causing the system to slow down or crash[2][6]. While the classic fork bomb exploits the fork() system call in Unix-like systems, Windows does not have a direct equivalent. However, similar behavior can be achieved using batch scripts or other programming methods that recursively spawn new processes[3][6].
Warning: Running a fork bomb will likely crash your system and may result in data loss. Do not run this code on any system you care about.
Batch File Fork Bomb (Windows)
The simplest way to create a fork bomb in Windows is with a one-line batch file:
%0|%0
%0 refers to the currently running batch file.
- The
| (pipe) operator causes the batch file to call itself recursively, spawning two new processes each time.
- This quickly leads to exponential growth in the number of processes, overwhelming the system[4][8].
How it works:
Each instance of the batch file spawns two more, and each of those spawns two more, and so on, rapidly consuming all available process slots and CPU resources[4].
Alternative Batch Fork Bomb
Another common batch fork bomb uses an infinite loop with the start command:
@echo off
:start
start %0
goto start
- This script continuously starts new instances of itself, leading to a rapid increase in the number of processes[5].
PowerShell Fork Bomb
A similar effect can be achieved in PowerShell:
while ($true) { Start-Process powershell -ArgumentList "-NoExit", "while ($true) { Start-Process powershell }" }
- This command starts new PowerShell processes in an infinite loop, quickly overwhelming the system[5].
Summary Table: Simple Windows Fork Bombs
| Method | Code Example | Description |
|---|
| Batch (pipe) | `%0 | %0` |
| Batch (start) | start %0 in a loop | Continuously starts new instances of itself |
| PowerShell | See above | Infinite loop spawning new PowerShell processes |
Important Notes
- Windows does not have a native
fork() system call like Unix, so these methods rely on recursive process creation using batch or scripting[3][6].
- Running a fork bomb will make your system unresponsive and may require a hard reboot to recover[2][6].
- Do not run fork bombs on production or important systems.
Prevention
- Limit the number of processes a user can create (not as straightforward in Windows as in Linux, but can be managed via Group Policy or other administrative tools)[2][6].
- Monitor and restrict execution of untrusted scripts and batch files.
In summary:
A simple Windows fork bomb can be written as a batch file containing %0|%0, which recursively spawns new processes until the system is overwhelmed[4][8]. Use this knowledge responsibly and only in controlled, safe environments.