30

I have a binary file and i want to replace the value A2 at address DEADBEEF with some other value, say A1.

How can I do this with dd? If there are other tools that can do this, please suggest. But I plan to do this on iPhone so I can only work with most basic Unix tools.

Wei Shi
  • 4,945
  • 8
  • 49
  • 73

1 Answers1

52
printf '\xa1' | dd of=somefile bs=1 seek=$((0xdeadbeef)) conv=notrunc
noraj
  • 3,964
  • 1
  • 30
  • 38
C. K. Young
  • 219,335
  • 46
  • 382
  • 435
  • This doesn't work on my machine. `somefile` end up truncated after the modified byte. – gromain Jun 15 '17 at 11:45
  • 1
    However, it works when `conv=notrunc` is at the end of the command. `printf '\xa1' | dd of=somefile bs=1 seek=$((0xdeadbeef)) conv=notrunc` – gromain Jun 15 '17 at 11:58