![from from](https://c1.lmlphp.com/image/static/default_avatar.gif)
本文介绍了CLI:在地址处写入字节(hexedit /从命令行修改二进制文件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有任何直接的方法从命令行修改二进制文件?
假设我知道我的二进制文件包含1234abcd,我想将其更改为12FFabcd或FFFFabcd,或者甚至可以使用FF34FFabc0(您会明白): - )
如何在不使用任何特殊用途的工具如或类似的文件。
只用标准linux工具就可以从命令行执行它。 p>
或者,甚至可能更好,而不是搜索十六进制字符串,我想直接在偏移量0x10000处写FF,在偏移量为0x100001的位置处写入FF。
任何想法?
谢谢!
PS:如下所示:
它应该可以编写脚本并直接从命令行运行。我正在寻找类似binary-which-is-in-the-distro --write AB --at-offset 100000 --file thebinary.bin的东西。我确信它可以使用dd,但我无法将自己的头部包裹在手册页中。
解决方案 printf'\x31\xc0\xc3'| dd of = test_blob bs = 1 seek = 100 count = 3 conv = notrunc
p>
- of |文件修补
- bs |请每次1个字节
- 搜寻 |转到位置100(十进制)
- conv = notrunc |不要在编辑后截断输出(默认为dd)
一个Josh寻找另一个;)
>
Is there any straightforward way to modify a binary from the commandline?Let's say I know that my binary contains 1234abcd and i want to change it to 12FFabcd or FFFFabcd or maybe even FF34FFabc0 (you get the idea) :-)
How might I achieve that without using any special purpose tools like http://stahlworks.com/dev/swiss-file-knife.html or similar.
It would be great to do it just from the commandline with only standard linux tools.
Or maybe even better instead for searching for the hex string i want to replace directly writing FF at Offset 0x10000, 12 at Offset 0x100001 and so on.
Any idea?
Thanks in advance!
P.S.: I should add the following:
It should be scriptable and run directly from the commandline. I am looking for something like "binary-which-is-included-in-the-distro --write AB --at-offset 100000 --file thebinary.bin". I am quite sure that it is possible with "dd", but I wasn't able to wrap my head around the man page.
解决方案
printf '\x31\xc0\xc3' | dd of=test_blob bs=1 seek=100 count=3 conv=notrunc
dd arguments:
- of | file to patch
- bs | 1 byte at a time please
- seek | go to position 100 (decimal)
- conv=notrunc | don't truncate the output after the edit (which dd does by default)
One Josh looking out for another ;)
这篇关于CLI:在地址处写入字节(hexedit /从命令行修改二进制文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!