标题: 二进制方式处理文件工具 STR (2020.11.16 更新)
[打印本页]
作者: 19951001
时间: 2008-4-26 21:45
标题: 二进制方式处理文件工具 STR (2020.11.16 更新)
STR [File] [Start] [Bytes] [/C|/I] [dstFile] [Address]
File: A File to be Processed data. //文件
Start: Offset to Process data. //文件中处理数据的起始位置 (文件的开头位置为0)
Bytes: Bytes to Process. //要处理的字节数量 (如果输入0,则表示从Start开始到文件末尾)
/C: Copy Bytes from File to dstFile. //从源文件向目标文件复制数据
/I: Insert Bytes to dstFile from File. //从源文件向目标文件插入数据,插入数据后目标文件增加 Bytes个字节
dstFile: A File to Write Result data. //目标文件
Address: Offset to Write Result data. //目标文件中要复制或插入数据的位置 (如果目标文件不存在,该值被忽略)
STR [File] [Start] [Bytes] [/D] [dstFile]
/D: Delete Bytes from File & Write Result to dstFile. //从源文件删除数据并结果写入目标文件
STR [File] [Start] [Bytes] [/V] [/A] [/P]
/V: View File In Hex Style. //十六进制方式查看文件
/A: Show ASCII Value. //显示ASCII码
/P: Pause Echo Screen. //满屏暂停
STR [File] [Start] [Bytes] [/F] [/Hex|/Asc]:[Value] [/I] [/A]
Bytes: Must be 0. //必须为0
/F: Find String in File. //在文件中查找字符串
/Hex: Hex Style. //十六进制方式
/Asc: ASCII Style. //ASCII码方式
Value: Hex_Digital/ASCII String (40 Characters Maximum). //字符传真的值,最长40个字符 (如果是十六进制串长度应为双数)
/I: Ignore Case. //忽略大小写
/A: Process All Value in File. //在文件中查找所有满足要求的字符串(默认查找1次)
STR [File] [Start] [Bytes] [/E] [/Hex|/Asc]:[Value]
Bytes: Must be 0. //必须为0
/E: Edit File. //编辑文件
STR [File] [Start] [Bytes] [/R] [SrcString] [DstString] [/I] [/A]
Bytes: Must be 0. //必须为0
/R: Relace SrcString with DstString. //字符常替换
SrcString: [/Hex|/Asc]:[Value]. //源串,可以使用十六进制或ASCII码串
DstString: [/Hex|/Asc]:[Value]. //目标串,可以使用十六进制或ASCII码串
/A: Process All SrcString in File. //在文件中查找所有源字符串(默认替换1次)
说明:
1 使用 /C 和 /I 命令时,如果目的文件不存在,Adress 的值将被忽略,直接执行将源文件从 Start 开始的 Bytes 个字节写入到新创建的目的文件中
2 使用 /C 和 /I 命令时,如果目的文件存在,并且不输入 Address,则Address 默认为0,也就是文件的起始位置。
3 目前处理的单个文件大小不超过 2G
例子:
str 1.exe 0x100 0x10 /d 2.bin 执行将文件1.exe 从位置256开始的16个字节删除,并将结果写入到2.bin,文件2.bin的长度将比1.exe长度小16
str 1.exe 0x100 0x10 /c 2.bin 20 执行将文件1.exe 从位置256开始的16个字节写入到2.bin的20位置,也就是文件2.bin从位置20开始的16字节被覆盖
str 1.exe 0x100 0x10 /i 2.bin 20 执行将文件1.exe 从位置256开始的16个字节插入到2.bin的20位置,结果文件2.bin的长度将增加16字节
str 1.exe 0x100 0 /v /p /a 从文件偏移位置256开始在屏幕上显示文件内容,如果Bytes输入为0,则表示从Start开始至文件末尾。
str 1.exe 0x100 0 /e /hex:11223344 将文件偏移位置256开始的4个字节修改为,0x11,0x22,0x33,0x44。
str 1.exe 0x100 0 /e /asc:1234 将文件偏移位置256开始的4个字节修改为,1234, 也就是0x31,0x32,0x33,0x34
查找替换算法使用的是 KMP 算法,不重复计数,如文件 1.txt 的内容为10个字符0:
0000000000
如执行命令: str 1.txt 0 0 /f /asc:0000 /a
则执行结果为:
Find string At:
0 0x0
4 0x4
不会是:
Find string At:
0 0x0
1 0x1
2 0x2
3 0x3
4 0x4
5 0x5
6 0x6
压缩包中包含DOS版本和Win32版本
2008.12.14 修正替换字符串功能中存在的问题
2008.12.19 修正19楼存在问题
2009.2.15 测试版本在50楼
[
Last edited by 19951001 on 2020-11-16 at 17:01 ]
附件
1:
str.rar (2008-12-19 22:27, 18.38 K, 下载附件所需积分 1点
,下载次数: 168)
附件
2:
strWin32.rar (2020-11-16 17:00, 20.34 K,下载次数: 7)
作者: cchessbd
时间: 2008-4-28 17:29
可能这个东西我用不到,但是我需要一个DOS下查找替换文件中的某个字符串的工具……
不知道 19950101兄能否帮忙写一个?
比如: XXX /rN file "12345,d" "54321,g"
查找到才替换,或替换一次就退出。
替换所有 /r N次 /rN
此文件可能会有 3~10 M
[
Last edited by cchessbd on 2008-4-28 at 05:39 PM ]
作者: 19951001
时间: 2008-5-7 22:52
Quote: |
Originally posted by cchessbd at 2008-4-28 17:29:
可能这个东西我用不到,但是我需要一个DOS下查找替换文件中的某个字符串的工具……
不知道 19950101兄能否帮忙写一个?
比如: XXX /rN file "123 ... |
|
只需要对文本文件处理吗?
作者: 19951001
时间: 2008-11-14 21:20
2008.11.14 更新
作者: 本是
时间: 2008-11-15 00:01
好工具,但.rar 解压时报错:文件"WIN"头被损坏!
请重新上传!!!
作者: 雨露
时间: 2008-11-15 08:07
报错后win32文件夹是空的!
作者: 本是
时间: 2008-11-15 11:13
文件WIN在根目录。
作者: 19951001
时间: 2008-11-15 11:42
已经修复破损的压缩包
作者: chishingchan
时间: 2008-11-24 21:25
因需修改二进制文件,这种小软件我以前寻找过,只找到纯DOS下的FH,现在这个应该不错。
作者: goli2008
时间: 2008-12-13 11:07
坚决支持,!!
找了好久,请楼主将标题改改,可好,方便其他人搜索,谢谢!
作者: chenall
时间: 2008-12-13 18:10
好东西,收下了,谢谢!
作者: chenall
时间: 2008-12-13 19:10
可不可以再加个功能"字符转义"
比如\0 就是ASCII码00
比如
strw test.bin 0x10 0 /e /asc:test\13\0
会写入test和0X0D和0X00
作者: 19951001
时间: 2008-12-13 22:28
Quote: |
Originally posted by chenall at 2008-12-13 19:10:
可不可以再加个功能"字符转义"
比如\0 就是ASCII码00
比如
strw test.bin 0x10 0 /e /asc:test\13\0
会写入test和0X0D和0X00 |
|
理论上可以实现,不过我近些日子比较忙,暂时没有时间修改
其实也可以这样实现
strw test.bin 0x10 0 /e /asc:test
strw test.bin 0x14 0 /e /hex:1300
上述两条命令可以实现你要的功能
[
Last edited by 19951001 on 2008-12-13 at 23:18 ]
作者: chenall
时间: 2008-12-14 09:43
嗯,上面是可以实现,只是如果放在批处理里面要计算字符长度会比较麻烦.
另一个问题,不知程序有没有返回errorleve值?
比如查找,成功返回?失败返回?
作者: chenall
时间: 2008-12-14 10:14
查找替换功能好像有些问题..
文件A.TXT内容
Exe =$1\TEST
Exe =$1\TEST2
strw a.txt 0 0 /r /asc:$1 /asc:j: /a
得到的结果为乱码,而且丢失字符
正确的结果
Exe =J:\TEST
Exe =J:\TEST2
作者: 19951001
时间: 2008-12-14 16:10
Quote: |
Originally posted by chenall at 2008-12-14 10:14:
查找替换功能好像有些问题..
文件A.TXT内容
Exe =$1\TEST
Exe =$1\TEST2 strw a.txt 0 0 /r /asc:$1 /asc:j: /a
得到的结果为乱码,而且丢失字符
正确的 ... |
|
已经修正,见一楼附件
作者: lianjiang2004
时间: 2008-12-14 16:41
我说怎么前几天用来给grldr改名不行,改后文件大小都变了。
修正后的已没问题。
作者: chenall
时间: 2008-12-14 21:17
#17
用grubutil现在改名已经没有问题了.
作者: goli2008
时间: 2008-12-18 09:43
大侠,写0出错啊
str 1.exe 0x03 0 /e /hex:0011
碰到00时,不能写入
急用,能否尽快修正?
[
Last edited by goli2008 on 2008-12-18 at 14:06 ]
作者: hefeilixin
时间: 2008-12-18 10:40
Quote: |
如执行命令: str 1.txt 0 0 /f /asc:0000 /a
则执行结果为:
Find string At:
0 0x0
4 0x4 |
|
请问这个是怎么输出的?
作者: 19951001
时间: 2008-12-19 22:31
Quote: |
Originally posted by chenall at 2008-12-14 09:43:
嗯,上面是可以实现,只是如果放在批处理里面要计算字符长度会比较麻烦.
另一个问题,不知程序有没有返回errorleve值?
比如查找,成功返回?失败返回? |
|
#define SUCCESS 0
#define COMMON_USE_ERROR 1
#define OPEN_FILE_ERROR 2
#define PRG_MODIFIED 3
#define FILE_READ_ERROR 4
#define PARAMETER_ERROR 5
#define CREATE_FILE_ERROR 6
#define FILE_WRITE_ERROR 7
#define SRCFILE_DSTFILE_SAME 8
#define USER_CANCEL 9
#define FILE_NOT_EXIST 10
#define FILE_SEEK_ERROR 11
#define STRING_NOT_FOUND 12
作者: chenall
时间: 2008-12-19 23:19
收下,更新了, 用返回值用于批处理比较方便.
作者: lianjiang2004
时间: 2008-12-24 12:46
杀软报毒的问题,能否进一步改进?
反病毒引擎 版本 最后更新 扫描结果
Panda 9.0.0.4 2008.12.23 Suspicious file
eSafe 7.0.17.0 2008.12.23 Suspicious File
CAT-QuickHeal 10.00 2008.12.23 (Suspicious) - DNAScan
TrendMicro 8.700.0.1004 2008.12.23 PAK_Generic.001
作者: 19951001
时间: 2008-12-24 23:41
Quote: |
Originally posted by lianjiang2004 at 2008-12-24 12:46:
杀软报毒的问题,能否进一步改进?
反病毒引擎 版本 最后更新 扫描结果
Panda 9.0.0.4 2008.12.23 Suspicious file
eSafe 7.0.17.0 2 ... |
|
dos版本还是Win32版本?
上传一个重新编译的Win32版本,看一下是否还报。
[
Last edited by 19951001 on 2008-12-24 at 23:59 ]
附件
1:
strWin32.rar (2008-12-24 23:59, 6.83 K, 下载附件所需积分 1点
,下载次数: 2)
作者: lianjiang2004
时间: 2008-12-25 09:00
是win32版的,新版仍有4家误报。
结果参看:
http://www.virustotal.com/zh-cn/ ... 52acffa461f01a8ff3f
作者: 19951001
时间: 2008-12-26 20:33
这里使用了3个编译器编译,vc6、vc2005、watcom_c_c++,看一下是否还报。
附件
1:
str.rar (2008-12-26 20:33, 79.8 K, 下载附件所需积分 1点
,下载次数: 6)
作者: 19951001
时间: 2008-12-26 21:09
我自己查了一下,这是结果:
vc6版本
http://www.virustotal.com/zh-cn/ ... 8888f3f99d8f67405e0
vc2005版本
http://www.virustotal.com/zh-cn/ ... 2b9d13bfcfcb02c61f9
watcon_c_c++版本
http://www.virustotal.com/zh-cn/ ... 7f75aa497a3a946fb57
看来是使用watcom_c_c++编译误报可能最小。
作者: lianjiang2004
时间: 2008-12-26 21:16
辛苦了,看来这个问题有些难处理。那就没办法了,只能这样了。
作者: 19951001
时间: 2008-12-26 22:10
标题: 终于解决了误报
终于解决了误报,使用gcc编译程序。
http://www.virustotal.com/zh-cn/ ... a8bb89b41affc255e91
附件
1:
STR.rar (2008-12-26 22:10, 22.06 K, 下载附件所需积分 1点
,下载次数: 30)
作者: lianjiang2004
时间: 2008-12-26 22:20
太好了,这样就不会出现有人来报告有毒了。感谢。
方便的话,麻烦你把dspt和diskrw也重新编译一下,我的GGhost中也要使用到。
作者: 19951001
时间: 2008-12-26 22:27
Quote: |
Originally posted by lianjiang2004 at 2008-12-26 22:20:
太好了,这样就不会出现有人来报告有毒了。感谢。
方便的话,麻烦你把dspt和diskrw也重新编译一下,我的GGhost中也要使用到。 |
|
没有问题,马上处理。
作者: 19951001
时间: 2008-12-26 23:40
暂时还不可以编译,程序中有一段汇编代码,gcc不支持汇编,等我不忙时改写一下。
作者: goli2008
时间: 2008-12-27 22:49
继续顶上!!
将标题改为:二进制文件编辑工具,可能让更多人搜索到。
作者: 19951001
时间: 2009-1-1 02:02
一个小工具:
HexTool [Filename] [/S] [BytesPerLine] [Spaces] [/Type] [/U]
Filename: A File. //文件名
/S: Show File on Screen //显示
BytesPerLine: Bytes per line(An Integer). //每行显示多少个字符
Spaces: Spaces before Echo line. //每行开始的空格数
/Type: Can be C/PASCAL/ASM. //显示类型
/U: Upcase. //大写
可以把文件显示成C、Pascal或汇编形式
附件
1:
bitmn.rar (2009-1-1 02:02, 3.35 K, 下载附件所需积分 1点
,下载次数: 26)
作者: byxyk
时间: 2009-1-3 16:03
谢谢了。
作者: AriesChen
时间: 2009-1-8 12:01
谢谢LZ,正是我需要的
作者: Piyeluo
时间: 2009-1-11 13:53
找了好久的工具今天终于找到了,谢谢楼主.
作者: tegl
时间: 2009-1-17 20:26
好工具,收下慢慢研究
作者: cdb723g
时间: 2009-1-20 19:50
好东西的确难找,谢谢提供。
作者: pseudo
时间: 2009-2-6 00:00
好工具。
请问,怎样关闭显示?
大凡dos命令一般都可通过命令行参数,或>nul关闭屏幕显示信息,以便统一控制应用程序的界面。但楼主的程序总要显示几行信息。如果多次调用,屏幕显得乱。
有没有能关闭显示的方法或版本?
[
Last edited by pseudo on 2009-2-6 at 00:02 ]
作者: folk
时间: 2009-2-8 11:39
好工具,谢谢楼主 !
作者: DJ131452DJ
时间: 2009-2-8 15:22
谢谢楼主 !
作者: zhaoliang518
时间: 2009-2-12 23:28
不错的东东,
正需要,下来试试
作者: 19951001
时间: 2009-2-15 23:13
根据12楼和40楼提出的建议进行改进,字符串形式增加 /Mix 参数,也就是字符串形式可采用asc和十六进制字符串混合形式,混合形式中如果使用十六进制参数需要使用转义字符 \ ,如果 \50\45 代表字符串“PE”,\ 后必须跟16进制的两个字符,如\AD 、\03 等不可简写,如果使用字符 \ 在混合方式下要使用 \\代替,基本遵循C语音的使用方式。
这是测试版本,如果没有问题发布正式版本。
附件
1:
str215.rar (2009-2-15 23:13, 7.98 K, 下载附件所需积分 1点
,下载次数: 26)
作者: chenall
时间: 2009-2-15 23:53
谢谢,先下载测试下.
作者: chenall
时间: 2009-2-17 13:50
试了下暂时没有发现问题.
另有一个建议,替换时能否充许替换内容为空?
即删除找到的内容.
作者: 19951001
时间: 2009-2-18 00:04
Quote: |
Originally posted by chenall at 2009-2-17 13:50:
试了下暂时没有发现问题.
另有一个建议,替换时能否充许替换内容为空?
即删除找到的内容. |
|
先执行查找,再执行删除即可。
作者: DJ131452DJ
时间: 2009-2-19 05:33
Quote: |
Originally posted by goli2008 at 2008-12-13 11:07:
坚决支持,!!
找了好久,请楼主将标题改改,可好,方便其他人搜索,谢谢! |
|

