天泽在线_网页版CS_CS对战平台_Cs1.6_amxx_sma插件_CS论坛

标题: Linux fork炸弹及其预防方法 [打印本页]

作者: admin    时间: 2013-2-9 09:28
标题: Linux fork炸弹及其预防方法

在Linux系统下执行这段fork 炸弹代码就会引起死机,一旦执行起来后,唯一的方法就是重启系统。实际上这段代码是一段无限递归代码,将系统资源耗尽。

fork 炸弹代码:

.(){ .|.& };.

本文下面有这段代码的详细解释,为了防止fork炸弹,方法就是限制用户能够启动的进程数。具体做法,编辑/etc/security/limits.conf文件,在末尾加入 :

* hard nproc 200

将用户的进程数限制为200,经过测试,root账户不受这个限制。

Q. Can you explain following bash code or bash fork() bomb?

:{ :|:& };:

A. This is a bash function. It gets called recursively (recursive function). This is most horrible code for any Unix / Linux box. It is often used by sys admin to test user processes limitations (Linux process limits can be configured via /etc/security/limits.conf and PAM).

Once a successful fork bomb has been activated in a system it may not be possible to resume normal operation without rebooting, as the only solution to a fork bomb is to destroy all instances of it.

WARNING! These examples may crash your computer if executed.

Understanding :{ :|:& };: fork() bomb code

: - It is a function name. It accepts no arguments at all. Generally, bash function is defined as follows:

foo(){

arg1=

echo ''

#do_something on $arg argument

}

fork() bomb is defined as follows:

:{

:|:&

};:

:|: - Next it call itself using programming technique called recursion and pipes the output to another call of the function ':'. The worst part is function get called two times to bomb your system.

& - Puts the function call in the background so child cannot die at all and start eating system resources.

; - Terminate the function definition

: - Call (run) the function aka set the fork() bomb.

Here is more human readable code:


bomb() {bomb | bomb &}; bombProperly configured Linux / UNIX box should not go down when fork() bomb sets off.



作者: 张大炮    时间: 2013-2-19 08:12
声明一下:本人看贴和回贴的规则,好贴必看,精华贴必回。  
作者: 丹琮博    时间: 2013-2-20 02:37
谢谢分享  
作者: 阿克    时间: 2013-2-20 11:22
努力~~各位。。。  
作者: 更惨的时间    时间: 2013-2-22 03:34
初来乍到,请多多关照。。。嘿嘿,回个贴表明我来过。  
作者: 吊丝虫    时间: 2013-2-22 22:06
先看看怎么样!  
作者: ρá??    时间: 2014-12-4 05:57
老大,我好崇拜你哟  
作者: 迩的微笑    时间: 2014-12-26 22:23
没人理我。。。。  
作者: 大海无量    时间: 2015-1-27 02:57
呵呵,明白了  
作者: 花落谁家    时间: 2015-3-1 02:03
支持你就顶你  
作者: 地狱灬王朝    时间: 2015-3-29 07:36
谁都不容易啊 ~~  
作者: 低吟_花非花格调    时间: 2015-5-2 03:32
初来乍到,请多多关照。。。嘿嘿,回个贴表明我来过。  
作者: 张伊康    时间: 2015-6-8 06:29
琴棋书画不会,洗衣做饭嫌累。  
作者: 我靠    时间: 2015-7-14 02:29
好帖子,要顶!
作者: 神乐    时间: 2015-8-17 17:36
勤奋真能造就财富吗?  
作者: 可惜错过你    时间: 2015-9-19 01:44
今天无聊来逛逛  
作者: 帅哥花落去    时间: 2015-10-21 21:14
好啊,谢楼主
作者: 平迟越翠    时间: 2015-11-29 02:58
要不我崇拜你?行吗?  
作者: 碰见过然    时间: 2016-1-13 05:08
做一个,做好了,请看  
作者: 上官天尘    时间: 2016-2-22 14:51
满城尽待年终奖,弄弄才是喇叭腔  
作者: 缨枫浮    时间: 2016-4-14 21:00
加油啊!偶一定会追随你左右,偶坚定此贴必然会起到抛砖引玉的作用~  
作者: 胸手突袭    时间: 2016-6-17 08:18
回复一下  
作者: 我是文风    时间: 2016-7-28 17:42
这个贴不错!!!!!看了之后就要回复贴子,呵呵  
作者: 巅峰魔神    时间: 2016-9-27 10:23
要不我崇拜你?行吗?  
作者: 毛部波    时间: 2016-11-21 14:55
我毫不犹豫地把楼主的这个帖子收藏了  
作者: 炳寅佃    时间: 2017-1-20 02:10
没有医保和寿险的,天黑后请不要见义勇为……  




欢迎光临 天泽在线_网页版CS_CS对战平台_Cs1.6_amxx_sma插件_CS论坛 (https://bbs.tianzept.com/) Powered by Discuz! X3.4