Ejemplo n.º 1
0
 def segm_added(self, s):
     self._send_event(SegmAddedEvent(idaapi.get_segm_name(s),
                                     idaapi.get_segm_class(s),
                                     s.start_ea, s.end_ea,
                                     s.orgbase, s.align, s.comb,
                                     s.perm, s.bitness, s.flags))
     return 0
Ejemplo n.º 2
0
    def list_segments(self):
        """ Return the list of segments in the current binary and their characteristics """
        
        self.segments = list()
        self.segments_idx = list()


        for n in xrange(get_segm_qty()):
            seg = getnseg(n)

            if not seg: 
                continue

            # For some linux binaries
            # Ida does not recognize the segment
            # permissions (usually for plt)
            if seg.perm == 0:
                continue

            segentry = SegmentEntry(
                name = idaapi.get_segm_name(seg),
                start = seg.startEA,
                end = seg.endEA,
                size = seg.size(),
                r = (seg.perm & idaapi.SEGPERM_READ) >> 2,
                w = (seg.perm & idaapi.SEGPERM_WRITE) >> 1,
                x = (seg.perm & idaapi.SEGPERM_EXEC),
                segclass = idaapi.get_segm_class(seg)
            )

            self.segments.append(segentry) 
            self.segments_idx.append(n)

        return self.segments
Ejemplo n.º 3
0
    def __init__(self, seg):

        self.content = None

        self.segclass = idaapi.get_segm_class(seg)
        self.name = idaapi.get_segm_name(seg)

        self.content = function.functions_node(seg.startEA, seg.endEA)
Ejemplo n.º 4
0
    def __init__(self, seg):

        self.content = None

        self.segclass = idaapi.get_segm_class(seg)
        self.name = idaapi.get_segm_name(seg)

        self.content = function.functions_node(seg.startEA, seg.endEA)
Ejemplo n.º 5
0
def code_segments_iter():
    """Iterates over the possible code sections within an input binary."""
    for i in range(idaapi.get_segm_qty()):
        seg = idaapi.getnseg(i)

        if not seg: continue
        seg_class = idaapi.get_segm_class(seg)

        if seg_class != "CODE": continue
        seg_name = idaapi.get_segm_name(seg.startEA)

        yield seg.startEA, seg.endEA, seg_name
Ejemplo n.º 6
0
def code_segments_iter():
    """Iterates over the possible code sections within an input binary."""
    for i in range(idaapi.get_segm_qty()):
        seg = idaapi.getnseg(i)

        if not seg: continue
        seg_class = idaapi.get_segm_class(seg)

        if seg_class != "CODE": continue
        seg_name = idaapi.get_segm_name(seg.startEA)

        yield seg.startEA, seg.endEA, seg_name
Ejemplo n.º 7
0
def segms_by_class(cls):
    """
	Get list of segments (sections) in the binary image, filtering based on
	the segment's class.

	@return: List of segment start addresses.
	"""
    cls = norm(cls)
    for n in xrange(idaapi.get_segm_qty()):
        seg = idaapi.getnseg(n)
        if seg and not seg.empty():
            segcls = norm(idaapi.get_segm_class(seg))
            if segcls == cls:
                yield seg
Ejemplo n.º 8
0
 def enum_segm(self):
     i = 0
     for ea in idautils.Segments():
         seg = idaapi.getseg(ea)
         SigmName = idc.SegName(ea)
         startA = idc.SegStart(ea)
         endA = idc.SegEnd(ea)
         className = idaapi.get_segm_class(seg)
         seg_radio = SegmRadio(SigmName, startA, endA, className)
         self.segm.append((SigmName, startA, endA, className))
         self.segm_vbox.addWidget(seg_radio)
         self.segm_vbox.addStretch(1)
         if i == 0:
             i = 1
             seg_radio.toggle()
     return self.segm_vbox
Ejemplo n.º 9
0
def getAllSegments():
    segs = list()
    si = SegmInfo()
    i = 0
    for ea in idautils.Segments():
        seg = idaapi.getseg(ea)
        si.m_name = idc.SegName(ea)
        si.m_startAddr = int(idc.SegStart(ea))
        si.m_endAddr = int(idc.SegEnd(ea))
        si.m_className = idaapi.get_segm_class(seg)
        segs.append(si)
        print "[%d]" % (i)
        print "Segment name: %s" % (si.m_name)
        print "Segment start address: 0x%08x" % (si.m_startAddr)
        print "Segment end address: 0x%08x" % (si.m_endAddr)
        print "Segment class name: %s" % (si.m_className)
        i += 1
    return segs
Ejemplo n.º 10
0
    def setupUI(self):
        ea = idc.ScreenEA()
        seg = idaapi.getseg(ea)
        SigmName = idc.SegName(ea)
        startA = idc.SegStart(ea)
        endA = idc.SegEnd(ea)
        className = idaapi.get_segm_class(seg)
        self.setWindowTitle("Jumper--%s %s %s" % (hex(ea - startA).upper(), SigmName, className))

        self.groupBox.setLayout(self.enum_segm())

        search_hbox = QHBoxLayout()
        search_hbox.addWidget(QLabel("search"))
        search_hbox.addWidget(self.search_edit)

        offset_hbox = QHBoxLayout()
        offset_hbox.addWidget(QLabel("offset"))
        offset_hbox.addWidget(self.off_edit)

        self.scroll = QScrollArea()
        self.scroll.setWidgetResizable(True)  # Set to make the inner widget resize with scroll area
        self.scroll.setWidget(self.groupBox)

        globle_vbox = QVBoxLayout(self)
        globle_vbox.addWidget(self.scroll)
        globle_vbox.addLayout(search_hbox)
        globle_vbox.addLayout(offset_hbox)

        btn_layout =  QHBoxLayout()
        jump = QPushButton("jump")
        jump.clicked.connect(self.jump_click)
        get_offset = QPushButton("offset")
        get_offset.clicked.connect(self.get_cur_offset)
        btn_layout.addWidget(jump)
        btn_layout.addWidget(get_offset)
        globle_vbox.addLayout(btn_layout)

        self.search_edit.textChanged.connect(self.search_changed)
Ejemplo n.º 11
0
 def class_(self):
     return idaapi.get_segm_class(self.segment_t)
Ejemplo n.º 12
0
def create_segment_node(seg):
    segclass = idaapi.get_segm_class(seg)
    if segclass == "CODE":
        return code_segment_node(seg)
    else:
        return verbatim_segment_node(seg)
Ejemplo n.º 13
0
 def class_(self):
     return idaapi.get_segm_class(self.segment_t)
Ejemplo n.º 14
0
def create_segment_node(seg):
    segclass = idaapi.get_segm_class(seg)
    if segclass == "CODE":
        return code_segment_node(seg)
    else:
        return verbatim_segment_node(seg)
Ejemplo n.º 15
0
 def get_class(self):
     seg = idaapi.getseg(self.addr)
     if not seg:
         return None
     return idaapi.get_segm_class()