VBS 加解密 For MS Script Encode

一、加密

代码如下:

Dim ObjectFSO

If (lcase(right(wscript.fullname,11))="wscript.exe") Then
 WScript.Quit(0)
End If

If wscript.arguments.count<2 Then
 Wscript.Echo "VBS Code Encoder v1.0 Powered by ENUN. http://www.enun.net/"
 Wscript.Echo "Notes: dFileName Must be '*.vbe'!"
 Wscript.Echo "Usage: cscript.exe //nologo sFileName dFileName"
 Wscript.Echo "   eg: cscript.exe //nologo test.vbs enc.vbe"
 WScript.Quit(0)
End If

sFileName = Wscript.Arguments(0)
dFileName = Wscript.Arguments(1)

Set ObjectFSO = CreateObject("Scripting.FileSystemObject")
Set ReadData = ObjectFSO.OpenTextFile(sFileName, 1)

ObjectFSO.OpenTextFile(dFileName, 8, true).Write(Encoder(ReadData.Readall))

Function Encoder(data)
    Encoder = CreateObject("Scripting.Encoder").EncodeScriptFile(".vbs", data, 0, "VBScript")
End Function

二、解密

代码如下:

option explicit

Dim oArgs, NomFichier

'Optional argument : the encoded filename

NomFichier=""
Set oArgs = WScript.Arguments
Select Case oArgs.Count

Case 0 'No Arg, popup a dialog box to choose the file
        NomFichier=BrowseForFolder("Choose an encoded file", &H4031, &H0011)
Case 1
        If Instr(oArgs(0),"?")=0 Then '-? ou /? => aide
                NomFichier=oArgs(0)
        End If
Case Else
        WScript.Echo "Too many parameters"
End Select

Set oArgs = Nothing

If NomFichier<>"" Then
        Dim fso
        Set fso=WScript.CreateObject("Scripting.FileSystemObject")
        If fso.FileExists(NomFichier) Then
                Dim fic,contenu
                Set fic = fso.OpenTextFile(NomFichier, 1)
                Contenu=fic.readAll
                fic.close
                Set fic=Nothing
                Const TagInit="#@~^" '#@~^awQAAA==
                Const TagFin="==^#~@" '& chr(0)
                Dim DebutCode, FinCode
                Do
     FinCode=0
     DebutCode=Instr(Contenu,TagInit)
     If DebutCode>0 Then
      If (Instr(DebutCode,Contenu,"==")-DebutCode)=10 Then 'If "==" follows the tag
       FinCode=Instr(DebutCode,Contenu,TagFin)
       If FinCode>0 Then
        Contenu=Left(Contenu,DebutCode-1) & _
        Decode(Mid(Contenu,DebutCode+12,FinCode-DebutCode-12-6)) & _
        Mid(Contenu,FinCode+6)
       End If
      End If
     End If
                Loop Until FinCode=0
                WScript.Echo Contenu
        Else
                WScript.Echo Nomfichier & " not found"
        End If
        Set fso=Nothing

Else
        WScript.Echo "Please give a filename"
        WScript.Echo "Usage : " & wscript.fullname  & " " & WScript.ScriptFullName & " <filename>"

End If

Function Decode(Chaine)
        Dim se,i,c,j,index,ChaineTemp
        Dim tDecode(127)
        Const Combinaison="1231232332321323132311233213233211323231311231321323112331123132"
        Set se=WSCript.CreateObject("Scripting.Encoder")
        For i=9 to 127
                tDecode(i)="JLA"
        Next

For i=9 to 127
                ChaineTemp=Mid(se.EncodeScriptFile(".vbs",string(3,i),0,""),13,3)
                For j=1 to 3
                        c=Asc(Mid(ChaineTemp,j,1))
                        tDecode(c)=Left(tDecode(c),j-1) & chr(i) & Mid(tDecode(c),j+1)
                Next
        Next

'Next line we correct a bug, otherwise a ")" could be decoded to a ">"
        tDecode(42)=Left(tDecode(42),1) & ")" & Right(tDecode(42),1)
        Set se=Nothing
        Chaine=Replace(Replace(Chaine,"@&",chr(10)),"@#",chr(13))
        Chaine=Replace(Replace(Chaine,"@*",">"),"@!","<")
        Chaine=Replace(Chaine,"@$","@")
        index=-1
        For i=1 to Len(Chaine)
                c=asc(Mid(Chaine,i,1))
                If c<128 Then index=index+1
                If (c=9) or ((c>31) and (c<128)) Then
                        If (c<>60) and (c<>62) and (c<>64) Then
                                Chaine=Left(Chaine,i-1) & Mid(tDecode(c),Mid(Combinaison,(index mod 64)+1,1),1) & Mid(Chaine,i+1)
                        End If
                End If
        Next
        Decode=Chaine
End Function

