To overload a server Linux
11 marzo 2008, 6:54 Shell , System , Tips & Tricks March 11, 2008, 6:54This morning I read a post that describes an apparent vulnerability of Linux systems. This is actually a sequence of characters that - if launched from command line - creates an infinite loop, resulting in saturation of block RAM and CPU. So this is not a deficiency of Linux, but an obvious logical fallacy of those who throw the string to bash on any operating system that is provided. The author of the post suggests, however, the most simple and effective way to overcome the effects of the microscopic but dangerous script.
Perhaps this article may be useful to dampen somewhat 'apologetic tones with which he praises the steel operating system GNU / Linux: there is a sequence of characters that few, if typed into the terminal, sends the whole system into a tailspin. Here is the offending code:
: () { : | : & };: How can this brief and enigmatic string can cause such havoc?
In reality what happens is quite normal and the explanation, for those with literacy bash script, is as follows: the functions in bash.
The functions in bash, are declared with the syntax:
nomeFunzione() { comando1; comando2; ... comandoN; }
nomeFunzione() { comando1; comando2; ... comandoN; } and are invoked by typing their name and in the normal controls.
Thus, for example, the following code:
saluta(){ echo "ciao"; };saluta that do not declare the function salutes, he prints the word Hello on the terminal, and invoke it.
The offending code function is called: (colon).
Well yes, although it is a particularly exotic legal name for a bash feature.
As you can see now, in light of this, the function (once called) calls itself and redirects its output to another invocation of itself through the pipe (vertical bar). If you do not know the pipe, on which there is no need to dwell in detail for the purposes of explanation (and on which there is ample documentation in turn), just know that they will open up in parallel between the two commands which they appear, so Code: |: appearing in the function body twice and invoke that function in parallel, giving rise to a (double) recursion.
Finally, the & placed at the end of the command has the effect of run in the background.
Now: When the function is launched, calls itself twice in parallel resulting in a bifurcation (fork), each of the two bifurcations, in turn, splits, and so on. The fact that the functions are run in the background ensures that a terminandone (for example with the kill command), those that you have created (so the two bifurcations and their descendants) will not be terminated in their turn as would be normally. This unstoppable startup functions, which proceeds exponentially, eventually saturating the resources (CPU and memory) and after a while 'time arrives, freezing the system.
The antidote. For the more timid: the antidote for these fork bombs and there is simply putting a limit on the number of processes may be started by a user.
Original Post:
http://www.tuxbay.org/index.php?option=com_content&task=view&id=152&Itemid=1














