Board logo

標題: :(){ :|: & };: – Fork Bomb ? [打印本頁]

作者: ronstudio    時間: 2014-2-5 00:04     標題: :(){ :|: & };: – 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:53

本帖最後由 凌天羽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 要倒帶救機

但佢地查唔到邊個搞,但同時我今日都唔知當時為乜要倒帶
作者: chancho    時間: 2014-2-5 12:04

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.
作者: Charcoal99    時間: 2014-2-5 15:24

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

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

回復 4# Charcoal99

Thanks a lot for your explanation!!
作者: idiotricky    時間: 2014-2-6 10:29

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


有營養的解釋!
作者: hkguy80    時間: 2014-2-7 17:08

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



    犀利... 咁都明!!!
作者: 凌天羽v    時間: 2014-2-7 17:52

解得好清楚
作者: rayman    時間: 2014-2-7 22:31

提示: 作者被禁止或刪除 內容自動屏蔽
作者: Charcoal99    時間: 2014-2-8 00:44

當中先定義函式 " () { }; " , ....   最後執行此函式。
是你看漏了嗎?
作者: rayman    時間: 2014-2-8 11:47

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





歡迎光臨 電腦領域 HKEPC Hardware (https://h0.hkepc.com/forum/) Powered by Discuz! 7.2