Esempio n. 1
0
def list(**type):
    """List all the segments defined in the database.

    Search type can be identified by providing a named argument.
    like = glob match
    regex = regular expression
    selector = segment selector
    index = particular index
    name = specific segment name
    predicate = function predicate
    """
    res = __builtin__.list(iterate(**type))

    maxindex = max(__builtin__.map(operator.attrgetter('index'), res) or [1])
    maxaddr = max(__builtin__.map(operator.attrgetter('endEA'), res) or [1])
    maxsize = max(__builtin__.map(operator.methodcaller('size'), res) or [1])
    maxname = max(__builtin__.map(utils.compose(idaapi.get_true_segm_name,len), res) or [1])
    cindex = math.ceil(math.log(maxindex)/math.log(10))
    caddr = math.ceil(math.log(maxaddr)/math.log(16))
    csize = math.ceil(math.log(maxsize)/math.log(16))

    for seg in res:
        comment = idaapi.get_segment_cmt(seg, 0) or idaapi.get_segment_cmt(seg, 1)
        print("[{:{:d}d}] {:0{:d}x}:{:0{:d}x} {:>{:d}s} {:<+#{:d}x} sel:{:04x} flags:{:02x}{:s}".format(seg.index, int(cindex), seg.startEA, int(caddr), seg.endEA, int(caddr), idaapi.get_true_segm_name(seg), maxname, seg.size(), int(csize), seg.sel, seg.flags, "// {:s}".format(comment) if comment else ''))
    return
Esempio n. 2
0
def list(**type):
    '''List all of the segments in the database that match the keyword specified by `type`.'''
    res = builtins.list(__iterate__(**type))

    maxindex = max(builtins.map(operator.attrgetter('index'), res) or [1])
    maxaddr = max(builtins.map(operator.attrgetter('endEA'), res) or [1])
    maxsize = max(builtins.map(operator.methodcaller('size'), res) or [1])
    maxname = max(
        builtins.map(utils.fcompose(idaapi.get_true_segm_name, len), res)
        or [1])
    cindex = math.ceil(math.log(maxindex or 1) / math.log(10))
    caddr = math.ceil(math.log(maxaddr or 1) / math.log(16))
    csize = math.ceil(math.log(maxsize or 1) / math.log(16))

    for seg in res:
        comment = idaapi.get_segment_cmt(seg, 0) or idaapi.get_segment_cmt(
            seg, 1)
        six.print_(
            u"[{:{:d}d}] {:#0{:d}x}<>{:#0{:d}x} : {:<+#{:d}x} : {:>{:d}s} : sel:{:04x} flags:{:02x}{:s}"
            .format(
                seg.index, int(cindex), seg.startEA, 2 + int(caddr), seg.endEA,
                2 + int(caddr), seg.size(), 3 + int(csize),
                utils.string.of(idaapi.get_true_segm_name(seg)),
                maxname, seg.sel, seg.flags, u"// {:s}".format(
                    utils.string.of(comment)) if comment else ''))
    return
Esempio n. 3
0
def list(**type):
    '''List all of the segments in the database that match the keyword specified by `type`.'''
    res = builtins.list(__iterate__(**type))

    maxindex = max(builtins.map(operator.attrgetter('index'), res) or [1])
    maxaddr = max(builtins.map(operator.attrgetter('endEA'), res) or [1])
    maxsize = max(builtins.map(operator.methodcaller('size'), res) or [1])
    maxname = max(builtins.map(utils.fcompose(idaapi.get_true_segm_name,len), res) or [1])
    cindex = math.ceil(math.log(maxindex or 1)/math.log(10))
    caddr = math.ceil(math.log(maxaddr or 1)/math.log(16))
    csize = math.ceil(math.log(maxsize or 1)/math.log(16))

    for seg in res:
        comment = idaapi.get_segment_cmt(seg, 0) or idaapi.get_segment_cmt(seg, 1)
        six.print_(u"[{:{:d}d}] {:#0{:d}x}<>{:#0{:d}x} : {:<+#{:d}x} : {:>{:d}s} : sel:{:04x} flags:{:02x}{:s}".format(seg.index, int(cindex), seg.startEA, 2+int(caddr), seg.endEA, 2+int(caddr), seg.size(), 3+int(csize), utils.string.of(idaapi.get_true_segm_name(seg)), maxname, seg.sel, seg.flags, u"// {:s}".format(utils.string.of(comment)) if comment else ''))
    return
