Skip to content

Instantly share code, notes, and snippets.

@yarjor
Last active September 24, 2018 15:04
Show Gist options
  • Select an option

  • Save yarjor/1fed3d65f8d73c6742a95d0bd6219b9c to your computer and use it in GitHub Desktop.

Select an option

Save yarjor/1fed3d65f8d73c6742a95d0bd6219b9c to your computer and use it in GitHub Desktop.
[Hook endbr instructions for angr] #angr #r2pipe #ibtprotect #patch #r2 #radare2
import angr
import r2pipe
ENDBR64 = 'f30f1efa'
ENDBR32 = 'f30f1efb'
def endbr(state):
print "Hooked 'endbr' instruction"
p = angr.Project('./simple')
r2 = r2pipe.open('./simple', ['-B0x400000']) # flag needed to load the binary to same address as angr
endbr_locations = r2.cmdj('/xj {}'.format(ENDBR32)) + r2.cmdj('/xj {}'.format(ENDBR64))
for loc in endbr_locations:
p.hook(loc['offset'], endbr, length=4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment