Find the answer to your Linux question:
Results 1 to 6 of 6
Hi Recently i saw a post with the following script: Code: :() { :|: & } ; : Out of curiosity i ran it on my machine - and it ...
  1. #1
    Just Joined!
    Join Date
    Sep 2007
    Posts
    18

    dangerous script

    Hi

    Recently i saw a post with the following script:
    Code:
    :() { :|: & } ; :
    Out of curiosity i ran it on my machine - and it completely froze:
    i even couldn't connect via ssh. I had to do a cold start...

    Can anybody explain what exactly this script does?
    I have no idea what those brackets and colons mean.

    Thank You
    Jody

  2. #2
    Linux Guru Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    2,096
    It´s a fork bomb.
    It forks children and waits for their completion, but the childs also fork childs and wait....
    That grows exponentially.

    So the machines´ load explodes and it will run out of memory eventually.

    You can prevent that by setting limits.
    Which might be a good idea in a multi-user environment
    You must always face the curtain with a bow.

  3. #3
    Just Joined!
    Join Date
    Sep 2007
    Posts
    18
    Thank you for your reply

    I'd like to understand the details:
    Could you explain in more detail the different parts?
    Like which is the command for forking, what is the
    meaning of the curly brackets and their content, and
    what do the colons mean?

    Or perhaps you can give a ointer where i can read about this?
    (I tried googling these things, but googling for colons or brackets doesn't work.)

    Thank You
    Jody

  4. #4
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    The : are equal to true and the others...well they may actually depend on context so I'm not sure...but you can try here

    Advanced Bash-Scripting Guide

    If I had to guess
    Code:
    :() { :|: & } ; :
    
    :() is a function declaration
    {}this is the body of the function
    :|:& is the contents of the function
    and finally : is caling the function..Like I said guess
    Last edited by gerard4143; 03-17-2010 at 05:02 PM.
    Make mine Arch Linux

  5. #5
    Linux Enthusiast scathefire's Avatar
    Join Date
    Jan 2010
    Location
    Western Kentucky
    Posts
    616
    linux user # 503963

  6. #6
    Trusted Penguin elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    2,298
    Quote Originally Posted by jody View Post
    Hi

    Recently i saw a post with the following script:
    Code:
    :() { :|: & } ; :
    Out of curiosity i ran it on my machine - and it completely froze:
    i even couldn't connect via ssh. I had to do a cold start...

    Can anybody explain what exactly this script does?
    I have no idea what those brackets and colons mean.

    Thank You
    Jody
    Code:
    function fork() {
      fork | fork &
    }
    fork()
    is equivalent. It works by starting new processes in the background, each of which starts new processes. Eventually the computer can't keep up with the number of processes being started.

    By coincidence, I am wearing a t-shirt with
    Code:
    :() { :|: & } ; :
    on it
    If we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)


    My new blog. It's probably not as good as I think it is.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...