Last active
May 21, 2022 07:25
-
-
Save captainGeech42/944abbd5752d879a1869b66d0748c328 to your computer and use it in GitHub Desktop.
Patch out common annoying functions in CTF binaries
This file contains 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
IMPORTS_TO_PATCH = [ | |
"alarm", | |
"ptrace" | |
] | |
# iterate over imported symbols | |
for import_sym in bv.get_symbols_of_type(SymbolType.ImportedFunctionSymbol): | |
# check if symbol is in the patch list | |
if import_sym.name in IMPORTS_TO_PATCH: | |
log.log_info(f"patching out call to {import_sym.name}") | |
# iterate over caller xrefs | |
for xref in bv.get_callers(import_sym.address): | |
# nop out the call | |
bv.convert_to_nop(xref.address) | |
# add a comment | |
bv.set_comment_at(xref.address, f"nop'd call to {import_sym.name}()") | |
log.log_info(f"nop'd out call to {import_sym.name}() @ {hex(xref.address)}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment