Edit (patch) a binary file in IDA Pro
Asked Answered
E

6

22

i would like to know how to edit a binary file in ida pro (i just need to change one instruction!)

(its ARM binary)

thanks

Employment answered 9/6, 2009 at 12:54 Comment(0)
F
12
  1. select the instruction you need to change in "IDA View" subview. enter image description here

  2. switch to "Hex View" subview. You will see several highlighting hex numbers. enter image description here

  3. press "F2", edit it, when you finish, press "F2" again. enter image description here

  4. That's all. you will see your change in other subviews. enter image description here

Fruitarian answered 11/12, 2018 at 3:7 Comment(3)
In the nearly decade since I asked this question, the answer appears to have changed! Would it therefore be possible to quote the current working version number of IDA Pro this relates to in your answer? Thanks!Employment
In my experience, IDA 6.6 works fine. And so does following products. I met this problem,too. I hope it can help others if they see this problem.Fruitarian
The second F2 is for "apply changes". To actually change file on disk, select "Apply patches to input file".Anthemion
W
23

Possibly edit:

idagui.cfg: DISPLAY_PATCH_SUBMENU = YES

If the menu is not enabled, then use

Edit/Patch code/Change Byte

Wrens answered 15/9, 2009 at 8:40 Comment(1)
this doesn't change it in the actual binary thoSelden
F
12
  1. select the instruction you need to change in "IDA View" subview. enter image description here

  2. switch to "Hex View" subview. You will see several highlighting hex numbers. enter image description here

  3. press "F2", edit it, when you finish, press "F2" again. enter image description here

  4. That's all. you will see your change in other subviews. enter image description here

Fruitarian answered 11/12, 2018 at 3:7 Comment(3)
In the nearly decade since I asked this question, the answer appears to have changed! Would it therefore be possible to quote the current working version number of IDA Pro this relates to in your answer? Thanks!Employment
In my experience, IDA 6.6 works fine. And so does following products. I met this problem,too. I hope it can help others if they see this problem.Fruitarian
The second F2 is for "apply changes". To actually change file on disk, select "Apply patches to input file".Anthemion
C
9

IDA 6.2 has the "Edit" -> "Patch program" menu enabled out of the box. No need to modify idagui.cfg. There is also an "Apply patches to input file" option that that will modify the target file.

Concoff answered 22/11, 2011 at 0:34 Comment(0)
L
8

I think IDA used to have a feature to do that, but it's not present in the current versions.

You should just use a hex editor. Note the file offset in IDA and edit the file at that address. If you'd like to see the changes in IDA, use the "File" -> "Load file" -> "Reload the input file" menu item.

Lupelupee answered 9/6, 2009 at 13:0 Comment(1)
this is the best method i've found too, unfortunateSelden
N
5

Here is how i did

Edit > Patch Program > Assemble 

After Assembling/patching instruction click on Apply Patches to Binary

done :)

assemble

Nickienicklaus answered 9/1, 2021 at 15:3 Comment(2)
I did something similar. Since this is a lot easier than the older answers, is this a new approach in newer versions? I am using IDA Free 7.6.Hegemony
Unless I'm doing something wrong (???), this doesn't seem to always work. Sometimes, I Assemble an instruction, it changes in IDA and I see it on the Hex View, but when I try to Apply the patch, on HxD I don't see the change (if I modify directly in Hex View as VictorV says though, it works). I've just patched a 2-byte instruction to 2 NOPs and it worked. Patched the NOPs to RET and it worked. Patched the RETs to NOPs again, and only one worked. The other byte remained C3 instead of 90 (x86). [IDA Pro 7.6 SP1 here.] Might stick to the Hex View way until they fix this.Pistoleer
M
1

First do as Lundman suggested, then choose File / Produce / DIF file.

Then apply the diff file using an external tool

Mckamey answered 6/8, 2010 at 14:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.