Function BrowseForFolder(ByVal pstrPrompt, ByVal pintBrowseType, ByVal pintLocation)
        Dim ShellObject, pstrTempFolder, x
        Set ShellObject=WScript.CreateObject("Shell.Application")
        On Error Resume Next
        Set pstrTempFolder=ShellObject.BrowseForFolder(&H0,pstrPrompt,pintBrowseType,pintLocation)
        BrowseForFolder=pstrTempFolder.ParentFolder.ParseName(pstrTempFolder.Title).Path
        If Err.Number<>0 Then BrowseForFolder=""
        Set pstrTempFolder=Nothing
        Set ShellObject=Nothing
End Function

原文: http://www.enun.net/?p=866

(0)

相关推荐

  • VBS 加解密 For MS Script Encode

    一.加密 复制代码 代码如下: Dim ObjectFSO If (lcase(right(wscript.fullname,11))="wscript.exe") Then WScript.Quit(0)End If If wscript.arguments.count<2 Then Wscript.Echo "VBS Code Encoder v1.0 Powered by ENUN. http://www.enun.net/" Wscript.Echo

  • VBS 加解密 For CAPICOM

    复制代码 代码如下: '******************************************************************************'' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, ' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED ' WA

  • 两种JavaScript的AES加密方式(可与Java相互加解密)

    由于JavaScript属于弱类型脚本语言,因此当其与强类型的后台语言进行数据交互时会产生各种问题,特别是加解密的操作.本人由于工作中遇到用js与Java进行相互加解密的问题,在网上查了很多资料及代码段,均无法解决.后总结多篇文档内容终于找到解决办法,现记录与此: 下面给大家介绍两种JavaScript的AES加密方式,具体详情如下所示: 第一种:加解密时需要秘钥(key)和秘钥偏移量(iv)的情况,在线验证地址:http://www.seacha.com/tools/aes.html //该方

  • 一个批量编码转换及ASP/JS加解密/简繁转换的工具

    详情看这里  http://hi.baidu.com/lael80/blog/item/6633d7fc89f9f282b801a061.html  http://www.gzyd.net/lael/coding.rar  文件编码转换/Screnc加解密/简繁转换 1.0  使用注意:  1.使用前请备份,使用本软件造成的损失自负:  2.进行编码转换前请确认所有文件的源编码一致并选择正确,否则可能出现错误.  3.对ASP代码进行加密或解密或简繁转换前须确认文件的编码为ANSI,否则可能出现

  • Base64加解密的实现方式实例详解

    Base64加解密的实现方式实例详解 本实现方式基于JDK 1.8 实现: import java.util.Base64; import java.util.Base64.Decoder; import java.util.Base64.Encoder; public class Main { static String src = "hello,sahadev"; public static void main(String[] args) { // 获取加密对象 Encoder

  • asp.net实现的MD5加密和DES加解密算法类完整示例

    本文实例讲述了asp.net实现的MD5加密和DES加解密算法类.分享给大家供大家参考,具体如下: #region MD5算法 public string md5(string str, int code) { if (code == 32) //32位加密 { return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").ToLower(); } else /

  • php5数字型字符串加解密代码

    <?php /* ---------------------------------------------------------------------------- * Script Name: encrypt.php * Creation Date: 2008-4-7 10:36 * Last Modified: 2008-4-12 16:00 * Author: meyu * Copyright (c) 2007 * Purpose: 数字字符串简易加解密 * ------------

  • C#字符串使用密钥进行加解密

    第一个为大家分享的是C#字符串使用密钥进行加解密代码,具体内容如下 public class DesEncrypt { /// <summary> /// 算法偏移量 /// </summary> const string m_IV = "12345678"; /// <summary> /// 功能描述:根据输入的密钥生成8位密钥 /// 作 者: 爱给模板网 2gei.cn /// 创建日期:2015-07-20 17:25:26 /// <

  • Android Rsa数据加解密的介绍与使用示例

    Rsa加密 RSA是目前最有影响力的公钥加密算法,RSA也是第一个既能用于数据加密也能用于数字签名的算法.该算法基于一个十分简单的数论事实:将两个大素数相乘十分容易,但那时想要对其乘积进行因式分解却极其困 难,因此可以将乘积公开作为加密密钥,即公钥,而两个大素数组合成私钥.公钥是可发布的供任何人使用,私钥则为自己所有,供解密之用. RSA算法原理 1.随机选择两个大质数p和q,p不等于q,计算N=pq: 2.选择一个大于1小于N的自然数e,e必须与(p-1)(q-1)互素. 3.用公式计算出d:

  • 我见过最全的个人js加解密功能页面

    网上那么长时间来,最牛的加密解密页面的,太强了,站长破解加密代码,病毒代码解密常备代码,本站将把在线工具给整理下,方便大家的使用 复制代码 代码如下: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD><TITLE>个人js加解密功能页面</TITLE> <SCRIPT>eval(function(p,a,c,k,e

随机推荐