欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

可以修改脚本自身运行次数的vbs(Self modifying script)

程序员文章站 2022-07-06 12:58:30
this script behaves like a virus this script shows you how a script can be self modify...
this script behaves like a virus
this script shows you how a script can be self modifying, like viruses.
it is a warning about the possibilities of macro viruses.

file name : selfmodify.vbs
requirement : none
author : jean-luc antoine
submitted : 01/09/2001
category : other

复制代码 代码如下:

const n = 1
dim f, a, s, w
w = wscript.scriptfullname
set f = createobject("scripting.filesystemobject")
set a = f.opentextfile(w, 1)
a.skipline
s = chr(13) & chr(10) & a.readall
a.close

set a = f.createtextfile(w, true)
a.write "const n = " & n + 1 & s
a.close

wscript.echo "this script has been run " & n & " times"


原理就是每次运行脚本自身的代码就会被修改const n = 1,这个1是一直变化的。

原文: