示例#1
0
 def generate_dead_code_stats_report(self):
     stats = {"DEAD": 0, "ALIVE": 0, "SPURIOUS": 0, "UNKNOWN": 0}
     to_color = {
         "DEAD": RED,
         "ALIVE": GREEN,
         "SPURIOUS": ORANGE,
         "UNKNOWN": BLACK
     }
     for cfg in self.functions_cfg.values():
         for bb in cfg.values():
             if bb.is_dead():
                 stats["DEAD"] += bb.size()
             elif bb.is_unknown():
                 stats["UNKNOWN"] += bb.size()
             elif bb.is_alive():
                 for i, st in bb.instrs_status.items():
                     if st == Status.ALIVE:
                         stats["ALIVE"] += 1
                     elif st == Status.DEAD:
                         stats["SPURIOUS"] += 1
                     else:
                         stats["UNKNOWN"] += 1
     self.report.add_title('Stats Dead Code', size=3)
     self.report.add_table_header(["type", "number", "percentage"])
     total = sum(stats.values())
     for st, nb in stats.items():
         avg = float(nb * 100) / (total if total != 0 else 1)
         self.report.add_table_line([
             make_cell(st, color=to_color[st]),
             make_cell(str(nb)),
             make_cell("%d%c" % (avg, '%'))
         ])
     self.report.end_table()
示例#2
0
 def analysis_terminated(self):
     self.result_widget.action_selector.setEnabled(True)
     self.result_widget.action_button.setEnabled(True)
     report = HTMLReport()
     report.add_title("Opaque predicates results k=" +
                      (str(self.results.k)),
                      size=3)
     report.add_table_header(
         ['address', "status", "nb path(tested)", "alive branch"])
     for addr in sorted(self.results.keys()):
         infos = self.results[addr]
         addr = make_cell("%x" % addr)
         status, color = to_status_name(infos.status), status_to_color(
             infos.status)
         status = make_cell(status, bold=True, color=color)
         alive_br = to_alive_branch(infos.status, infos.alive_branch)
         report.add_table_line([
             addr, status,
             make_cell(str(infos.nb_paths)),
             make_cell(alive_br)
         ])
         #TODO: Compute the number of possible paths for each predicate
     report.end_table()
     data = report.generate()
     self.result_widget.webview.setHtml(data)
示例#3
0
 def generate_opaqueness_stats_report(self):
     self.report.add_title('Stats opaqueness', size=3)
     self.report.add_table_header(["type", "number", "percentage"])
     total = len(self.results)
     for state in [self.po.OPAQUE, self.po.NOT_OPAQUE, self.po.UNKNOWN]:
         nb = len([x for x in self.results.values() if x.status == state])
         avg = float(nb * 100) / (total if total != 0 else 1)
         state_cell = make_cell(to_status_name(state),
                                bold=True,
                                color=status_to_color(state))
         self.report.add_table_line([
             state_cell,
             make_cell(str(nb)),
             make_cell("%d%c" % (avg, '%'))
         ])
     self.report.end_table()
示例#4
0
 def analysis_terminated(self):
     self.result_widget.action_selector.setEnabled(True)
     self.result_widget.action_button.setEnabled(True)
     report = HTMLReport()
     report.add_title("Call stack results", size=2)
     report.add_table_header([
         'address', "status", "hit count", "labels", "return addresses",
         "calls"
     ])
     for ret in self.results:
         addr = make_cell("%x" % ret.addr)
         status = make_cell(ret.get_status(),
                            bold=ret.is_tampering(),
                            color=RED if ret.is_tampering() else GREEN)
         labels_s = make_cell(''.join(
             ["[%s]" % x for x in ret.get_labels()]))
         return_s = make_cell(''.join(["%x," % x
                                       for x in ret.returnsites])[:-1])
         call_s = make_cell(''.join([
             "%x:%s<br/>" % (x[0], to_status_name(x[1])) for x in ret.calls
         ])[:-5])
         report.add_table_line([
             addr, status,
             make_cell(str(ret.solve_count)), labels_s, return_s, call_s
         ])
     report.end_table()
     data = report.generate()
     self.result_widget.webview.setHtml(data)
示例#5
0
 def generate_opaqueness_details_report(self):
     for rtn_addr, candidates in self.functions_candidates.items():
         self.report.add_title('%s' % idc.GetFunctionName(rtn_addr), size=3)
         self.report.add_table_header([
             'address', "status", "K", "predicate", "distance",
             "dead branch"
         ])
         for addr in sorted(candidates):
             res = self.results[addr]
             status, color = to_status_name(res.status), status_to_color(
                 res.status)
             status = make_cell(status, bold=True, color=color)
             dead_br_cell = make_cell(
                 "/" if res.dead_branch is None else "%x" % res.dead_branch)
             self.report.add_table_line([
                 make_cell("%x" % addr), status,
                 make_cell(str(res.k)),
                 make_cell(res.predicate),
                 make_cell(str(res.distance)), dead_br_cell
             ])
         self.report.end_table()