如何編寫(xiě)VBS加解密代碼-創(chuàng)新互聯(lián)

本篇內(nèi)容介紹了“如何編寫(xiě)VBS加解密”的有關(guān)知識(shí),在實(shí)際案例的操作過(guò)程中,不少人都會(huì)遇到這樣的困境,接下來(lái)就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!

成都創(chuàng)新互聯(lián)公司云計(jì)算的互聯(lián)網(wǎng)服務(wù)提供商,擁有超過(guò)13年的服務(wù)器租用、成都天府聯(lián)通服務(wù)器托管、云服務(wù)器、網(wǎng)頁(yè)空間、網(wǎng)站系統(tǒng)開(kāi)發(fā)經(jīng)驗(yàn),已先后獲得國(guó)家工業(yè)和信息化部頒發(fā)的互聯(lián)網(wǎng)數(shù)據(jù)中心業(yè)務(wù)許可證。專業(yè)提供云主機(jī)、網(wǎng)頁(yè)空間、域名注冊(cè)、VPS主機(jī)、云服務(wù)器、香港云服務(wù)器、免備案服務(wù)器等。

一、加密

復(fù)制代碼 代碼如下:

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


二、解密

復(fù)制代碼 代碼如下:

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


“如何編寫(xiě)VBS加解密”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!

網(wǎng)站標(biāo)題:如何編寫(xiě)VBS加解密代碼-創(chuàng)新互聯(lián)
網(wǎng)頁(yè)路徑:http://muchs.cn/article28/dpijcp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供全網(wǎng)營(yíng)銷推廣App設(shè)計(jì)、做網(wǎng)站、網(wǎng)站收錄建站公司、企業(yè)建站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

網(wǎng)站建設(shè)網(wǎng)站維護(hù)公司