def getFunctionAddress(name): """ Looks for the function 'name' in the PLT of a binary Returns a pair (name, address) as (str, int) """ global binary_name global binary_ELF if (not Arch.currentIsELF()): return (None, None) # Get function in relocatins relasec_name = '.rela.plt' relasec = binary_ELF.get_section_by_name(relasec_name) if not isinstance(relasec, RelocationSection): print(' ERROR DEBUG The file has no %s section' % relasec_name) relasec_addr = relasec.header['sh_addr'] symbols = binary_ELF.get_section(relasec.header['sh_link']) if (not isinstance(symbols, NullSection)): for reloc in relasec.iter_relocations(): if (symbols.get_symbol(reloc['r_info_sym']).name == name): return (name, reloc['r_offset'] + relasec_addr) # Get function from symbol table sections for symsec in getSymbolSections(): function = symsec.get_symbol_by_name(name) if (function): return (name, function[0]['st_value']) return (None, None)
def initScanner(filename): global binary_name global binary_ELF binary_name = filename if (Arch.currentIsELF()): binary_ELF = ElfParser(binary_name) else: binary_ELF = None
def initScanner(filename): global binary_name global binary_ELF binary_name = filename f = open(binary_name, 'rb') if (Arch.currentIsELF()): binary_ELF = ELFFile(f) else: binary_ELF = None
def getFunctionAddress(name): """ Looks for the function 'name' in the PLT of a binary Returns a pair (name, address) as (str, int) """ global binary_name global binary_ELF if (not Arch.currentIsELF()): return (None, None) for rela in binary_ELF.jumpRelocationEntries: if (rela.symbol.symbolName == name): return (rela.symbol.symbolName, rela.r_offset) return (None, None)