def get_string(self, start_address, end_address) -> list: result = [] current_start = start_address while current_start < end_address: if ida_nalt.get_str_type(current_start) < 4294967295: result.append( ida_bytes.get_strlit_contents( current_start, -1, ida_nalt.get_str_type(current_start)).decode()) # https://github.com/idapython/src/blob/master/python/idautils.py#L202 current_start = ida_bytes.next_head(current_start, ida_ida.cvar.inf.max_ea) return result
def get_string(self, start_address, end_address) -> list: result = [] start = int(start_address, 16) end = int(end_address, 16) while start <= end: # https://github.com/idapython/src/blob/master/python/idautils.py#L202 next_start = ida_bytes.next_head(start, ida_ida.cvar.inf.max_ea) if ida_nalt.get_str_type(start) < 4294967295: result.append( ida_bytes.get_strlit_contents( start, -1, ida_nalt.get_str_type(start)).decode()) start = next_start return result
def CompileTextFromFunction(f,sep): s="" faddr = list(idautils.FuncItems(f)) for c in range(len(faddr)): for d in idautils.DataRefsFrom(faddr[c]): t = ida_nalt.get_str_type(d) if ((t==0) or (t==3)): s += " "+ sep + " " + idc.GetStrLitContents(d) return s
def CompileTextFromRange(start,end,sep): x = start s = "" while (x<=end): faddr = list(idautils.FuncItems(x)) #print "items list: %d" % len(faddr) for c in range(len(faddr)): for d in idautils.DataRefsFrom(faddr[c]): #print "Found ref at %x: %x " % (faddr[c],d) t = ida_nalt.get_str_type(d) if ((t==0) or (t==3)): s += " " + sep + " " + GetStrLitContents(d) x = NextFunction(x) return s
def enum_string_refs_in_function(fva): ''' yield the string references in the given function. Args: fva (int): the starting address of a function Returns: sequence[tuple[int, int, str]]: tuples of metadata, including: - the address of the instruction referencing a string - the address of the string - the string ''' for ea in enum_function_addrs(fva): for ref in idautils.DataRefsFrom(ea): stype = ida_nalt.get_str_type(ref) if stype < 0 or stype > 7: continue CALC_MAX_LEN = -1 s = str(ida_bytes.get_strlit_contents(ref, CALC_MAX_LEN, stype)) yield ea, ref, s
def get_str_literal(addr): type = ida_nalt.get_str_type(addr) length = ida_bytes.get_max_strlit_length(addr, type, ida_bytes.ALOPT_IGNHEADS) return ida_bytes.get_strlit_contents(addr, length, type).decode('ascii')