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
Todo
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 is decoded to a ' > '
Tdecode (=left) (Tdecode (1) & ")" & Right (Tdecode (42), 1)
Set se=nothing
Chaine=replace (Replace (Chaine, "@&", Chr ()), "@#", 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 +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