Skip to content
Life is short Play more
  • AI技术
  • Computer
    • Cloud
    • DataBase
      • Mysql
      • Oracle
    • Operation system
      • Android
      • Linux
      • Windows
    • Programming
      • C , C++
      • Java
      • Javascript
      • Linux shell
      • Php
      • python
      • Web Programing
    • Security
    • Virtulization
    • Web hosting
      • Ad
  • Life Testing
  • My work
    • wrapEasyDevice
  • Network
    • HTTP
  • Note
  • Other
    • Embedded
    • Hardware
  • Share
    • Articles
    • Music
    • Tools
    • Video
  • Software Testing
    • Automation Testing
    • Cloud Testing
    • Functional Testing
    • Performance Testing
Life is short Play more
Life is short play more

bash中的冒号, 以及bash bomb解析还有各种各样的炸弹

Posted On 2011年11月18日

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.

此篇文章已被阅读2957 次

相关文章

  1. javascript有sleep方法么?
  2. linux(unix)文件格式类型以及dos和unix文件格式的转换
  3. Unix domain sockets介绍
  4. linux shell经典应用
  5. how to extend root partition size

Related Posts

spring data jpa mongodb根据example查找不到问题
jython 2.5.2 还是不支持cjk(中国,日本,韩国亚洲字符编码)
mongodb shell 更新多条记录

About The Author

The Tester

技术交流,生活学习

© 2026 Life is short Play more | blog | Powered by WordPress & Customizable Blogily