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
ebf1afc4
Commit
ebf1afc4
authored
Jan 09, 2014
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed hexdiff output formatting
parent
283b1ee2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
7 deletions
+20
-7
hexdiff.py
src/binwalk/modules/hexdiff.py
+20
-7
No files found.
src/binwalk/modules/hexdiff.py
View file @
ebf1afc4
...
...
@@ -19,6 +19,9 @@ class HexDiff(Module):
SEPERATORS
=
[
'
\\
'
,
'/'
]
DEFAULT_BLOCK_SIZE
=
16
SKIPPED_LINE
=
"*"
CUSTOM_DISPLAY_FORMAT
=
"0x
%.8
X
%
s"
TITLE
=
"Binary Diffing"
CLI
=
[
...
...
@@ -52,8 +55,8 @@ class HexDiff(Module):
Kwarg
(
name
=
'enabled'
,
default
=
False
),
]
RESULT_FORMAT
=
"
0x
%.8
X
%
s
\n
"
RESULT
=
[
'
offset'
,
'description
'
]
RESULT_FORMAT
=
"
%
s
\n
"
RESULT
=
[
'
display
'
]
def
_no_colorize
(
self
,
c
,
color
=
"red"
,
bold
=
True
):
return
c
...
...
@@ -113,13 +116,15 @@ class HexDiff(Module):
return
(
hexbyte
,
asciibyte
)
def
diff_files
(
self
,
target_files
):
last_line
=
None
loop_count
=
0
sep_count
=
0
while
True
:
line
=
""
done_files
=
0
block_data
=
{}
seperator
=
self
.
SEPERATORS
[
loo
p_count
%
2
]
seperator
=
self
.
SEPERATORS
[
se
p_count
%
2
]
for
fp
in
target_files
:
block_data
[
fp
]
=
fp
.
read
(
self
.
block
)
...
...
@@ -152,7 +157,18 @@ class HexDiff(Module):
if
fp
!=
target_files
[
-
1
]:
line
+=
"
%
s "
%
seperator
self
.
result
(
offset
=
(
fp
.
offset
+
(
self
.
block
*
loop_count
)),
description
=
line
)
offset
=
fp
.
offset
+
(
self
.
block
*
loop_count
)
if
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
:
self
.
result
(
offset
=
offset
,
description
=
line
,
display
=
display
)
last_line
=
line
loop_count
+=
1
def
init
(
self
):
...
...
@@ -191,9 +207,6 @@ class HexDiff(Module):
else
:
self
.
colorize
=
self
.
_no_colorize
def
validate
(
self
,
result
):
result
.
valid
=
self
.
_color_filter
(
result
.
description
)
def
run
(
self
):
if
self
.
hex_target_files
:
self
.
header
()
...
...
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