示例#1
0
    def export_bp_notice(self):
        if not self.dbg_dialect:
            rs_log("idb isn't synced yet, can't export bp")
            return

        mod = self.name.split('.')[0].strip()
        nbp = ida_dbg.get_bpt_qty()

        for i in range(nbp):
            ea = idc.get_bpt_ea(i)
            attrs = [idc.BPTATTR_TYPE, idc.BPTATTR_COND, idc.BPTATTR_FLAGS]
            btype, cond, flags = [idc.get_bpt_attr(ea, x) for x in attrs]

            if cond:
                rs_log("bp %d: conditional bp not supported" % i)
            else:
                if ((btype in [idc.BPT_EXEC, idc.BPT_SOFT])
                        and ((flags & idc.BPT_ENABLED) != 0)):

                    offset = ea - self.base
                    bp = self.dbg_dialect['hbp' if
                                          (btype == idc.BPT_EXEC) else 'bp']
                    cmd = "%s%s+0x%x" % (bp, mod, offset)
                    self.notice_broker("cmd", "\"cmd\":\"%s\"" % cmd)
                    rs_log("bp %d: %s" % (i, cmd))

        rs_log('export done')
示例#2
0
 def bp_backup(self, suffix=""):
     nbp = idc.get_bpt_qty()
     bps = []
     for i in range(nbp):
         bp = idc.get_bpt_ea(i)
         bps.append((bp - self.offset, idc.check_bpt(bp)))
     return DbgInfo.config_save(bps, "breakpoints" + suffix)
示例#3
0
 def bp_update(self):
     invalid = []
     for bp in range(idc.get_bpt_qty()):
         bpea = idc.get_bpt_ea(bp)
         offstr = idc.get_func_off_str(bpea)
         if not offstr:
             invalid.append(bpea)
             continue
         offstr = offstr.split("+")
         if len(offstr) == 1:
             self.userbp_add(bpea)
     if invalid:
         for bp in invalid:
             idc.del_bpt(bp)
         print("invalid bp:", str(invalid))
示例#4
0
 def bp_recover(self, remove=True, suffix=""):
     bplist = DbgInfo.config_load("breakpoints" + suffix, list)
     if not bplist:
         return False
     if remove:
         nbp = idc.get_bpt_qty()
         bps = []
         for i in range(nbp):
             bp = idc.get_bpt_ea(i)
             bps.append(bp)
         for bp in bps:
             idc.del_bpt(bp)
     for bp in bplist:
         ea = bp[0]
         addr = ea + self.offset
         idc.add_bpt(addr)
         idc.enable_bpt(addr, bp[1])
     return True
示例#5
0
    def export_bp_notice(self):
        if not self.dbg_dialect:
            rs_log("idb isn't synced yet, can't export bp")
            return

        is_windbg = (self.dbg_dialect == 'windbg')

        # Windbg supports relative address, ie. mod+0xCAFE
        # for non relative address the remote base address is needed
        if (not is_windbg) and (not self.base_remote):
            rs_log("idb isn't enabled, can't export bp")
            return

        mod = self.name.split('.')[0].strip()
        nbp = ida_dbg.get_bpt_qty()

        for i in range(nbp):
            ea = idc.get_bpt_ea(i)
            attrs = [idc.BPTATTR_TYPE, idc.BPTATTR_COND, idc.BPTATTR_FLAGS]
            btype, cond, flags = [idc.get_bpt_attr(ea, x) for x in attrs]

            if cond:
                rs_log("bp %d: conditional bp not supported" % i)
            else:
                if ((btype in [idc.BPT_EXEC, idc.BPT_SOFT])
                        and ((flags & idc.BPT_ENABLED) != 0)):

                    bp = self.dbg_dialect['hbp' if
                                          (btype == idc.BPT_EXEC) else 'bp']

                    if is_windbg:
                        offset = ea - self.base
                        cmd = "%s%s+0x%x" % (bp, mod, offset)
                    else:
                        offset = self.rebase_remote(ea)
                        cmd = "%s0x%x" % (bp, offset)

                    self.notice_broker("cmd", "\"cmd\":\"%s\"" % cmd)
                    rs_log("bp %d: %s" % (i, cmd))

        rs_log('export done')
示例#6
0
def get_bpt_ea(i):
    if idaapi.IDA_SDK_VERSION <= 699:
        bpt_ea = idc.GetBptEA(i)
    else:
        bpt_ea = idc.get_bpt_ea(i)
    return bpt_ea