Skip to content

Instantly share code, notes, and snippets.

@captainGeech42
Last active May 21, 2022 07:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save captainGeech42/944abbd5752d879a1869b66d0748c328 to your computer and use it in GitHub Desktop.
Save captainGeech42/944abbd5752d879a1869b66d0748c328 to your computer and use it in GitHub Desktop.
Patch out common annoying functions in CTF binaries
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