Last active
September 24, 2018 15:04
-
-
Save yarjor/1fed3d65f8d73c6742a95d0bd6219b9c to your computer and use it in GitHub Desktop.
[Hook endbr instructions for angr] #angr #r2pipe #ibtprotect #patch #r2 #radare2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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