Monday 29 October 2018

linux - What this command :(){ :|: & };: does?



What does this shell command do in Linux


:(){ :|: & };:

How can it be used in Denial of Service attacks?



Answer



It's a fork bomb. I actually have that written on my whiteboard (as a joke) as I speak. Don't run it.


:()         # define a function named :, () defines a function in bash
{
: | :; # the pipe needs two instances of this function, which forks two shells
}
; # end function definition
: # run it

So, the first run makes 2 subshells, which then each runs 2 more subshells...


: is a built in command in bash. It's kind of a "null" no-op command. It used to be the comment character, before there was a comment character. Now, it's got a small use as a no-op, but really used here because it's more cryptic, you look at :() and think WTH is that?


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...