Self Modifying





-4
Date Submitted Tue. Feb. 28th, 2006 7:18 AM
Revision 1 of 1
Syntax Master dannyboy
Tags VBSCRIPT
Comments 0 comments
This script shows you how a script can be self modifying, like viruses. It is a warning about the possibilities of new macro viruses


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"

 

Comments

There are currently no comments for this snippet.

Voting