作者: pseudo
时间: 2009-2-23 16:04
谢谢,希望有dos版的
作者: 19951001
时间: 2009-2-23 21:25
Quote: |
Originally posted by pseudo at 2009-2-23 16:04:
谢谢,希望有dos版的 |
|
见附件
附件
1:
str215.rar (2009-2-23 21:25, 19.7 K, 下载附件所需积分 1点
,下载次数: 68)
作者: pseudo
时间: 2009-2-24 17:39
谢谢,试了下dos版没有发现问题。
作者: hjh700913
时间: 2009-4-18 05:25
谢谢
作者: wdshop
时间: 2009-8-10 00:03
标题: 不错的工具
不错的工具
作者: h20040606
时间: 2009-8-11 20:50
这个工具太好了,谢谢
作者: cijbrr
时间: 2009-10-13 08:57
剛註冊,等可以回覆拿積分等好久!總算有積分可以下了!感恩!
作者: alearner126
时间: 2009-10-22 17:20
及时雨!!!
作者: atoms
时间: 2010-3-20 01:35
标题: 找好久找好久
找好久找好久
作者: xypcmac
时间: 2010-3-21 21:48
小巧玲珑
作者: atoms
时间: 2010-4-1 12:52
标题: 好久才找到
好久才找到
作者: 283868130
时间: 2010-5-29 15:35
东西不错,谢谢!
作者: abshuhuhuhu
时间: 2010-6-19 23:37
真的非常不错!
刚好中病毒需要这个软件来恢复数据!
万恶的doc病毒!
作者: wchoverchen
时间: 2010-7-13 22:31
刚好需要这个工具,多谢
作者: weishu2006
时间: 2010-9-27 09:42
标题: 好思路
不错
作者: jayhuang
时间: 2010-11-2 15:56
标题: wwww
qqqqqqqqqqqqqqqqqqq
作者: greenworld
时间: 2010-11-6 08:39
这个工具非常强大,但貌似不支持正则???
作者: zcj6758
时间: 2010-11-6 11:22
CODE: [Copy to clipboard]
--------------------------------------------------------------------------------
Exe =J:\TEST
Exe =J:\TEST2
作者: wang123ok
时间: 2018-10-6 22:21
好 喜欢。
作者: zx511325
时间: 2019-2-2 06:41
多谢楼主
作者: 19951001
时间: 2020-11-16 18:44
标题: 将Str的最终版本放出来了(2009.10.29)Win32版本,在一楼
Powerful Tools for Process Binary Data in File(s)
Written by 19951001, Compiled: 2009-10-29, V1.02b
Free for Personal use, E-mail:
Tswrl1115@163.com
STR [File] [Start] [Bytes] [/C|/I] [DstFile] [Address]
File: A File to be Processed data.
Start: Offset in File.
Bytes: Bytes to be Processed.
/C|/I: Copy|Insert Bytes from File to DstFile.
DstFile: A File to Write data.
Address: Offset in DstFile.
STR [File] [Start] [Bytes] [/D] [DstFile]
File: A File to be Processed data.
Start: Offset in File.
Bytes: Bytes to be Processed.
/D: Delete Bytes from File & Write Result to DstFile.
DstFile: A New File to Write data.
STR [File] [Start] [Bytes] [/W] [Byte]
File: A File to be Processed data.
Start: Offset in File.
Bytes: Bytes to be Processed.
/W: Fill Data with [Byte] at Specified Position.
Byte: An Integer (0..255, Default is 0).
STR [File] [Start] [Bytes] [/E] [/Hex|/Asc|/Mix]:[Value]
File: A File to be Processed data.
Start: Offset in File.
Bytes: Must be 0.
/E: Edit File.
/Hex: Hex Style.
/Asc: ASCII Style.
/Mix: Hex & ASCII Style.
Value: HexDigital/ASCII/Mixture String (32 Bytes Maximum).
STR [File] [Start] [Bytes] [/F] [/Hex|/Asc|/Mix]:[Value] [/Times:N] [/I] [/A]
File: A File to be Processed data.
Start: Offset in File.
Bytes: Bytes to be Processed.
/F: Find String in File.
/Hex: Hex Style.
/Asc: ASCII Style.
/Mix: Hex & ASCII Style.
Value: HexDigital/ASCII/Mixture string (32 Bytes Maximum).
/Times:N, Find [Value] N Times in [File].
/I: Ignore Case ([Value] in [File]).
/A: Process All in File.
STR [File] [Start] [Bytes] [/R] [SrcData] [DstData] [/Times:N] [/I] [/A]
File: A File to be Processed data.
Start: Offset in File.
Bytes: Bytes to be Processed.
/R: Relace SrcData with DstData.
SrcData: [/Hex|/Asc|/Mix]:[Value].
DstData: [/Hex|/Asc|/Mix]:[Value].
/Times:N, Relace [SrcData] with [DstData] N Times in [File].
/I: Ignore Case ([SrcData] in [File]).
/A: Process All in File.
STR [File] [Start] [Bytes] [/S] [BytesPerLine] [Spaces] [/Type] [/U]
File: A File to be Processed data.
Start: Offset in File.
Bytes: Bytes to be Processed.
/S: Show File on Screen.
BytesPerLine: Bytes per line (Default is 10).
Spaces: Spaces before echo line (Default is 0).
Type: Can be [C, PASCAL, ASM] (Default is C).
/U: Upcase (Default is Lowercase).
STR [File] [Start] [Bytes] [/M] [DstFile] [Address] [Bits]
File: A File to be Processed data.
Start: Offset in File.
Bytes: Bytes to be Processed.
/M: Right Rotate [Bits] of each Byte.
DstFile: A File to Write data.
Address: Offset in DstFile.
Bits: An Interger (1..7, Default is 4).
STR [File] [Start] [Bytes] [/O] [DstFile] [Address]
File: A File to Compare data.
Start: Offset in File.
Bytes: Bytes to be Processed.
/O: Compare Bytes between File and DstFile.
DstFile: A File to Compare data.
Address: Offset in DstFile.
STR [File] [Start] [Bytes] [/V] [/A] [/P]
File: A File to be Processed data.
Start: Offset in File.
Bytes: Bytes to be Processed.
/V: View File In Hex Style.
/A: Show ASCII Value.
/P: Pause echo Screen.
STR [File] [Start] [Bytes] [/N]
File: A File to be Created.
Start: Must be 0.
Bytes: FileSize (0..2147483647, or 0x00..0x7FFFFFFF).
/N: Create New File and FileSize is [Bytes].
作者: LoggerVick
时间: 2020-11-26 17:01
隔了这么多年竟然更新了,看一下。