当前位置: 移动技术网 > IT编程>脚本编程>VBScript > 使用VBS修改二进制文件HEX数据

使用VBS修改二进制文件HEX数据

2017年12月08日  | 移动技术网IT编程  | 我要评论

租家具,苦情电视剧,郭本才

可用之处还是有的,如:隐藏快捷方式中目标文件位置;破解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  lxzzr@21cn.com"
 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

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网