Skip to content

Instantly share code, notes, and snippets.

@notareverser
Last active January 5, 2023 15:11
Show Gist options
  • Save notareverser/1fbb0fb575159dffa34785a1dd2222a7 to your computer and use it in GitHub Desktop.
Save notareverser/1fbb0fb575159dffa34785a1dd2222a7 to your computer and use it in GitHub Desktop.
IDA Python script to NOP (x86/x64) selected bytes
import idaapi as ia, idc
def PLUGIN_ENTRY(): return nop()
class nop(ia.plugin_t):
flags = ia.PLUGIN_UNL
comment = "NOP"
help = "select bytes, run"
wanted_name = "NOP bytes..."
wanted_hotkey = "Ctrl+Shift+N"
def init(self): return ia.PLUGIN_OK
def term(self): pass
def run(self, arg):
no = 0x90
ib = idc.BADADDR
pb = idc.patch_byte
s1 = idc.read_selection_start()
e1 = idc.read_selection_end()
if s1 == ib or e1 == ib: pb(idc.here(), no)
else:
for x in range((e1-s1)):
pb(s1+x, no)
idc.create_insn(s1+x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment