Python idaapi.get_segm_qty() Examples
The following are 8
code examples of idaapi.get_segm_qty().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
idaapi
, or try the search function
.
Example #1
Source File: idautils.py From dumpDex with Apache License 2.0 | 5 votes |
def Segments(): """ Get list of segments (sections) in the binary image @return: List of segment start addresses. """ for n in xrange(idaapi.get_segm_qty()): seg = idaapi.getnseg(n) if seg: yield seg.startEA
Example #2
Source File: get_vuln_functions_list.py From slid with MIT License | 5 votes |
def get_functions_ida(): #Repeat for list of segments for n in xrange(idaapi.get_segm_qty()): #Get number of segments seg = idaapi.getnseg(n) if seg: #Get list of functions in that segment funcs=idautils.Functions(seg.startEA, seg.endEA) for funcname in funcs: name = GetFunctionName(funcname) print name #Wait for analysis to complete
Example #3
Source File: rename_funcs.py From slid with MIT License | 5 votes |
def rename_functions_ida(): #Repeat for list of segments for n in xrange(idaapi.get_segm_qty()): #Get number of segments seg = idaapi.getnseg(n) if seg: #Get list of functions in that segment funcs=idautils.Functions(seg.startEA, seg.endEA) for funcaddress in funcs: name=GetFunctionName(funcaddress) if name in functions_in_library: MakeNameEx(funcaddress,"glibc_"+name,SN_NOWARN) #Wait for analysis to complete
Example #4
Source File: rename_similar_funcs.py From slid with MIT License | 5 votes |
def rename_functions_ida(func_library_map): print func_library_map.keys() #Repeat for list of segments for n in xrange(idaapi.get_segm_qty()): #Get number of segments seg = idaapi.getnseg(n) if seg: #Get list of functions in that segment funcs=idautils.Functions(seg.startEA, seg.endEA) for funcaddress in funcs: name=GetFunctionName(funcaddress) if func_library_map.has_key(name): MakeNameEx(funcaddress,func_library_map[name][1:]+"_"+name,SN_NOWARN) #Wait for analysis to complete
Example #5
Source File: segment.py From Sark with MIT License | 5 votes |
def segments(seg_type=None): """Iterate segments based on type Args: seg_type: type of segment e.g. SEG_CODE Returns: iterator of `Segment` objects. if seg_type is None , returns all segments otherwise returns only the relevant ones """ for index in range(idaapi.get_segm_qty()): seg = Segment(index=index) if (seg_type is None) or (seg.type == seg_type): yield Segment(index=index)
Example #6
Source File: OL_OSX_decryptor.py From malware-research with BSD 2-Clause "Simplified" License | 5 votes |
def search_binary(binary_string): for i in range(idaapi.get_segm_qty()): segm = idaapi.getnseg(i) current_ea = segm.startEA while True: current_ea = idaapi.find_binary(current_ea + 1, segm.endEA, binary_string, 16, idaapi.SEARCH_DOWN) if current_ea == idaapi.BADADDR: break return current_ea return 0
Example #7
Source File: segment.py From ida-minsc with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __iterate__(**type): '''Iterate through each segment defined in the database that match the keywords specified by `type`.''' def newsegment(index): seg = idaapi.getnseg(index) seg.index, _ = index, ui.navigation.set(interface.range.start(seg)) return seg iterable = itertools.imap(newsegment, six.moves.range(idaapi.get_segm_qty())) for key, value in six.iteritems(type or builtins.dict(predicate=utils.fconstant(True))): iterable = builtins.list(__matcher__.match(key, value, iterable)) for item in iterable: yield item
Example #8
Source File: memory_reader.py From ida-images with MIT License | 4 votes |
def get_padded_bytes(self, size): result = "\x00" * size ranges_left = [MemoryRange(self.address, self.address + size)] segment_count = idaapi.get_segm_qty() valid_memory_ranges = [] for i in range(segment_count): segment = idaapi.getnseg(i) # Skip segments with unstable data if segment.type == idaapi.SEG_XTRN: continue valid_memory_ranges.append( MemoryRange(segment.startEA, segment.endEA) ) while len(ranges_left) > 0: # Get a requested memory range and remove it from the list current_range = ranges_left.pop() intersection = None for memory_range in valid_memory_ranges: start = max(current_range.start, memory_range.start) end = min(current_range.end, memory_range.end) if end > start: intersection = MemoryRange(start, end) break # No segment can satisfy any part of requested range if intersection is None: continue chunk = idc.GetManyBytes( intersection.start, intersection.end - intersection.start ) if chunk is None: print( "[librgb] Some bytes are unreadable in %s..%s" % ( idc.atoa(intersection.start), idc.atoa(intersection.end), ) ) continue result = ( result[0 : intersection.start - self.address] + chunk + result[intersection.end - self.address :] ) assert len(result) == size # If necessary, enqueue ranges unsatisfied by chosen mem segment range1 = MemoryRange(current_range.start, intersection.start) range2 = MemoryRange(intersection.end, current_range.end) if range1.length > 0: ranges_left.append(range1) if range2.length > 0: ranges_left.append(range2) assert len(result) == size return result