:(){ :|: &};:

0 views
Skip to first unread message

小马xiaoma

unread,
Sep 2, 2010, 4:06:25 AM9/2/10
to sh...@googlegroups.com
标题是一行bash shell命令, 有高人能解释一下啥意思么?

Ian Yang

unread,
Sep 2, 2010, 4:09:12 AM9/2/10
to sh...@googlegroups.com
echo ':(){ :|: &};:' | sed 's/:/func/g'

2010/9/2 小马xiaoma <cnxi...@gmail.com>
>
> 标题是一行bash shell命令, 有高人能解释一下啥意思么?

--
Sincerely, Ian Yang

Twitter @doitian
http://www.doitian.com

机械唯物主义 : linjunhalida

unread,
Sep 2, 2010, 4:09:45 AM9/2/10
to sh...@googlegroups.com

机械唯物主义 : linjunhalida

unread,
Sep 2, 2010, 4:10:37 AM9/2/10
to sh...@googlegroups.com
DO NOT RUN THIS!! IT WILL LOCK UP YOUR SYSTEM!!
2010/9/2 机械唯物主义 : linjunhalida <linjun...@gmail.com>

Thomas Iverson

unread,
Sep 2, 2010, 4:11:05 AM9/2/10
to sh...@googlegroups.com
2010/9/2 小马xiaoma <cnxi...@gmail.com>:
> 标题是一行bash shell命令, 有高人能解释一下啥意思么?
>

2年前玩过,设个参数就可以防止这个东西搞破坏了

--
ghosTM55
Shanghai Linux User Group

Keep It Simple Stupid
http://www.ghosTunix.org
http://facebook/ghosTM55
http://twitter.com/ghosTM55

Zhang Jiejing

unread,
Sep 2, 2010, 4:14:53 AM9/2/10
to sh...@googlegroups.com
还是run一下吧, 根据2.6的fork进程的方法, 应该不会lock up 你的系统。
我没试过, 一会重启下试试。

Best regards,
Zhang Jiejing

Ian Yang

unread,
Sep 2, 2010, 4:27:59 AM9/2/10
to sh...@googlegroups.com
":" 在Bash中可以做空命令用

比如清空一个文件

: > /tmp/file

":"也能当函数名,把它全替换下,再从单行转成多行

func() {
func | func &
}

func

不停Fork出无限递归的进程

2010/9/2 Ian Yang <doit...@gmail.com>:

小马xiaoma

unread,
Sep 2, 2010, 4:41:12 AM9/2/10
to sh...@googlegroups.com
我仍然有一个疑问,那就是 & 在这里的作用,加不加&有何区别。

l5g

unread,
Sep 2, 2010, 4:43:40 AM9/2/10
to sh...@googlegroups.com
定义一个函数递归调用?

Ian Yang

unread,
Sep 2, 2010, 4:43:54 AM9/2/10
to sh...@googlegroups.com
man bash

搜索 background

2010/9/2 小马xiaoma <cnxi...@gmail.com>:

--

机械唯物主义 : linjunhalida

unread,
Sep 2, 2010, 4:44:19 AM9/2/10
to sh...@googlegroups.com
func | func& 表示执行一个, fork一个在后台.

2010/9/2 小马xiaoma <cnxi...@gmail.com>

ablo

unread,
Sep 2, 2010, 5:28:12 AM9/2/10
to sh...@googlegroups.com
我的ubuntu系统被搞死了,硬件重启。
--
http://abloz.com
http://twitter.com/ablozhou

机械唯物主义 : linjunhalida

unread,
Sep 2, 2010, 10:12:09 PM9/2/10
to sh...@googlegroups.com
都说了不要运行啦. 
我去找个虚拟机试试看...

2010/9/2 ablo <ablo...@gmail.com>

机械唯物主义 : linjunhalida

unread,
Sep 2, 2010, 10:15:24 PM9/2/10
to sh...@googlegroups.com
虚拟机卡死啦, cpu全占满了, 还好我是多核.
正常关闭无法关, 强制退出可以.

2010/9/3 机械唯物主义 : linjunhalida <linjun...@gmail.com>

Yuan Zhang

unread,
Sep 2, 2010, 10:22:26 PM9/2/10
to sh...@googlegroups.com
还好我没有试着这个玩意儿,就是感觉这个语句有些蹊跷。

2010/9/3 机械唯物主义 : linjunhalida <linjun...@gmail.com>



