Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
binwalk
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-gitdep
binwalk
Commits
5b359c62
Commit
5b359c62
authored
Oct 16, 2018
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a tilde in the hexdiff output to show when the previous displayed line repeats.
parent
f31a06c9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
+15
-2
hexdiff.py
src/binwalk/modules/hexdiff.py
+15
-2
No files found.
src/binwalk/modules/hexdiff.py
View file @
5b359c62
...
...
@@ -17,6 +17,7 @@ class HexDiff(Module):
DEFAULT_BLOCK_SIZE
=
16
SKIPPED_LINE
=
"*"
SAME_DIFFERENCE
=
"~"
CUSTOM_DISPLAY_FORMAT
=
"0x
%.8
X
%
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment