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
c00c53ae
Commit
c00c53ae
authored
Sep 13, 2017
by
Craig Heffner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed the way --length works
parent
6286cc4c
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
22 additions
and
15 deletions
+22
-15
common.py
src/binwalk/core/common.py
+14
-6
magic.py
src/binwalk/core/magic.py
+2
-3
compression.py
src/binwalk/modules/compression.py
+1
-1
disasm.py
src/binwalk/modules/disasm.py
+1
-1
entropy.py
src/binwalk/modules/entropy.py
+1
-1
extractor.py
src/binwalk/modules/extractor.py
+1
-1
heuristics.py
src/binwalk/modules/heuristics.py
+1
-1
signature.py
src/binwalk/modules/signature.py
+1
-1
No files found.
src/binwalk/core/common.py
View file @
c00c53ae
...
...
@@ -50,6 +50,13 @@ def error(msg):
sys
.
stderr
.
write
(
"
\n
ERROR: "
+
msg
+
"
\n
"
)
def
critical
(
msg
):
'''
Prints critical messages to stderr
'''
sys
.
stderr
.
write
(
"
\n
CRITICAL: "
+
msg
+
"
\n
"
)
def
get_module_path
():
root
=
__file__
if
os
.
path
.
islink
(
root
):
...
...
@@ -176,7 +183,7 @@ def strings(filename, minimum=4):
with
BlockFile
(
filename
)
as
f
:
while
True
:
(
data
,
dlen
)
=
f
.
read_block
()
if
not
data
:
if
dlen
<
1
:
break
for
c
in
data
:
...
...
@@ -451,10 +458,10 @@ def BlockFile(fname, mode='r', subclass=io.FileIO, **kwargs):
return
n
def
read
(
self
,
n
=-
1
):
def
read
(
self
,
n
=-
1
,
override
=
False
):
''''
Reads up to n bytes of data (or to EOF if n is not specified).
Will not read more than self.length bytes.
Will not read more than self.length bytes
unless override == True
.
io.FileIO.read does not guaruntee that all requested data will be read;
this method overrides io.FileIO.read and does guaruntee that all data will be read.
...
...
@@ -464,9 +471,10 @@ def BlockFile(fname, mode='r', subclass=io.FileIO, **kwargs):
l
=
0
data
=
b
''
if
self
.
total_read
<
self
.
length
:
if
override
==
True
or
(
self
.
total_read
<
self
.
length
)
:
# Don't read more than self.length bytes from the file
if
(
self
.
total_read
+
n
)
>
self
.
length
:
# unless an override has been requested.
if
override
==
False
and
(
self
.
total_read
+
n
)
>
self
.
length
:
n
=
self
.
length
-
self
.
total_read
while
n
<
0
or
l
<
n
:
...
...
@@ -486,7 +494,7 @@ def BlockFile(fname, mode='r', subclass=io.FileIO, **kwargs):
Peeks at data in file.
'''
pos
=
self
.
tell
()
data
=
self
.
read
(
n
)
data
=
self
.
read
(
n
,
override
=
True
)
self
.
seek
(
pos
)
return
data
...
...
src/binwalk/core/magic.py
View file @
c00c53ae
...
...
@@ -814,9 +814,8 @@ class Magic(object):
# Signatures are ordered based on the length of their magic bytes (largest first).
# If this offset has already been matched to a previous signature, ignore it unless
# self.show_invalid has been specified. Also ignore obviously invalid offsets (<1)
# as well as those outside the specified self.data range
# (dlen).
# self.show_invalid has been specified. Also ignore obviously invalid offsets (<0)
# as well as those outside the specified self.data range (dlen).
if
(
offset
not
in
matched_offsets
or
self
.
show_invalid
)
and
offset
>=
0
and
offset
<
dlen
:
# if offset >= 0 and offset < dlen:
# Analyze the data at this offset using the current
...
...
src/binwalk/modules/compression.py
View file @
c00c53ae
...
...
@@ -270,7 +270,7 @@ class RawCompression(Module):
while
not
file_done
:
(
data
,
dlen
)
=
fp
.
read_block
()
if
not
data
:
if
dlen
<
1
:
break
for
i
in
range
(
0
,
dlen
):
...
...
src/binwalk/modules/disasm.py
View file @
c00c53ae
...
...
@@ -109,7 +109,7 @@ class Disasm(Module):
result
=
None
(
data
,
dlen
)
=
fp
.
read_block
()
if
not
data
:
if
dlen
<
1
:
break
# If this data block doesn't contain at least two different bytes, skip it
...
...
src/binwalk/modules/entropy.py
View file @
c00c53ae
...
...
@@ -173,7 +173,7 @@ class Entropy(Module):
file_offset
=
fp
.
tell
()
(
data
,
dlen
)
=
fp
.
read_block
()
if
not
data
:
if
dlen
<
1
:
break
i
=
0
...
...
src/binwalk/modules/extractor.py
View file @
c00c53ae
...
...
@@ -782,7 +782,7 @@ class Extractor(Module):
while
total_size
<
size
:
(
data
,
dlen
)
=
fdin
.
read_block
()
if
not
data
:
if
dlen
<
1
:
break
else
:
total_size
+=
(
dlen
-
adjust
)
...
...
src/binwalk/modules/heuristics.py
View file @
c00c53ae
...
...
@@ -177,7 +177,7 @@ class HeuristicCompressionAnalyzer(Module):
while
i
<
block
.
length
:
j
=
0
(
d
,
dlen
)
=
fp
.
read_block
()
if
not
d
:
if
dlen
<
1
:
break
while
j
<
dlen
:
...
...
src/binwalk/modules/signature.py
View file @
c00c53ae
...
...
@@ -138,7 +138,7 @@ class Signature(Module):
while
True
:
(
data
,
dlen
)
=
fp
.
read_block
()
if
not
data
:
if
dlen
<
1
:
break
current_block_offset
=
0
...
...
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