程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 更多關於編程 >> 使用VBS修改二進制文件HEX數據

使用VBS修改二進制文件HEX數據

編輯:更多關於編程
    利用VBS修改二進制文件HEX數據。第一個參數為原文件,第二個參數為修改後的文件,第三個參數為原HEX值,第四個參數為修改後的HEX值  

    可用之處還是有的,如:隱藏快捷方式中目標文件位置;破解XP中TCP/IP連接數限制;去掉RAR右鍵解壓菜單等等。

    復制代碼 代碼如下:
    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  [email protected]"
     Wscript.Echo ""
     Wscript.Echo "Usage: cscript.exe " & WScript.ScriptName & " FilePath SavePath sHEX dHEX"
     Wscript.Echo "     : cscript.exe CHex.vbs "".test.exe"" "".new.exe"" ""80 7A 01 61"" ""80 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

     

    1. 上一頁:
    2. 下一頁:
    Copyright © 程式師世界 All Rights Reserved