:(){ :|: & };: – Fork Bomb ?

I just found a funny article "8 Deadly Commands You Should Never Run on Linux"
http://www.howtogeek.com/125157/ ... never-run-on-linux/

One of it is talking about :(){ :|: & };: – Fork Bomb which"This short line defines a shell function that creates new copies of itself. The process continually replicates itself, and its copies continually replicate themselves, quickly taking up all your CPU time and memory. This can cause your computer to freeze. It’s basically a denial-of-service attack."

Can anyone explain how those command fork itself ar?

本帖最後由 凌天羽v 於 2014-2-5 07:59 編輯

要死總會有好多方法的。

以前初學LINUX 果時試過用 user account telnet 入大學既aix RS6000 度玩wc -w `cat `ls -1 /proc`` >> 1.txt (大約係咁,重點係word count 人家個proc 每一個file )

結果搞到buffer overflow 然後連hdd 都花埋跟住搞到大學server 要倒帶救機

但佢地查唔到邊個搞,但同時我今日都唔知當時為乜要倒帶

TOP

it is very easy to write to the system disk. your system disk may not be the /dev/sda(1). it is better to check before do anything about /dev/sdX.

TOP

本帖最後由 Charcoal99 於 2014-2-5 19:51 編輯

:(){ :|: & };:
把冒號換個名字來看, 以 func 為例,  方便解說, 即      func() { func | func & }; func
當中先定義函式 " () { }; " 裡面會 pipeline " | " 一同名函式並以背景模式 " & " 執行, 最後執行此函式。
bash 或其他 shell 實現pipeline時便會用到 fork() 系統函式。
由於此是 recursive 函式, 會以指數形式增長消耗記憶體。

TOP

回復 4# Charcoal99

Thanks a lot for your explanation!!

TOP

:(){ :|: & };:
把冒號換個名字來看, 以 func 為例,  方便解說, 即      func() { func | func & }; func
...
Charcoal99 發表於 2014-2-5 15:24


有營養的解釋!

TOP

:(){ :|: & };:
把冒號換個名字來看, 以 func 為例,  方便解說, 即      func() { func | func & }; func
...
Charcoal99 發表於 2014-2-5 15:24



    犀利... 咁都明!!!

TOP

解得好清楚

TOP

提示: 作者被禁止或刪除 內容自動屏蔽

TOP

當中先定義函式 " () { }; " , ....   最後執行此函式。
是你看漏了嗎?

TOP