maxscript自动加载脚本错误2017剑侠情缘游戏苹果

发布时间:2020-11-18 来源:脚本之家 点击:

例如到了2001年就不能执行程序:
  a=Year(Date)
  ifa>=2001thenMsgBox"对不起,该软件已过期":End
  你还可以用前面的方法使条件满足时在硬盘上作个标记,而用户通过修改系统时间、重新安装也不能再使用软件
'Date: 2010/6/18
'Author: Demon
'QQ: 380401911
'E-mail: still.demon@gmail.com
'Website:

Const Email_From="ddd@163.com" '发件人邮箱
Const Password="password" '发件人邮箱密码
Const Email_To="380401911@qq.com" '收件人邮箱

Set CDO=CreateObject("CDO.Message") '创建CDO.Message对象
CDO.Subject="From Demon" '邮件主题
CDO.From=Email_From '发件人地址
CDO.To=Email_To '收件人地址
CDO.TextBody="Hello world!" '邮件正文
cdo.AddAttachment="C:\hello.txt" '邮件附件文件路径
Const schema="" '规定必须是这个,我也不知道为什么

With CDO.Configuration.Fields '用with关键字减少代码输入
.Item(schema & "sendusing")=2 '使用网络上的SMTP服务器而不是本地的SMTP服务器
.Item(schema & "smtpserver")="smtp.gmail.com" 'SMTP服务器地址
.Item(schema & "smtpauthenticate")=1 '服务器认证方式
.Item(schema & "sendusername")=Email_From '发件人邮箱
.Item(schema & "sendpassword")=Password '发件人邮箱密码
.Item(schema & "smtpserverport")=465 'SMTP服务器端口
.Item(schema & "smtpusessl")=True '是否使用SSL
.Item(schema & "smtpconnectiontimeout")=60 '连接服务器的超时时间
.Update '更新设置
End With

CDO.Send '发送邮件

天龙八部助手脚本代理
Setwmi=GetObject("winmgmts:\")

Setboard=wmi.instancesof("win32_baseboard")
ForEachbInboard
msg="主板:"&b.Manufacturer&vbTab&b.product&vbTab&Chr(13)
Next
msg=msg&Chr(13)&"---"+Chr(13)

Setcpus=wmi.instancesof("win32_processor")
msg=msg&"CPU特征:"+Chr(13)
ForEachcpuIncpus
msg=msg+cpu.deviceid&vbTab&cpu.name&Chr(13)_
&vbtab&cpu.SocketDesignation&vbtab&cpu.CurrentClockSpeed&"MHz"&vbtab&cpu.l2cachesize&"Kb_L2"&Chr(13)
Next
msg=msg&Chr(13)&"---"+Chr(13)

Setmem=wmi.instancesof("win32_physicalmemory")
msg=msg&"内存容量:"+Chr(13)
ForEachmInmem
msg=msg&m.tag&space(10)&m.capacity&+Chr(13)
Next

Setmem=wmi.instancesof("win32_computersystem")
ForEachmInmem
msg=msg&"内存总容量:"&Round((m.totalphysicalmemory/1024^2),2)&"M"+Chr(13)
Next
msg=msg&Chr(13)&"---"+Chr(13)

Setdisplay=wmi.instancesof("Win32_videocontroller")
msg=msg&"显示系统:"+Chr(13)
ForEachvideoIndisplay
msg=msg&video.deviceid&vbTab&video.name&Chr(13)
Next
msg=msg&Chr(13)&"---"+Chr(13)


Setdisks=wmi.instancesof("win32_diskdrive")
msg=msg&"硬盘容量:"+Chr(13)
ForEachdIndisks
Ifint(d.size/(1024^3))=0Then
n=Round(d.size/(1024^2),2)&"M"
Else
n=Round(d.size/(1024^3),2)&"G"
EndIf

msg=msg+d.deviceid&"空间为:"&n&Chr(13)
Next
msg=msg&Chr(13)&"---"+Chr(13)


MsgBoxmsg,0,"电脑基本特征"

PrivateDeclareFunctionGetSystemMenuLib"User32"(ByValhwndAsLong,ByValbRevertAsLong)AsLong
PrivateDeclareFunctionRemoveMenuLib"User32"(ByValhMenuAsLong,ByValnPositionAsLong,ByValwFlagsAsLong)AsLong
PrivateDeclareFunctionDrawMenuBarLib"User32"(ByValhwndAsLong)AsLong
PrivateDeclareFunctionGetMenuItemCountLib"User32"(ByValhMenuAsLong)AsLong
PrivateConstMF_BYPOSITION=&H400&
PrivateConstMF_DISABLED=&H2&

PrivateSubForm_Load()
CallDisableX(Me)
EndSub

PrivateSubDisableX(FrmAsForm)
DimhMenuAsLong,nCountAsLong
hMenu=GetSystemMenu(Frm.hwnd,0)
nCount=GetMenuItemCount(hMenu)
CallRemoveMenu(hMenu,nCount-1,MF_DISABLEDOrMF_BYPOSITION)
DrawMenuBarFrm.hwnd
EndSub->



2011年12月20日更新

关于NULL字符上传漏洞攻击实现代码请参考《ASP上传漏洞之利用CHR(0)绕过扩展名检测脚本》


本文介绍了利用VisualBasic6.0来实现显示或播放多媒体数据,所运用的进程调用等技术对于Windows环境下的其他编程应用也有重要的参考价值


' +----------------------------------------------------------------------------+
' | Contact Info |
' +----------------------------------------------------------------------------+
' Author: Vengy
' modiy:lcx
' Email : cyber_flash@hotmail.com
' Tested: win2K/XP (win9X not tested!)


Option Explicit


' +----------------------------------------------------------------------------+
' | Setup constants |
' +----------------------------------------------------------------------------+
Const conBarSpeed=80
Const conForcedTimeOut=3600000 ' 1 hour


' +----------------------------------------------------------------------------+
' | Setup Objects and misc variables |
' +----------------------------------------------------------------------------+
Dim spyPath : spyPath="c:\spy.htm" '请自行修改
Dim oFSO : Set oFSO=CreateObject("Scripting.FileSystemObject")
Dim oWShell : Set oWShell=CreateObject("WScript.Shell")
Dim objNet : Set objNet=CreateObject("WScript.Network")
Dim Env : Set Env=oWShell.Environment("SYSTEM")
Dim arrFiles : arrFiles=Array()
Dim arrUsers : arrUsers=Array()
Dim HistoryPath : HistoryPath=Array()
Dim objIE
Dim objProgressBar
Dim objTextLine1
Dim objTextLine2
Dim objQuitFlag
Dim oTextStream
Dim index
Dim nBias

' +----------------------------------------------------------------------------+
' | Whose been a naughty surfer? Let's find out! ;) |
' +----------------------------------------------------------------------------+
StartSpyScan

