LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices

Reply
 
Search this Thread
Old 05-03-2011, 10:36 AM   #1
grob115
Member
 
Registered: Oct 2005
Posts: 526

Rep: Reputation: 32
crash () { crash|crash& }; crash


Sorry I know this would bring the server to its knees if ulimit is not set. However, can someone explain to me why this works.
crash () { crash|crash& }; crash

But either of the following doesn't?

This should recursively calls the function "crash".
crash () { crash }; crash

This should recursively calls the function "crash", except to throw it into the background.
crash () { crash& }; crash
 
Old 05-04-2011, 12:08 AM   #2
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 18 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290
Hello,

At the following links you'll find all information and explanation about Bash fork bombs you might need:
http://www.cyberciti.biz/faq/underst...ash-fork-bomb/
http://en.wikipedia.org/wiki/Fork_bomb

Kind regards,

Eric
 
Old 05-05-2011, 10:14 AM   #3
grob115
Member
 
Registered: Oct 2005
Posts: 526

Original Poster
Rep: Reputation: 32
Can you tell me why the following wouldn't work? It's still calling itself recursively and putting the child processes into background.
crash () { crash& }; crash

Also, not sure why the following would regain the process table slots as per http://en.wikipedia.org/wiki/Fork_bomb
while (sleep 100 &!) do; done

What is the ! doing? Assuming it's the same as the following, it still is taking back one process slot. And this isn't being released back to the system for an admin to run any commands to kill the bomb.
while (true) do; done
 
Old 05-05-2011, 10:42 AM   #4
unixfool
Member
 
Registered: May 2005
Location: Northern VA
Distribution: Slackware, Ubuntu, FreeBSD, OpenBSD, OS X
Posts: 781
Blog Entries: 8

Rep: Reputation: 157Reputation: 157
I'm lost.

What are you trying to do? Create a fork bomb, prevent a fork bomb, or just understand the makings of a fork bomb?

The reason I'm asking is that I dunno if it would be kosher to assist you with creating a fork bomb. Preventing one might be doable, along with helping one comprehend.

But this applies to zsh but it may well apply to bash also:


Quote:
According to that Wikipedia article, the purpose of the complete command is to create many harmless jobs that will disable the fork bomb because it will no longer able to spawn even more children.

According to the zsh manual,

If a job is started with &|' or &!', then that job is immediately disowned. After startup, it does not have a place in the job table, and is not subject to the job control features described here.

I am not sure how to achieve the same with bash. However, something like the following might do:

nohup sleep 100 &

Then the post after it:

Quote:
Hi guys, I'm the guy who wrote that part of the Wikipedia article (and who "discovered" this cure after accidentally starting the fork bomb on my system!).

The reason for the "&!" instead of "&" is indeed to prevent zsh from doing job-control over the new process, i.e., trying to care when and if it finished. I don't remember exactly why job control was a problem when I tried it, but it was. You can actually try it to see how the "cure" works and what happens if you don't prevent job control. Maybe the problem with job control had to do with some bug in zsh that doesn't even exist in bash, and maybe it is no longer relevant in zsh either.

So try just an "&" with bash, and if job control is interfering, try to disable it ("set +m") and hopefully this would work.

You're right that the wikipedia article should probably not be zsh dependent.
 
Old 05-05-2011, 10:48 AM   #5
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Hi,

This crash () { crash& }; crash does "work". Its just not fast enough to do any real harm.

Open 2 terminals, start top in one and the following in the other: crash () { sleep 1 ; crash& }; crash

You'll see the sleep command and a bash session that change pid every 1 second and this will go on forever. Without the sleep 1 it will run for a short while before it is killed by the system. It is just not fast enough.

The original command multiplies very fast (1, 2, 4, 8, 16 etc.) and overwhelms the system if no precautions are taken.

Hope this clears things up.
 
1 members found this post helpful.
Old 05-06-2011, 10:09 PM   #6
grob115
Member
 
Registered: Oct 2005
Posts: 526

Original Poster
Rep: Reputation: 32
druuna, thanks. I get what you say.
 
Old 05-07-2011, 03:06 AM   #7
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
You're welcome
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Crash, Crash, Crash, Crash and You Guessed it Crash! little_penguin Suse/Novell 8 07-04-2005 09:34 AM
X.Org crash........very odd crash..... doctorzoidberg Linux - Software 11 01-07-2005 07:38 PM
Stripes & Crash on Xorg acarpetknight Fedora 3 12-20-2004 07:50 AM
kde crash, then other crash, now weird problems true_atlantis Linux - Laptop and Netbook 1 04-28-2004 12:01 AM
xmms crash xine crash mplayer crash paledread Linux - Software 9 03-09-2004 07:09 AM


All times are GMT -5. The time now is 08:46 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration