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

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

问题描述

是否有任何直接的方法可以从命令行修改二进制文件?
比方说,我知道我的二进制文件包含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处直接写入FF,以此类推。

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.

它应该是可编写脚本的,并且可以直接从命令行运行。我正在寻找类似发行版中包含的二进制文件--write AB --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 '\x31\xc0\xc3' | dd of=test_blob bs=1 seek=100 count=3 conv=notrunc 

dd参数:


  • of | |要修补的文件

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

一个乔什(Jush)寻找另一个;)

One Josh looking out for another ;)

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

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