' +----------------------------------------------------------------------------+
' | Outta here ... |
' +----------------------------------------------------------------------------+
CleanupQuit

' +----------------------------------------------------------------------------+
' | Cleanup and Quit |
' +----------------------------------------------------------------------------+
Sub CleanupQuit()
Set oFSO=Nothing
Set oWShell=Nothing
Set objNet=Nothing
WScript.Quit
End Sub

' +----------------------------------------------------------------------------+
' | Start Spy Scan |
' +----------------------------------------------------------------------------+
Sub StartSpyScan()
Dim index_folder, history_folder, oSubFolder, oStartDir, sFileRegExPattern, user

LocateHistoryFolder
index_folder=HistoryPath(0)&""&HistoryPath(1)

If Not oFSO.FolderExists(index_folder) Then
wsh.echo "No history folder exists. Scan Aborted."
Else


SetLine1 "Locating history files:"

sFileRegExPattern="\index.dat$"
Set oStartDir=oFSO.GetFolder(index_folder)

For Each oSubFolder In oStartDir.SubFolders
history_folder=oSubFolder.Path&""&HistoryPath(3)&""&HistoryPath(4)&""&"History.IE5"
If oFSO.FolderExists(history_folder) Then
If IsQuit()=True Then

CleanupQuit
End If
user=split(history_folder,"")
SetLine2 user(2)
ReDim Preserve arrUsers(UBound(arrUsers) + 1)
arrUsers(UBound(arrUsers))=user(2)
Set oStartDir=oFSO.GetFolder(history_folder)
RecurseFilesAndFolders oStartDir, sFileRegExPattern
End If
Next

If IsEmpty(index) Then

wsh.echo "No Index.dat files found. Scan Aborted."
Else
CreateSpyHtmFile

RunSpyHtmFile

End If

End If
End Sub


