I looked at this page and can't understand how this works.
This command "exponentially spawns subprocesses until your box locks up".
But why? What I understand less are the colons.
user@host$ :(){ :|:& };:
Description. bash is a sh-compatible command language interpreter that executes commands read from the standard input or from a file. bash also incorporates useful features from the Korn and C shells (ksh and csh).
$1 means an input argument and -z means non-defined or empty. You're testing whether an input argument to the script was defined when running the script.
$1 is the first argument (filename1) $2 is the second argument (dir1)
Bash is a command-line and scripting language for most Unix/Linux-based operating systems. The generated output is in the form of characters.
:(){ :|:& };:
..defines a function named :
, which spawns itself (twice, one pipes into the other), and backgrounds itself.
With line breaks:
:() { :|:& }; :
Renaming the :
function to forkbomb
:
forkbomb() { forkbomb | forkbomb & }; forkbomb
You can prevent such attacks by using ulimit
to limit the number of processes-per-user:
$ ulimit -u 50 $ :(){ :|:& };: -bash: fork: Resource temporarily unavailable $
More permanently, you can use /etc/security/limits.conf
(on Debian and others, at least), for example:
* hard nproc 50
Of course that means you can only run 50 processes, you may want to increase this depending on what the machine is doing!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With