--
沉之 and fall

tiger

unread,
Sep 3, 2010, 4:57:06 AM9/3/10
to sh...@googlegroups.com

这个东西都被讨论N年了

在2010-09-02,ablo <ablo...@gmail.com> 写道:
-----原始邮件-----
发件人:ablo <ablo...@gmail.com>
发送时间:2010年9月2日 星期四
收件人:sh...@googlegroups.com
主题:Re: [shlug] :(){ :|: &};:



网易邮箱,没有垃圾邮件的邮箱。

Sami Zhan

unread,
Sep 3, 2010, 5:17:53 AM9/3/10
to sh...@googlegroups.com

我爱bash啊。。。不过这个没完过。。貌似后果会比较严重是吧??
虚拟机跑不动么,来个archlinux最小安装(只选择base包)总不会有问题吧

vivian huang

unread,
Sep 3, 2010, 8:53:53 AM9/3/10
to sh...@googlegroups.com
: >/tmp/file 和>/tmp/file 作用一样吧,为何多写一个":"

2010/9/2 Ian Yang <doit...@gmail.com>

oooo...@gmail.com

unread,
Sep 3, 2010, 9:10:09 AM9/3/10
to sh...@googlegroups.com


On Thu, 2 Sep 2010 16:06:25 +0800
小马xiaoma <cnxi...@gmail.com> wrote:

> 标题是一行bash shell命令, 有高人能解释一下啥意思么?
:是一个函数的定义, 该函数不断的调用自身并且fork子进程.
其实:换作别的合法的表示符也是可以的, 例如.

Sherlock

unread,
Sep 6, 2010, 9:15:09 AM9/6/10
to sh...@googlegroups.com
加了& 就不能ctrl+c
不加还能break 不用重启




--
==========
      InitX
==========

Su Wang

unread,
Sep 6, 2010, 9:52:47 AM9/6/10
to sh...@googlegroups.com
降低wmware-vmx.exe进程的优先级至“低“就不会卡死
--
We hold these truths to be self-evident, that all men are created equal, that they are endowed by their Creator with certain unalienable Rights, that among these are Life, Liberty and the pursuit of Happiness.

Sherlock

unread,
Sep 6, 2010, 10:01:54 AM9/6/10
to sh...@googlegroups.com
也不是卡死,就是fork的时候,你keyborad的响应会降低。


2010/9/6 Su Wang <wang...@gmail.com>



--
==========
      InitX
==========

Su Wang

unread,
Sep 6, 2010, 10:10:19 AM9/6/10
to sh...@googlegroups.com
有次尝试了一下将正在编译程序的vmware优先级提高至”RT“,host马上就挂了,放了一晚上都没响应,最后cold reboot。发现虚机中compile过程也没完成,估计是host系统和vmware进入deadlock了

Bill Liao

unread,
Sep 6, 2010, 8:38:45 PM9/6/10
to sh...@googlegroups.com
我怎么觉得和 CPyUG昨天那个thread里面讨论fork很像啊..
都是递归了.
2010/9/2 机械唯物主义 : linjunhalida <linjun...@gmail.com>



--
If the dream is BIG enough,the facts don't count!

yishan.mao

unread,
Sep 12, 2010, 11:02:34 AM9/12/10
to sh...@googlegroups.com
请参见: http://www.vpsee.com/2010/09/limit-linux-user-process/

----下面为引用----
最简单的 bash fork 炸弹: : () { : | : & } ; :

上面几个符号看上去很复杂,其实如果写成下面这个样子就好懂了,: 是函数名,执行一个调用自己的递归并且 pipe 到自己,&
表示后台执行程序,最后的一个 : 是在函数外调用和执行 : () 这个函数的意思:
: () {
: | : &
}; :

如何避免 fork 炸弹呢?方法很简单,只要限制每个用户可以调用的进程数就可以避免,这个可以通过修改 vi
/etc/security/limits.conf 文件来设定:
...


2010/9/7 Bill Liao <lwlw...@gmail.com>:

--
~~~~ keep it simple ~~~~

姚宗友

unread,
Sep 16, 2010, 8:28:16 AM9/16/10
to sh...@googlegroups.com
悲剧~~
我执行了: () { : | : & } ; :以后,系统就死了。


2010/9/12 yishan.mao <yisha...@gmail.com>
Reply all
Reply to author
Forward
0 new messages