Summary of vbs script Encryption

Source: Internet
Author: User

CopyCode The Code is as follows: dxy:
Hello!
I have been learning vbs for a short time. I recently saw a book about vbs script encryption and I tried it myself. But I have a problem. I have fixed all low-level syntax errors myself, it does not work after the script is run. so I 'd like to ask you. the script works like this: it converts the code into a hexadecimal notation, and then writes a decryption code to execute the encrypted code, the code for converting a string into hexadecimal format is as follows:
Function str2hex (byval strhex)
For I = 1 to Len (strhex)
Shex = shex & hex (ASC (mid (strhex, I, 1 )))
Next
Str2hex = shex
End Function

The decryption code is as follows:

Function hextostr (data)
Hextostr = "execute """""
C = "& CHR (& H"
N = ")"
Do While Len (data)> 1
If isnumeric (left (data, 1) then
Hextostr = hextostr & C & left (data, 2) & n
Data = mid (data, 3)
Else
Hextostr = hextostr & C & left (data, 4) & n
Data = mid (data, 5)
End if
Loop
End Function

Decryption code may be a problem. Please correct it. I can't find it.

The entire finished product is:

On Error resume next
Set Arg = wscript. arguement 'declare external parameters
If Arg. Count = 0 then wscript. Quit 'exit the script if no parameter exists.
Set FSO = creatobject ("scripting. filesystem object") 'declares the FSO component
When FSO. opentextfile (ARG (0), 1, flase)
Data = readall:. Close 'read text content
If err. Number <> 0 then wscript. Quit 'exit if an error occurs.
With FSO. opentextfile (ARG (0) & "*. vbs", 2, true) 'write the converted data to a new vbs.
If err. Number <> 0 then wscript. Quit 'exit if an error occurs.
. Writeline "execute (hextostr (" & str2hex (data) & "") "'executes decryption and the decrypted code
. Writeline "function hextostr (data )"
. Writeline "hextostr =" "execute """""""""""
. Writeline "c =" "& CHR (& H """
. Writeline "n = )"
. Writeline "do while Len (data)> 1"
. Writeline "If isnumeric (left (data, 1) then"
. Writeline "hextostr = hextostr & C & left (data, 2) & N"
. Writeline "Data = (data, 3 )"
. Writeline "else"
. Writeline "hextostr = hex to STR & C & left (data, 4) & N"
. Writeline "Data = mid (data, 5 )"
. Writeline "end if"
. Writeline "loop"
. Writeline "end function"
'Write the decryption function
. Close 'Close the text
Set FSO = nothing 'unregister the FSO component
End
Msgbox "OK"
'Here are the encryption functions
Function str2hex (byval strhex)
For I = 1 to Len (strhex)
Shex = shex & hex (ASC (mid (strhex, I, 1 )))
Next
Str2hex = shex
End Function
'The whole code is here, so long ~

The book says that you can drag the vbs script to be encrypted to this script, but I didn't succeed. I don't know the problem. Please help me. Thank you ~

Note the following code:
1. Set Arg = wscript. arguements
Backdoor has a s
2. Set FSO = creatobject ("scripting. filesystem object") 'declares the FSO component.
It should be filesystemboject.
3. writeline "n = )"
To output n = ")" input with vbs "(double quotation marks), use two ""
. Writeline "n = "")"""
4. writeline "Data = (data, 3)" fewer mid here
Basically, that's all.
Do. vbs is saved as do. vbs, And you can drag the JS file to be encrypted to this file. Copy code The Code is as follows: 'On error resume next
Set Arg = wscript. Arguments 'declare external parameters
If Arg. Count = 0 then wscript. Quit 'exit the script if no parameter exists.
Set FSO = Createobject ("scripting. FileSystemObject") 'declares the FSO component
Filename = wscript. Arguments (0)
Set Readline = FSO. opentextfile (filename, 1, flase)
Data = Readline. readall:
Readline. Close 'reads text content
If err. Number <> 0 then wscript. Quit 'exit if an error occurs.
With FSO. opentextfile (filename & "_ out. vbs", 2, true) 'write the converted file to a new vbs.
If err. Number <> 0 then wscript. Quit 'exit if an error occurs.
. Writeline "execute (hextostr (" & str2hex (data) & "") "'executes decryption and the decrypted code
. Writeline "function hextostr (data )"
. Writeline "hextostr =" "execute """""""""""
. Writeline "c =" "& CHR (& H """
. Writeline "n = "")"""
. Writeline "do while Len (data)> 1"
. Writeline "If isnumeric (left (data, 1) then"
. Writeline "hextostr = hextostr & C & left (data, 2) & N"
. Writeline "Data = mid (data, 3 )"
. Writeline "else"
. Writeline "hextostr = hextostr & C & left (data, 4) & N"
. Writeline "Data = mid (data, 5 )"
. Writeline "end if"
. Writeline "loop"
. Writeline "end function"
'Write the decryption function
. Close 'Close the text
End
Set FSO = nothing 'unregister the FSO component
Msgbox "OK"
'Here are the encryption functions
Function str2hex (byval strhex)
For I = 1 to Len (strhex)
Shex = shex & hex (ASC (mid (strhex, I, 1 )))
Next
Str2hex = shex
End Function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.