Modifying binary file hex data using VBS

Source: Internet
Author: User
Use VBS to modify binary file hex data. The first parameter is the original file, the second parameter is the modified file, the third parameter is the original hex value, and the fourth parameter is the modified hex value

Available, such as: Hidden shortcuts in the target file location, crack XP in the number of TCP/IP connections, remove the RAR right button decompression menu and so on.

Copy Code code as follows:


Public BinaryData

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

If wscript.arguments.count<4 Then
WScript.Echo "Change File Hex. BY:LXZZR lxzzr@21cn.com "
WScript.Echo ""
WScript.Echo "Usage:cscript.exe" & WScript.ScriptName & "FilePath savepath ShEx"
WScript.Echo ": Cscript.exe Chex.vbs" "". Test.exe "" "". New.exe "" "" 7A "" "" 7A 01 61 "" "
Wscript.Quit (0)
End If

ShEx = Replace (LCase (WScript.Arguments (2)), "", "")
DHex = Replace (LCase (WScript.Arguments (3)), "", "")

WScript.Echo "File:" & wscript.arguments (0)
WScript.Echo "ShEx:" & WScript.Arguments (2)
WScript.Echo "DHex:" & WScript.Arguments (3)

Readbinary (wscript.arguments (0))

MyData = Replace (BinaryData, ShEx, DHex)

Writebinary wscript.arguments (1), MyData

WScript.Echo "All done."
Wscript.Quit (0)


Function readbinary (FileName)
Dim Stream, Objxml, Mynode

Set Objxml = CreateObject ("Microsoft.XMLDOM")
Set Mynode = objxml.createelement ("binary")
Set Stream = CreateObject ("ADODB.") Stream ")

Mynode.datatype = "Bin.hex"

Stream.type = 1
Stream.open
Stream.loadfromfile FileName

Mynode.nodetypedvalue = Stream.read

Stream.Close

BinaryData = Mynode.text

Set Mynode = Nothing
Set Stream = Nothing
Set Objxml = Nothing
End Function


Function writebinary (FileName, Bufferdata)
Dim Stream, Objxml, Mynode

Set Objxml = CreateObject ("Microsoft.XMLDOM")
Set Mynode = objxml.createelement ("binary")
Set Stream = CreateObject ("ADODB.") Stream ")

Mynode.datatype = "Bin.hex"
Mynode.text = Bufferdata

Stream.type = 1
Stream.open
Stream.Write Mynode.nodetypedvalue
Stream.savetofile FileName, 2
Stream.Close

Set stream = Nothing
Set Mynode = Nothing
Set Objxml = Nothing
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.