Skip to content

Commit

Permalink
Remove highlighting before saving db and restore after to avoid havin…
Browse files Browse the repository at this point in the history
…g stale highlighting
  • Loading branch information
Jonas Zaddach committed Jul 20, 2017
1 parent 305d953 commit 5adb8ce
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions plugin/casc_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
print("[CASCPlugin] Error loading dependencies for Sigalyzer: {}".format(str(err)))
sigalyzer_required_modules_loaded = False

COLOR_RED = 0x2020c0
SIGALYZER_COLOR_HIGHLIGHTED = 0x4dd811

# Global Variables
#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -2157,7 +2157,7 @@ def __get_array(self, index):
# Sigalyzer Widget
#-------------------------------------------------------------------------------

class SigalyzerWidget(QtWidgets.QWidget):
class SigalyzerWidget(QtWidgets.QWidget, idaapi.UI_Hooks):
def __init__(self):
super(QtWidgets.QWidget, self).__init__()
self.previous_colors = []
Expand All @@ -2168,6 +2168,7 @@ def __init__(self):
for idx in sorted(self.netnode.keys()):
sig = self.netnode[idx]
self._add_signature(sig)
self.hook()

def PopulateWidget(self):
signatures_widget = QtWidgets.QFrame()
Expand Down Expand Up @@ -2278,7 +2279,7 @@ def subsignature_selected(self, item):
for ea in Heads(match["ea"], match["ea"] + len(match["data"])):
print_console("Coloring ea 0x%x" % ea)
self.previous_colors.append((ea, GetColor(ea, CIC_ITEM)))
SetColor(ea, CIC_ITEM, COLOR_RED)
SetColor(ea, CIC_ITEM, SIGALIYZER_COLOR_HIGHLIGHTED)
except IndexError:
log.exception("While selecting subsignature")

Expand All @@ -2294,8 +2295,15 @@ def yara_match(self, strings):
for ea in Heads(strings[0]["ea"], strings[0]["ea"] + len(strings[0]["data"])):
print_console("Coloring ea 0x%x" % ea)
self.previous_colors.append((ea, GetColor(ea, CIC_ITEM)))
SetColor(ea, CIC_ITEM, COLOR_RED)

SetColor(ea, CIC_ITEM, SIGALYZER_COLOR_HIGHLIGHTED)

def saving(self):
for ea, color in self.previous_colors:
SetColor(ea, CIC_ITEM, color)

def saved(self):
for ea, color in self.previous_colors:
SetColor(ea, CIC_ITEM, SIGALYZER_COLOR_HIGHLIGHTED)

# Main Plug-in Form Class
#-------------------------------------------------------------------------------
Expand Down

0 comments on commit 5adb8ce

Please sign in to comment.