Commit 5b359c62 by devttys0

Added a tilde in the hexdiff output to show when the previous displayed line repeats.

parent f31a06c9
......@@ -17,6 +17,7 @@ class HexDiff(Module):
DEFAULT_BLOCK_SIZE = 16
SKIPPED_LINE = "*"
SAME_DIFFERENCE = "~"
CUSTOM_DISPLAY_FORMAT = "0x%.8X %s"
TITLE = "Binary Diffing"
......@@ -113,6 +114,7 @@ class HexDiff(Module):
return (hexbyte, asciibyte)
def diff_files(self, target_files):
last_raw_line = None
last_line = None
loop_count = 0
sep_count = 0
......@@ -126,6 +128,7 @@ class HexDiff(Module):
while True:
line = ""
current_raw_line = ""
done_files = 0
block_data = {}
seperator = self.SEPERATORS[sep_count % 2]
......@@ -159,20 +162,30 @@ class HexDiff(Module):
break
if fp != target_files[-1]:
# Need to keep a copy of the line data without the seperator, since the sep changes
# every other line. This allows us to compare one raw line to a previous raw line to
# see if they are the same.
current_raw_line += line
line += " %s " % seperator
offset = fp.offset + (self.block * loop_count)
if not self._color_filter(line):
if current_raw_line == last_raw_line:
display = line = self.SAME_DIFFERENCE
elif not self._color_filter(line):
display = line = self.SKIPPED_LINE
else:
display = self.CUSTOM_DISPLAY_FORMAT % (offset, line)
sep_count += 1
if line != self.SKIPPED_LINE or last_line != line:
if (line not in [self.SKIPPED_LINE, self.SAME_DIFFERENCE] or
(last_line != line and
(last_line not in [self.SKIPPED_LINE, self.SAME_DIFFERENCE] or
line not in [self.SKIPPED_LINE, self.SAME_DIFFERENCE]))):
self.result(offset=offset, description=line, display=display)
last_line = line
last_raw_line = current_raw_line
loop_count += 1
self.status.completed += self.block
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment