Files
ghidra-plugins/removeint3.py

34 lines
715 B
Python

# Replaces all INT3 instructions in the selection by NOPs
#@author AlxCzl
#@category Instructions
#@keybinding
#@menupath
#@toolbar
def main():
"""Main"""
if not currentSelection:
print("[!] Please select the range to be patched")
return
print('[*] Patching instructions...')
addrRange = currentSelection.getAddressRanges().next()
currAddr = addrRange.minAddress
count = 0
while currAddr < addrRange.maxAddress:
currVal = getByte(currAddr)
if currVal == 0xcc - 256:
count += 1
setByte(currAddr, 0x90)
currAddr = currAddr.add(1)
print('[*] Removed {} int3.'.format(count))
if __name__ == '__main__':
main()