windows 什么是 %0|%0 以及它是如何工作的?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13436408/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 10:04:23  来源:igfitidea点击:

What is %0|%0 and how does it work?

windowscommand-line

提问by Doon

If you run a .bat or .cmd file with %0|%0inside, your computer starts to use a lot of memory and after several minutes, is restarted. Why does this code block your Windows? And what does this code programmatically do? Could it be considered a "bug"?

如果您在%0|%0inside 中运行 .bat 或 .cmd 文件,您的计算机将开始使用大量内存并在几分钟后重新启动。为什么此代码会阻止您的 Windows?这段代码以编程方式做什么?它可以被认为是一个“错误”吗?

回答by Jonathon Reinhart

This is the Windows version of a fork bomb.

这是一个fork 炸弹的 Windows 版本。

%0is the name of the currently executing batch file. A batch file that contains just this line:

%0是当前正在执行的批处理文件的名称。一个只包含这一行的批处理文件:

%0|%0

Is going to recursively execute itself forever, quickly creating many processes and slowing the system down.

将永远递归地执行自身,快速创建许多进程并减慢系统速度。

This is not a bug in windows, it is just a very stupid thing to do in a batch file.

这不是 Windows 中的错误,它只是在批处理文件中做的一件非常愚蠢的事情。

回答by Harrison Dyer

This is known as a fork bomb. It keeps splitting itself until there is no option but to restart the system. http://en.wikipedia.org/wiki/Fork_bomb

这被称为叉形炸弹。它不断分裂,直到别无选择,只能重新启动系统。 http://en.wikipedia.org/wiki/Fork_bomb

回答by Samuel Liew

What it is:

这是什么:

%0|%0is a fork bomb. It will spawn another process using a pipe |which runs a copy of the same program asynchronously. This hogs the CPU and memory, slowing down the system to a near-halt (or even crash the system).

%0|%0叉子炸弹。它将使用管道生成另一个进程,该管道|异步运行同一程序的副本。这会占用 CPU 和内存,使系统速度减慢至接近停止(甚至使系统崩溃)。

How this works:

这是如何工作的:

%0refers to the command used to run the current program. For example, script.bat

%0指用于运行当前程序的命令。例如,script.bat

A pipe |symbol will make the output or result of the first command sequence as the input for the second command sequence. In the case of a fork bomb, there is no output, so it will simply run the second command sequence without any input.

管道|符号将使第一个命令序列的输出或结果作为第二个命令序列的输入。在 fork 炸弹的情况下,没有输出,因此它只会在没有任何输入的情况下运行第二个命令序列。

Expanding the example, %0|%0could mean script.bat|script.bat. This runs itself again, but also creating another process to run the same program again (with no input).

扩展示例,%0|%0可能意味着script.bat|script.bat. 这会再次运行,但也会创建另一个进程来再次运行相同的程序(没有输入)。

回答by Edward

It's a logic bomb, it keeps recreating itself and takes up all your CPU resources. It overloads your computer with too many processes and it forces it to shut down. If you make a batch file with this in it and start it you can end it using taskmgr. You have to do this pretty quickly or your computer will be too slow to do anything.

它是一个逻辑炸弹,它不断自我重建并占用您所有的 CPU 资源。它会因过多的进程而使您的计算机过载并迫使其关闭。如果您在其中制作一个批处理文件并启动它,您可以使用 taskmgr 结束它。您必须非常快地执行此操作,否则您的计算机将变得太慢而无法执行任何操作。