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
d9423b66
Commit
d9423b66
authored
Jan 20, 2015
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed extractor bug with --swap enabled
parent
2384691e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
5 deletions
+29
-5
extractor.py
src/binwalk/modules/extractor.py
+14
-3
zlibextract.py
src/binwalk/plugins/zlibextract.py
+1
-0
zlibvalid.py
src/binwalk/plugins/zlibvalid.py
+14
-2
No files found.
src/binwalk/modules/extractor.py
View file @
d9423b66
...
...
@@ -532,8 +532,18 @@ class Extractor(Module):
fname
=
unique_file_name
(
bname
,
extension
)
try
:
# If byte swapping is enabled, we need to start reading at a swap-size
# aligned offset, then index in to the read data appropriately.
if
self
.
config
.
swap_size
:
adjust
=
offset
%
self
.
config
.
swap_size
else
:
adjust
=
0
offset
-=
adjust
# Open the target file and seek to the offset
fdin
=
self
.
config
.
open_file
(
file_name
,
length
=
size
,
offset
=
offset
)
fdin
=
self
.
config
.
open_file
(
file_name
)
fdin
.
seek
(
offset
)
# Open the output file
try
:
...
...
@@ -550,8 +560,9 @@ class Extractor(Module):
if
not
data
:
break
else
:
fdout
.
write
(
str2bytes
(
data
[:
dlen
]))
total_size
+=
dlen
fdout
.
write
(
str2bytes
(
data
[
adjust
:
dlen
]))
total_size
+=
(
dlen
-
adjust
)
adjust
=
0
# Cleanup
fdout
.
close
()
...
...
src/binwalk/plugins/zlibextract.py
View file @
d9423b66
...
...
@@ -37,3 +37,4 @@ class ZLIBExtractPlugin(binwalk.core.plugin.Plugin):
return
False
return
True
src/binwalk/plugins/zlibvalid.py
View file @
d9423b66
...
...
@@ -14,9 +14,20 @@ class ZlibValidPlugin(binwalk.core.plugin.Plugin):
def
scan
(
self
,
result
):
# If this result is a zlib signature match, try to decompress the data
if
result
.
file
and
result
.
description
.
lower
()
.
startswith
(
'zlib'
):
# If byte swapping is enabled, we need to start reading at a swap-size
# aligned offset, then index in to the read data appropriately.
if
self
.
module
.
config
.
swap_size
:
adjust
=
result
.
offset
%
self
.
module
.
config
.
swap_size
else
:
adjust
=
0
offset
=
result
.
offset
-
adjust
# Seek to and read the suspected zlib data
fd
=
self
.
module
.
config
.
open_file
(
result
.
file
.
name
,
offset
=
result
.
offset
,
length
=
self
.
MAX_DATA_SIZE
)
data
=
fd
.
read
(
self
.
MAX_DATA_SIZE
)
fd
=
self
.
module
.
config
.
open_file
(
result
.
file
.
name
)
fd
.
seek
(
offset
)
data
=
fd
.
read
(
self
.
MAX_DATA_SIZE
)[
adjust
:]
fd
.
close
()
# Check if this is valid zlib data. It is valid if:
...
...
@@ -29,3 +40,4 @@ class ZlibValidPlugin(binwalk.core.plugin.Plugin):
# Error -5, incomplete or truncated data input
if
not
str
(
e
)
.
startswith
(
"Error -5"
):
result
.
valid
=
False
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