[docs]classStaticHooker(Analysis):""" This analysis works on statically linked binaries - it finds the library functions statically linked into the binary and hooks them with the appropriate simprocedures. Right now it only works on unstripped binaries, but hey! There's room to grow! """
[docs]def__init__(self,library,binary=None):self.results={}try:lib=SIM_LIBRARIES[library]exceptKeyError:raiseAngrValueError("No such library %s"%library)ifbinaryisNone:binary=self.project.loader.main_objectforfuncinbinary.symbols:ifnotfunc.is_function:continueifself.project.is_hooked(func.rebased_addr):l.debug("Skipping %s at %#x, already hooked",func.name,func.rebased_addr)continueiflib.has_implementation(func.name):proc=lib.get(func.name,self.project.arch)self.results[func.rebased_addr]=procifself.project.is_hooked(func.rebased_addr):l.debug("Skipping %s at %#x, already hooked",func.name,func.rebased_addr)else:self.project.hook(func.rebased_addr,proc)l.info("Hooked %s at %#x",func.name,func.rebased_addr)else:l.debug("Failed to hook %s at %#x",func.name,func.rebased_addr)