Files
ghidra-plugins/XorRange.py

33 lines
736 B
Python

# XORs the instructions in the current selection
#@author AlxCzl
#@category Instructions
#@keybinding
#@menupath
#@toolbar
def main():
"""Main"""
if not currentSelection:
print("[!] Please select the range to be xored")
return
xorVal = askInt("xor value", "[*] Value to XOR the instructions with: ")
print('[*] XORing byte range with {}...'.format(xorVal))
addrRange = currentSelection.getAddressRanges().next()
currAddr = addrRange.minAddress
while currAddr < addrRange.maxAddress:
currVal = getByte(currAddr)
newVal = currVal ^ xorVal
setByte(currAddr, newVal)
currAddr = currAddr.add(1)
print('[*] Done.')
if __name__ == '__main__':
main()