Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What should be paid attention to in encryption in vbs script

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article is about what you need to pay attention to in encryption in vbs scripts. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

The code is as follows:

I have been learning vbs for a short time. Recently, I saw a book about the encryption of vbs scripts, so I tried it myself, but there was a problem. I corrected all the low-level syntax errors myself, but the script didn't work after running. So I'd like to ask you something. The principle of the script is this: it converts the code to hexadecimal, then writes a decryption code through which the encrypted code is executed, and the string into hexadecimal code is as follows:

Function str2hex (Byval strHex)

For iTunes 1 to Len (strHex)

SHex = sHex & Hex (Asc (mid (strHex,i,1)

Next

Str2Hex = sHex

End Function

The code for decryption 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

There seems to be something wrong with the decryption code. Please correct it. I really can't find it.

The whole finished product is:

On error resume next

Set arg=wscript.arguement 'declares external parameters

If arg.count=0 Then wscript.quit 'exit the script if there are no parameters

Set fso=creatobject ("Scripting.Filesystem Object") 'declares the fso component

When fso.opentextfile (arg (0), 1je flase)

Data = readall:.close' reads text content

If err.number0 then wscript.quit 'exit if an error occurs

With fso.opentextfile (arg (0) & "* .vbs", 2 vbs true) 'will write the converted ones to a new VBs

If err.number0 then wscript.quit 'exit if an error occurs

.writeline "Execute (Hextostr (" & str2hex (data) & "") ") 'executes the decryption and executes 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 tostr & c&Left (data,4) & N"

.writeline "data=mid (data,5)"

.writeline "end if"

.writeline "loop"

.writeline "end function"

'write in the decryption function

.close 'close text

Set fso=Nothing' unregisters the fso component

End with

Msgbox "OK"

'The following is the encryption function

Function str2hex (Byval strHex)

For iTunes 1 to Len (strHex)

SHex = sHex & Hex (Asc (mid (strHex,i,1)

Next

Str2Hex = sHex

End function

'that 's all the code. It's so long.

The book says, just drag the vbs script to be encrypted to this script, but I didn't succeed. I don't know what's wrong. Please help me, thank you.

The above code pays attention to several situations:

1 、 set arg=wscript.arguements

There's an s at the back door.

2. Set fso=creatobject ("Scripting.Filesystem Object") 'declares the fso component

It's supposed to be filesystemboject.

3. Writeline "N =)"

For the need to output N = ")" input with vbs "(double quotation marks) is to use two"

.writeline "N =") "

4. Writeline "data = (data,3)" there are fewer mid here

That's basically it.

Do.vbs is saved as do.vbs. Drag the encrypted js file to this file.

The copy code is as follows:

'on error resume next

Set arg=wscript.arguments' declares external parameters

If arg.count=0 Then wscript.quit 'exit the script if there are no parameters

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.number0 then wscript.quit 'exit if an error occurs

With fso.opentextfile (filename& "_ out.vbs", 2J true) 'will write the converted ones to a new vbs

If err.number0 then wscript.quit 'exit if an error occurs

.writeline "Execute (Hextostr (" & str2hex (data) & "") ") 'executes the decryption and executes 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 in the decryption function

.close 'close text

End with

Set fso=Nothing' unregisters the fso component

Msgbox "OK"

'The following is the encryption function

Function str2hex (Byval strHex)

For iTunes 1 to Len (strHex)

SHex = sHex & Hex (Asc (mid (strHex,i,1)

Next

Str2Hex = sHex

End function

Thank you for reading! This is the end of this article on "what do you need to pay attention to in vbs script encryption?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report