在地址处写入字节(从命令行进行十六进制编辑/修改二进制文件) [英] Write byte at address (hexedit/modify binary from the command line)

查看:36
本文介绍了在地址处写入字节(从命令行进行十六进制编辑/修改二进制文件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么直接的方法可以从命令行修改二进制文件吗?假设我知道我的二进制文件包含 1234abcd,我想将其更改为 12FFabcd 或 FFFFabcd 或什至 FF34FFabc0(您明白了):-)

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) :-)

我如何在不使用任何特殊用途的工具(例如 http://stahlworks.com/dev/swiss-file-knife.html 或类似的.

How might I achieve that without using any special purpose tools like http://stahlworks.com/dev/swiss-file-knife.html or similar.

仅使用标准 linux 工具从命令行执行此操作会很棒.

It would be great to do it just from the commandline with only standard linux tools.

或者甚至更好,而不是搜索我想替换的十六进制字符串,直接在偏移量 0x10000 处写入 FF,在偏移量 0x100001 处写入 12 等等.

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.

它应该可以编写脚本并直接从命令行运行.我正在寻找类似binary-which-is-included-in-the-distro --write AB --at-offset 100000 --file thebinary.bin"之类的东西.我很确定使用dd"是可能的,但我无法理解手册页.

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 'x31xc0xc3' | dd of=test_blob bs=1 seek=100 count=3 conv=notrunc 

dd 参数:

  • |要修补的文件
  • bs |请一次 1 个字节
  • 寻求 |转到位置 100(十进制)
  • conv=notrunc |编辑后不要截断输出(dd 默认情况下这样做)
  • 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)

一个 Josh 正在寻找另一个 ;)

One Josh looking out for another ;)

这篇关于在地址处写入字节(从命令行进行十六进制编辑/修改二进制文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