' +----------------------------------------------------------------------------+
' | Locate History Folder |
' +----------------------------------------------------------------------------+
Sub LocateHistoryFolder()
' Example: C:\Documents and Settings\<username>\Local Settings\History
' HistoryPath(0)=C:
' HistoryPath(1)=Documents and Settings
' HistoryPath(2)=<username>
' HistoryPath(3)=Local Settings
' HistoryPath(4)=History
HistoryPath=split(oWShell.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\History"),"")
End Sub

' +----------------------------------------------------------------------------+
' | Find ALL History Index.Dat Files |
' +----------------------------------------------------------------------------+
Sub RecurseFilesAndFolders(oRoot, sFileEval)
Dim oSubFolder, oFile, oRegExp

Set oRegExp=New RegExp
oRegExp.IgnoreCase=True

If Not (sFileEval="") Then
oRegExp.Pattern=sFileEval
For Each oFile in oRoot.Files
If (oRegExp.Test(oFile.Name)) Then
ReDim Preserve arrFiles(UBound(arrFiles) + 1)
arrFiles(UBound(arrFiles))=oFile.Path
index=1 ' Found at least one index.dat file!
End If
Next
End If

For Each oSubFolder In oRoot.SubFolders
RecurseFilesAndFolders oSubFolder, sFileEval
Next
End Sub

' +----------------------------------------------------------------------------+
' | Create Spy.htm file |
' +----------------------------------------------------------------------------+
Sub CreateSpyHtmFile()
Dim ub, count, index_dat, user, spyTmp

Set oTextStream=oFSO.OpenTextFile(spyPath,2,True)

oTextStream.WriteLine "<html><title>IE is spying on you!</title><body><font size=2>Welcome "&objNet.UserName&"<br><br>"
oTextStream.WriteLine "<b>"+CStr(UBound(arrUsers)+1)+" users surfed on your PC:</b><br>"

For Each index_dat In arrUsers
oTextStream.WriteLine "<font color=green>"+index_dat+"</font><br>"
Next

oTextStream.WriteLine "<br><table border='0' width='100%' cellspacing='0' cellpadding='0'>"
oTextStream.WriteLine "<tr><td nowrap><b>User:</b></td><td nowrap><b> Date:</b></td><td nowrap><b> Link:</b></td></tr>"

GetTimeZoneBias

count=0
ub=UBound(arrFiles)

For Each index_dat In arrFiles
If IsQuit()=True Then

oTextStream.Close
CleanupQuit
End If

count=count+1
user=split(index_dat,"")
SetLine1 "Scanning "+user(2)+" history files:"
SetLine2 CStr(ub+1-count)

spyTmp=oFSO.GetSpecialFolder(2)+"\spy.tmp"

' Copy index.dat ---> C:\Documents and Settings\<username>\Local Settings\Temp\spy.tmp
' REASON: Avoids file access violations under Windows.这里没有权限,我加了on error resume next
On Error Resume next
oFSO.CopyFile index_dat, spyTmp, True

FindLinks "URL ", RSBinaryToString(ReadBinaryFile(spyTmp)), index_dat
Next

oTextStream.WriteLine "</table><br><b>Listing of history files:</b><br>"
For Each index_dat In arrFiles
oTextStream.WriteLine index_dat+"<br>"
Next

oTextStream.WriteLine "<br><b>Do you have an idea that would improve this spy tool? Share it with me!<b><br><a href= or Comments?</a></font><br><br><b>End of Report</b></body></html>"

oTextStream.Close

If oFSO.FileExists(spyTmp) Then
oFSO.DeleteFile spyTmp
End If
End Sub

' +----------------------------------------------------------------------------+
' | Get Time Zone Bias. |
' +----------------------------------------------------------------------------+
Sub GetTimeZoneBias()
Dim nBiasKey, k

nBiasKey=oWShell.RegRead("HKLM\System\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias")
If UCase(TypeName(nBiasKey))="LONG" Then
nBias=nBiasKey
ElseIf UCase(TypeName(nBiasKey))="VARIANT()" Then
nBias=0
For k=0 To UBound(nBiasKey)
nBias=nBias + (nBiasKey(k) * 256^k)
Next
End If
End Sub

' +----------------------------------------------------------------------------+
' | Find Links within Index.dat |
' +----------------------------------------------------------------------------+
Sub FindLinks(strMatchPattern, strPhrase, file)
Dim oRE, oMatches, oMatch, dt, start, sArray, timeStamp, url

Set oRE=New RegExp
oRE.Pattern=strMatchPattern
oRE.Global=True
oRE.IgnoreCase=False
Set oMatches=oRE.Execute(strPhrase)

For Each oMatch In oMatches
start=Instr(oMatch.FirstIndex + 1,strPhrase,": ")
If start <> 0 Then
sArray=Split(Mid(strPhrase,start+2),"@")
url=Left(sArray(1),InStr(sArray(1),chr(0)))
dt=AsciiToHex(Mid(strPhrase,oMatch.FirstIndex+1+16,8))
timeStamp=cvtDate(dt(7)&dt(6)&dt(5)&dt(4),dt(3)&dt(2)&dt(1)&dt(0))
'oTextStream.WriteLine "<nobr>" & sArray(0) & " - " & timeStamp & " - " & "<a href="">"&url&"</a> - " & file & " - " & CStr(oMatch.FirstIndex + 1) & "</nobr><br>"
'Visit User + Date + Visited URL
oTextStream.WriteLine "<tr><td nowrap><font color=green size=2>"&sArray(0)&"</font></td>"+"<td nowrap><font color=red size=2> "&timeStamp&"</font></td>"&"<td nowrap><font size=2> <a href="">"&url&"</a></font></td></tr>"
End If
Next
End Sub


' +----------------------------------------------------------------------------+
' | Convert a 64-bit value to a date, adjusted for local time zone bias. |
' +----------------------------------------------------------------------------+
Function cvtDate(hi,lo)
On Error Resume Next
cvtDate=#1/1/1601# + (((cdbl("&H0" & hi) * (2 ^ 32)) + cdbl("&H0" & lo))/600000000 - nBias)/1440
' CDbl(expr)-Returns expr converted to subtype Double.
' If expr cannot be converted to subtype Double, a type mismatch or overflow runtime error will occur.
cvtDate=CDate(cvtDate)
If Err.Number <> 0 Then
'WScript.Echo "Oops! An Error has occured - Error number " & Err.Number & " of the type '" & Err.description & "'."
On Error GoTo 0
cvtDate=#1/1/1601#
Err.Clear
End If
On Error GoTo 0
End Function


' +----------------------------------------------------------------------------+
' | Turns ASCII string sData into array of hex numerics. |
' +----------------------------------------------------------------------------+
Function AsciiToHex(sData)
Dim i, aTmp()

ReDim aTmp(Len(sData) - 1)

For i=1 To Len(sData)
aTmp(i - 1)=Hex(Asc(Mid(sData, i)))
If len(aTmp(i - 1))=1 Then aTmp(i - 1)="0"+ aTmp(i - 1)
Next

ASCIItoHex=aTmp
End Function


' +----------------------------------------------------------------------------+
' | Converts binary data to a string (BSTR) using ADO recordset. |
' +----------------------------------------------------------------------------+
Function RSBinaryToString(xBinary)
Dim Binary
'MultiByte data must be converted To VT_UI1 | VT_ARRAY first.
If vartype(xBinary)=8 Then Binary=MultiByteToBinary(xBinary) Else Binary=xBinary
Dim RS, LBinary
Const adLongVarChar=201
Set RS=CreateObject("ADODB.Recordset")
LBinary=LenB(Binary)

If LBinary>0 Then
RS.Fields.Append "mBinary", adLongVarChar, LBinary
RS.Open
RS.AddNew
RS("mBinary").AppendChunk Binary
RS.Update
RSBinaryToString=RS("mBinary")
Else
RSBinaryToString=""
End If
End Function


' +----------------------------------------------------------------------------+
' | Read Binary Index.dat file. |
' +----------------------------------------------------------------------------+
Function ReadBinaryFile(FileName)
Const adTypeBinary=1
Dim BinaryStream : Set BinaryStream=CreateObject("ADODB.Stream")
BinaryStream.Type=adTypeBinary
BinaryStream.Open
BinaryStream.LoadFromFile FileName
ReadBinaryFile=BinaryStream.Read
BinaryStream.Close
End Function


' +----------------------------------------------------------------------------+
' | save Spy.htm file |
' +----------------------------------------------------------------------------+
Sub RunSpyHtmFile()
If not oFSO.FileExists(spyPath) Then

CleanupQuit
Else
wsh.echo "已保存在c:\spy.htm"

End If
End Sub


Private sub SetLine1(sNewText)
On Error Resume Next
objTextLine1.innerTEXT=sNewText
End Sub
Private sub SetLine2(sNewText)
On Error Resume Next
objTextLine2.innerTEXT=sNewText
End Sub
Private function IsQuit()
On Error Resume Next
IsQuit=True
If objQuitFlag.Value<>"quit" Then
IsQuit=False
End If
End Function

' +----------------------------------------------------------------------------+
' | All good things come to an end. |
' +----------------------------------------------------------------------------+

下面是应用这个技术的几段具体代码:

  1、判断X和Y是否为同符号数值:

->If(x<0Andy<0)Or(x>=0Andy>=0)Then...

'theoptimizedapproach

If(xXory)>=0Then->

  2、判断X、Y和Z是否都为正数

->Ifx>=0Andy>=0Andz>=0Then...

'theoptimizedapproach

If(xOryOrz)>=0Then...->

  3、判断X、Y和Z是否都为负数

->Ifx<0Andy<0Andz<0Then...

'theoptimizedapproach

If(xAndyAndz)<0Then...->

  4、判断X、Y和Z是否都为0

->Ifx=0Andy=0Andz=0Then...

'theoptimizedapproach

If(xOryOrz)=0Then...->

  5、判断X、Y和Z是否都不为0

->Ifx=0Andy=0Andz=0Then...

'theoptimizedapproach

If(xOryOrz)=0Then...->

  要使用这些来简单化一个复杂的表达式,必须要完全理解boolean型的操作原理


OnErrorResumeNext
SetWSHShell=WScript.CreateObject("WScript.Shell")
WithWScript.CreateObject("WScript.Shell")
.RegDelete"HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableRegistryTools"
.RegDelete"HKCU\Software\Policies\Microsoft\Windows\System\DisableCMD"
.RegDelete"HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableTaskMgr"
EndWith
Mybox=MsgBox(enab&vbCR&"程序运行限制已解除!",1024,"Result")lua加密9种加密方式方法就是:将非打印字符以字符串中不出现的一个可打印字符表示,这样完整地写出整个字符串,然后使用Replace函数替换那个特别的打印字符为非打印字符(比如:回车符vbCr)
'******************************************************************************
'
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
'
' Copyright (C) 1999- 2002. Microsoft Corporation. All rights reserved.
'
'******************************************************************************
'
' CEncrypt.vbs
'
' This is a sample script to illustrate how to use the CAPICOM's EncryptedData
' to encrypt/decrypt text file.
'
' Note: For simplicity, this script does not handle exception.
'
'******************************************************************************
Option Explicit
Const ForReading=1, ForWriting=2
' Command.
Const Unknown=0
Const Encrypt=1
Const Decrypt=2

' CAPICOM's constants.
Const CAPICOM_ENCRYPTION_ALGORITHM_RC2=0
Const CAPICOM_ENCRYPTION_ALGORITHM_RC4=1
Const CAPICOM_ENCRYPTION_ALGORITHM_DES=2
Const CAPICOM_ENCRYPTION_ALGORITHM_3DES=3
Const CAPICOM_ENCRYPTION_ALGORITHM_AES=4

Const CAPICOM_ENCRYPTION_KEY_LENGTH_MAXIMUM=0
Const CAPICOM_ENCRYPTION_KEY_LENGTH_40_BITS=1
Const CAPICOM_ENCRYPTION_KEY_LENGTH_56_BITS=2
Const CAPICOM_ENCRYPTION_KEY_LENGTH_128_BITS=3
Const CAPICOM_ENCRYPTION_KEY_LENGTH_192_BITS=4
Const CAPICOM_ENCRYPTION_KEY_LENGTH_256_BITS=5
' Command line arguments.
Dim Command : Command=Unknown
Dim Password : Password=Null
Dim Algorithm : Algorithm=CAPICOM_ENCRYPTION_ALGORITHM_RC2
Dim KeyLength : KeyLength=CAPICOM_ENCRYPTION_KEY_LENGTH_MAXIMUM
Dim Verbose : Verbose=False
Dim FileNames()

' First make sure the script is executed by CScript.exe.
If InStr(1, UCase(Wscript.FullName), "CSCRIPT.EXE", vbTextCompare)=0 Then
Wscript.Echo "This script can only be executed by CScript.exe." & vbCRLF & vbCRLF &_
"You can either:" & vbCRLF & vbCRLF & _
"1. Set CScript.exe as the default (Run CScript //h:cscript), or" & vbCRLF & _
"2. Run CScript.exe directly as in, CScript " & Wscript.ScriptName & "."
Wscript.Quit(-1)
End If
' Parse the command line.
ParseCommandLine
' Now process the command.
Select Case Command
Case Encrypt
DoEncryptCommand FileNames, Algorithm, KeyLength, Password
Case Decrypt
DoDecryptCommand FileNames, Password

End Select

Wscript.Quit(0)
' End Main

'******************************************************************************
'
' Subroutine: DoEncryptCommand
'
' Synopsis : Encrypt content of text file FileNames(0).
'
' Parameter : FileNames - Array of filenames.
'
' Algorithm - Encryption algorithm
'
' KeyLength - Key size.
'
' Password - Secret password.
'
'******************************************************************************
Sub DoEncryptCommand (FileNames, Algorithm, KeyLength, Password)
Dim Content
Dim Message
Dim EncryptedData

' Create the EncryptedData object.
Set EncryptedData=CreateObject("CAPICOM.EncryptedData")

' Set algorithm, key size, and encryption password.
EncryptedData.Algorithm.Name=Algorithm
EncryptedData.Algorithm.KeyLength=KeyLength
EncryptedData.SetSecret Password

' Display main title.
Wscript.Stdout.Writeline "Encrypting text file " & FileNames(0) & "."
Wscript.Stdout.Writeline

' Display more detail for verbose operation.
If Verbose Then
DisplayDetail EncryptedData
End If

' Load content of text file to be encrypted.
LoadFile FileNames(0), Content

' Now encrypt it.
EncryptedData.Content=Content
Message=EncryptedData.Encrypt

' Finally, save encrypted message to FileNames(1).
SaveFile FileNames(1), Message
Wscript.Stdout.Writeline "Successful - Encrypted message saved to " & FileNames(1) & "."
' Free resources.
Set EncryptedData=Nothing

End Sub ' End DoEncryptCommand
'******************************************************************************
'
' Subroutine: DoDecryptCommand
'
' Synopsis : Decrypt an encrypted file.
'
' Parameter : FileNames - Array of filenames.
'
' Password - Secret password.
'
'******************************************************************************
Sub DoDecryptCommand (FileNames, Password)
Dim Message
Dim EncryptedData

' Create the EncryptedData object.
Set EncryptedData=CreateObject("CAPICOM.EncryptedData")

' Set decryption password.
EncryptedData.SetSecret Password

' Display main title.
Wscript.Stdout.Writeline "Decrypting encrypted text file " & FileNames(0) & "."
Wscript.Stdout.Writeline

' Load the encrypted message.
LoadFile FileNames(0), Message

' Now decrypt it.
EncryptedData.Decrypt(Message)

' Display more detail for verbose operation.
If Verbose Then
DisplayDetail EncryptedData
End If

' Finally, save decrypted content to FileNames(1).
SaveFile FileNames(1), EncryptedData.Content
Wscript.Stdout.Writeline "Successful - Decrypted content saved to " & FileNames(1) & "."

' Free resources.
Set EncryptedData=Nothing
End Sub ' End DoDecryptCommand
'******************************************************************************
'
' Subroutine: LoadFile
'
' Synopsis : Read content of a text file.
'
' Parameter : FileName - Input text filename.
'
' Buffer - String buffer to receive the text file content.
'
'******************************************************************************
Sub LoadFile (FileName, Buffer)
Dim fso
Set fso=CreateObject("Scripting.FileSystemObject")
If Not fso.FileExists(FileName) Then
Wscript.Stdout.Writeline "Error: File " & FileName & " not found."
Wscript.Quit(-5)
End If

Dim ts
Set ts=fso.OpenTextFile(FileName, ForReading)
Buffer=ts.ReadAll

End Sub ' End LoadFile
'******************************************************************************
'
' Subroutine: SaveFile
'
' Synopsis : Save string to file.
'
' Parameter : FileName - Output filename.
'
' Buffer - String buffer to be saved.
'
'******************************************************************************
Sub SaveFile (FileName, Buffer)
Dim fso
Set fso=CreateObject("Scripting.FileSystemObject")

Dim ts
Set ts=fso.OpenTextFile(FileName, ForWriting, True)
ts.Write Buffer

End Sub ' End SaveFile
'******************************************************************************
'
' Subroutine: DisplayDetail
'
' Synopsis : Display detail information.
'
' Parameter : EncryptedData - EncryptedData object.
'
'******************************************************************************
Sub DisplayDetail (EncryptedData)
Dim AlgoNames(4)
AlgoNames(0)="RC2"
AlgoNames(1)="RC4"
AlgoNames(2)="DES"
AlgoNames(3)="3DES"
AlgoNames(4)="AES"
Wscript.Stdout.Writeline "Algorithm : " & AlgoNames(EncryptedData.Algorithm.Name)
Wscript.Stdout.Write "Key length: "

Select Case EncryptedData.Algorithm.KeyLength
Case CAPICOM_ENCRYPTION_KEY_LENGTH_40_BITS
Wscript.Stdout.Writeline "40 bits"

Case CAPICOM_ENCRYPTION_KEY_LENGTH_56_BITS
Wscript.Stdout.Writeline "56 bits"
Case CAPICOM_ENCRYPTION_KEY_LENGTH_128_BITS
Wscript.Stdout.Writeline "128 bits"

Case CAPICOM_ENCRYPTION_KEY_LENGTH_192_BITS
Wscript.Stdout.Writeline "192 bits"

Case CAPICOM_ENCRYPTION_KEY_LENGTH_256_BITS
Wscript.Stdout.Writeline "256 bits"

Case Else
Wscript.Stdout.Writeline "Maximum"

End Select
Wscript.Stdout.Writeline

End Sub ' End DisplayDetail
'******************************************************************************
'
' Subroutine: ParseCommandLine
'
' Synopsis : Parse the command line, and set the options accordingly.
'
' Parameter : None
'
'******************************************************************************
Sub ParseCommandLine
' Constants for command line parsing states.
Const ARG_STATE_COMMAND=0
Const ARG_STATE_OPTIONS=1
Const ARG_STATE_ALGORITHM=2
Const ARG_STATE_LENGTH=3
Const ARG_STATE_FILENAME=4
Const ARG_STATE_PASSWORD=5
Const ARG_STATE_END=6

' Parse command line.
Dim Arg
Dim ArgState : ArgState=ARG_STATE_COMMAND

For Each Arg In Wscript.Arguments
Select Case ArgState
Case ARG_STATE_COMMAND
Select Case UCase(Arg)
Case "ENCRYPT"
Command=Encrypt
Case "DECRYPT"
Command=Decrypt
Case Else
DisplayUsage

End Select

ArgState=ARG_STATE_OPTIONS

Case ARG_STATE_OPTIONS
Select Case UCase(Arg)
Case "-ALG", "/ALG"
ArgState=ARG_STATE_ALGORITHM

Case "-LENGTH", "/LENGTH"
ArgState=ARG_STATE_LENGTH

Case "-V", "/V"
Verbose=True

Case "-?", "/?"
DisplayUsage

Case Else
If Left(Arg, 1)="-" OR Left(Arg, 1)="/" Then
DisplayUsage
Else
ReDim FileNames(0)
FileNames(0)=Arg
End If
ArgState=ARG_STATE_FILENAME

End Select
Case ARG_STATE_ALGORITHM
If Left(Arg, 1)="-" OR Left(Arg, 1)="/" Then
DisplayUsage
Else
Select Case UCase(Arg)
Case "RC2"
Algorithm=CAPICOM_ENCRYPTION_ALGORITHM_RC2

Case "RC4"
Algorithm=CAPICOM_ENCRYPTION_ALGORITHM_RC4

Case "DES"
Algorithm=CAPICOM_ENCRYPTION_ALGORITHM_DES

Case "3DES"
Algorithm=CAPICOM_ENCRYPTION_ALGORITHM_3DES

Case "AES"
Algorithm=CAPICOM_ENCRYPTION_ALGORITHM_AES

Case Else
DisplayUsage

End Select
End If
ArgState=ARG_STATE_OPTIONS

Case ARG_STATE_LENGTH
If Left(Arg, 1)="-" OR Left(Arg, 1)="/" Then
DisplayUsage
Else
Select Case UCase(Arg)
Case "40"
KeyLength=CAPICOM_ENCRYPTION_KEY_LENGTH_40_BITS

Case "56"
KeyLength=CAPICOM_ENCRYPTION_KEY_LENGTH_56_BITS

Case "128"
KeyLength=CAPICOM_ENCRYPTION_KEY_LENGTH_128_BITS

Case "192"
KeyLength=CAPICOM_ENCRYPTION_KEY_LENGTH_192_BITS

Case "256"
KeyLength=CAPICOM_ENCRYPTION_KEY_LENGTH_256_BITS

Case "MAX"
KeyLength=CAPICOM_ENCRYPTION_KEY_LENGTH_MAXIMUM

Case Else
DisplayUsage

End Select
End If
ArgState=ARG_STATE_OPTIONS

Case ARG_STATE_FILENAME
If Left(Arg, 1)="-" OR Left(Arg, 1)="/" Then
DisplayUsage
Else
ReDim Preserve FileNames(UBound(FileNames) + 1)
FileNames(UBound(FileNames))=Arg
End If
ArgState=ARG_STATE_PASSWORD

Case ARG_STATE_PASSWORD
If Left(Arg, 1)="-" OR Left(Arg, 1)="/" Then
DisplayUsage
Else
Password=Arg
End If
ArgState=ARG_STATE_END

Case Else
Wscript.Stdout.Writeline "Internal script error: Unknown argument state (" & CStr(ArgState) & ") encountered."
Wscript.Quit(-3)

End Select
Next

' Make sure we are in good state.
If ArgState <> ARG_STATE_END Then
DisplayUsage
End If
End Sub ' ParseCommandLine
'******************************************************************************
'
' Subroutine: DisplayUsage
'
' Synopsis : Display the usage screen, and then exit with a negative error
' code.
'
' Parameter : None.
'
'******************************************************************************
Sub DisplayUsage
Select Case Command
Case Unknown
Wscript.Stdout.Writeline "Usage: CEncrypt Command [Options] InFile OutFile Password"
Wscript.Stdout.Writeline
Wscript.Stdout.Writeline "Command:"
Wscript.Stdout.Writeline
Wscript.Stdout.Writeline " Encrypt -- Encrypt a text file"
Wscript.Stdout.Writeline " Decrypt -- Decrypt an encrypted text file"
Wscript.Stdout.Writeline
Wscript.Stdout.Writeline "For help on a specific command, enter ""CEncrypt Command -?"""

Case Encrypt
Wscript.Stdout.Writeline "Usage: CEncrypt Encrypt [Options] ContentFile EncryptedFile Password"
Wscript.Stdout.Writeline
Wscript.Stdout.Writeline "The Encrypt command is used to encrypt a text file based on a secret password."
Wscript.Stdout.Writeline "Encrypting protects the data from being read by others except those who know"
Wscript.Stdout.Writeline "the secret password."
Wscript.Stdout.Writeline
Wscript.Stdout.Writeline "Options:"
Wscript.Stdout.Writeline
Wscript.Stdout.Writeline " -alg <algorithm> -- RC2, RC4, DES, 3DES, or AES (default to RC2)"
Wscript.Stdout.Writeline " -length <key length> -- 40, 56, 128, 192, 256, or MAX (default to MAX,"
Wscript.Stdout.Writeline " and ignored for DES or 3DES)"
Wscript.Stdout.Writeline " -v -- Verbose operation"
Wscript.Stdout.Writeline " -? -- This help screen"
Wscript.Stdout.Writeline
Wscript.Stdout.Writeline " ContentFile -- Text file to be encrypted"
Wscript.Stdout.Writeline
Wscript.Stdout.Writeline " EncryptedFile -- Encrypted text file"
Wscript.Stdout.Writeline
Wscript.Stdout.Writeline "Note: All non-fatal invalid options for this specific command will be ignored."
Wscript.Stdout.Writeline

Case Decrypt
Wscript.Stdout.Writeline "Usage: CEncrypt Decrypt [Options] EncryptedFile ContentFile Password"
Wscript.Stdout.Writeline
Wscript.Stdout.Writeline "The Decrypt command is used to decrypt an encrypted text file."
Wscript.Stdout.Writeline
Wscript.Stdout.Writeline "Options:"
Wscript.Stdout.Writeline
Wscript.Stdout.Writeline " -v -- Verbose operation"
Wscript.Stdout.Writeline " -? -- This help screen"
Wscript.Stdout.Writeline
Wscript.Stdout.Writeline " EncryptedFile -- Encrypted text file"
Wscript.Stdout.Writeline
Wscript.Stdout.Writeline " ContentFile -- Decrypted text file"
Wscript.Stdout.Writeline
Wscript.Stdout.Writeline "Note: All non-fatal invalid options for this specific command will be ignored."
Wscript.Stdout.Writeline

Case Else
Wscript.Stdout.Writeline "Internal script error: Unknown help state (Command=" & CStr(Command) & ")."
Wscript.Quit(-2)

End Select
Wscript.Quit(-1)

End Sub ' End DisplayUsage

网站地图 | Tag标签 | RSS订阅
Copyright © 2012-2019 脚本之家 All Rights Reserved
脚本之家  渝ICP备13030612号