Esempio n. 4
0
def list(**type):
    '''List all of the segments in the database that match the keyword specified by `type`.'''
    get_segment_name = idaapi.get_segm_name if hasattr(
        idaapi, 'get_segm_name') else idaapi.get_true_segm_name

    listable = []

    # Set some reasonable defaults
    maxindex = maxaddr = maxsize = maxname = 0

    # First pass through our segments to grab lengths of displayed fields
    for seg in __iterate__(**type):
        maxindex = max(seg.index, maxindex)
        maxaddr = max(interface.range.end(seg), maxaddr)
        maxsize = max(seg.size(), maxsize)
        maxname = max(len(get_segment_name(seg)), maxname)

        listable.append(seg)

    # Collect the maximum sizes for everything from the first pass. We have
    # to use different algorithms as due to Python's issues with imprecision,
    # the resulting number of digits will vary depending on what base is
    # actually being used when calculating the logarithm.
    cindex = utils.string.digits(maxindex, 10)
    caddr, csize = (utils.string.digits(item, 10)
                    for item in [maxaddr, maxsize])

    # List all the fields for each segment that we've aggregated
    for seg in listable:
        comment, _ = idaapi.get_segment_cmt(seg, 0) or idaapi.get_segment_cmt(
            seg, 1), ui.navigation.set(interface.range.start(seg))
        six.print_(
            u"[{:{:d}d}] {:#0{:d}x}<>{:#0{:d}x} : {:<+#{:d}x} : {:>{:d}s} : sel:{:04x} flags:{:02x}{:s}"
            .format(
                seg.index, math.trunc(cindex),
                interface.range.start(seg), 2 + math.trunc(caddr),
                interface.range.end(seg), 2 + math.trunc(caddr), seg.size(),
                3 + math.trunc(csize), utils.string.of(get_segment_name(seg)),
                maxname, seg.sel, seg.flags, u"// {:s}".format(
                    utils.string.of(comment)) if comment else ''))
    return
Esempio n. 5
0
def list(**type):
    '''List all of the segments in the database that match the keyword specified by `type`.'''
    get_segment_name = idaapi.get_segm_name if hasattr(
        idaapi, 'get_segm_name') else idaapi.get_true_segm_name

    listable = []

    # Set some reasonable defaults
    maxindex = maxaddr = maxsize = maxname = 0

    # First pass through our segments to grab lengths of displayed fields
    for seg in __iterate__(**type):
        maxindex = max(seg.index, maxindex)
        maxaddr = max(interface.range.end(seg), maxaddr)
        maxsize = max(seg.size(), maxsize)
        maxname = max(len(get_segment_name(seg)), maxname)

        listable.append(seg)

    # Collect the maximum sizes for everything from the first pass
    Fdigits = lambda number, base: math.floor(1. + math.log(number or 1) / math
                                              .log(base))
    cindex = Fdigits(maxindex, 10)
    caddr, csize = (Fdigits(item, 16) for item in [maxaddr, maxsize])

    # List all the fields for each segment that we've aggregated
    for seg in listable:
        comment, _ = idaapi.get_segment_cmt(seg, 0) or idaapi.get_segment_cmt(
            seg, 1), ui.navigation.set(interface.range.start(seg))
        six.print_(
            u"[{:{:d}d}] {:#0{:d}x}<>{:#0{:d}x} : {:<+#{:d}x} : {:>{:d}s} : sel:{:04x} flags:{:02x}{:s}"
            .format(
                seg.index, math.trunc(cindex),
                interface.range.start(seg), 2 + math.trunc(caddr),
                interface.range.end(seg), 2 + math.trunc(caddr), seg.size(),
                3 + math.trunc(csize), utils.string.of(get_segment_name(seg)),
                maxname, seg.sel, seg.flags, u"// {:s}".format(
                    utils.string.of(comment)) if comment else ''))
    return
Esempio n. 6
0
 def repeat(self):
     return idaapi.get_segment_cmt(self._segment, True)
Esempio n. 7
0
 def regular(self):
     return idaapi.get_segment_cmt(self._segment, False)
Esempio n. 8
0
 def repeat(self):
     return idaapi.get_segment_cmt(self._segment, True)
Esempio n. 9
0
 def regular(self):
     return idaapi.get_segment_cmt(self._segment, False)