segment.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:idascripts 作者: ctfhacker 项目源码 文件源码
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

## searching
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号