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
d19ff934
Commit
d19ff934
authored
Dec 22, 2013
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added verbose output to preceed scans.
parent
6161bcf6
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
7 deletions
+57
-7
setup.py
setup.py
+4
-1
display.py
src/binwalk/core/display.py
+34
-3
module.py
src/binwalk/core/module.py
+13
-2
signature.py
src/binwalk/modules/signature.py
+4
-0
zlibvalid.py
src/binwalk/plugins/zlibvalid.py
+2
-1
No files found.
setup.py
View file @
d19ff934
...
@@ -30,9 +30,12 @@ def cleanup_module_directory():
...
@@ -30,9 +30,12 @@ def cleanup_module_directory():
remove_tree
(
path
+
os
.
path
.
sep
+
"*"
)
remove_tree
(
path
+
os
.
path
.
sep
+
"*"
)
except
OSError
as
e
:
except
OSError
as
e
:
pass
pass
except
ImportError
:
except
KeyboardInterrupt
as
e
:
raise
e
except
Exception
:
pass
pass
# Change to the binwalk src directory
# Change to the binwalk src directory
def
warning
(
lines
,
terminate
=
True
,
prompt
=
True
):
def
warning
(
lines
,
terminate
=
True
,
prompt
=
True
):
WIDTH
=
115
WIDTH
=
115
...
...
src/binwalk/core/display.py
View file @
d19ff934
import
sys
import
sys
import
csv
as
pycsv
import
csv
as
pycsv
import
datetime
import
binwalk.core.common
from
binwalk.core.compat
import
*
class
Display
(
object
):
class
Display
(
object
):
...
@@ -15,6 +18,8 @@ class Display(object):
...
@@ -15,6 +18,8 @@ class Display(object):
self
.
fp
=
None
self
.
fp
=
None
self
.
csv
=
None
self
.
csv
=
None
self
.
num_columns
=
0
self
.
num_columns
=
0
self
.
custom_verbose_format
=
""
self
.
custom_verbose_args
=
[]
self
.
_configure_formatting
()
self
.
_configure_formatting
()
...
@@ -37,8 +42,33 @@ class Display(object):
...
@@ -37,8 +42,33 @@ class Display(object):
else
:
else
:
self
.
fp
.
write
(
fmt
%
tuple
(
columns
))
self
.
fp
.
write
(
fmt
%
tuple
(
columns
))
def
header
(
self
,
*
args
):
def
add_custom_header
(
self
,
fmt
,
args
):
self
.
custom_verbose_format
=
fmt
self
.
custom_verbose_args
=
args
def
header
(
self
,
*
args
,
**
kwargs
):
file_name
=
None
self
.
num_columns
=
len
(
args
)
self
.
num_columns
=
len
(
args
)
if
has_key
(
kwargs
,
'file_name'
):
file_name
=
kwargs
[
'file_name'
]
if
self
.
verbose
and
file_name
:
md5sum
=
binwalk
.
core
.
common
.
file_md5
(
file_name
)
timestamp
=
datetime
.
datetime
.
now
()
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
if
self
.
csv
:
self
.
log
(
""
,
[
"FILE"
,
"MD5SUM"
,
"TIMESTAMP"
])
self
.
log
(
""
,
[
file_name
,
md5sum
,
timestamp
])
self
.
_fprint
(
"
%
s"
,
"
\n
"
,
csv
=
False
)
self
.
_fprint
(
"Scan Time:
%
s
\n
"
,
[
timestamp
],
csv
=
False
)
self
.
_fprint
(
"Target File:
%
s
\n
"
,
[
file_name
],
csv
=
False
)
self
.
_fprint
(
"MD5 Checksum:
%
s
\n
"
,
[
md5sum
],
csv
=
False
)
if
self
.
custom_verbose_format
and
self
.
custom_verbose_args
:
#self._pprint("Signatures: %d\n" % self.binwalk.parser.signature_count, nolog=nolog)
self
.
_fprint
(
self
.
custom_verbose_format
,
self
.
custom_verbose_args
,
csv
=
False
)
self
.
_fprint
(
"
%
s"
,
"
\n
"
,
csv
=
False
)
self
.
_fprint
(
"
%
s"
,
"
\n
"
,
csv
=
False
)
self
.
_fprint
(
self
.
header_format
,
args
)
self
.
_fprint
(
self
.
header_format
,
args
)
self
.
_fprint
(
"
%
s"
,
[
"-"
*
self
.
HEADER_WIDTH
+
"
\n
"
],
csv
=
False
)
self
.
_fprint
(
"
%
s"
,
[
"-"
*
self
.
HEADER_WIDTH
+
"
\n
"
],
csv
=
False
)
...
@@ -59,10 +89,11 @@ class Display(object):
...
@@ -59,10 +89,11 @@ class Display(object):
def
footer
(
self
):
def
footer
(
self
):
self
.
_fprint
(
"
%
s"
,
"
\n
"
,
csv
=
False
)
self
.
_fprint
(
"
%
s"
,
"
\n
"
,
csv
=
False
)
def
_fprint
(
self
,
fmt
,
columns
,
csv
=
True
):
def
_fprint
(
self
,
fmt
,
columns
,
csv
=
True
,
stdout
=
True
):
if
not
self
.
quiet
:
line
=
fmt
%
tuple
(
columns
)
line
=
fmt
%
tuple
(
columns
)
if
filter
and
self
.
filter
.
valid_result
(
line
):
if
filter
and
self
.
filter
.
valid_result
(
line
):
if
not
self
.
quiet
and
stdout
:
sys
.
stdout
.
write
(
self
.
_format_line
(
line
.
strip
())
+
"
\n
"
)
sys
.
stdout
.
write
(
self
.
_format_line
(
line
.
strip
())
+
"
\n
"
)
if
self
.
fp
and
not
(
self
.
csv
and
not
csv
):
if
self
.
fp
and
not
(
self
.
csv
and
not
csv
):
...
...
src/binwalk/core/module.py
View file @
d19ff934
...
@@ -165,6 +165,9 @@ class Module(object):
...
@@ -165,6 +165,9 @@ class Module(object):
#RESULT = ['offset', 'description']
#RESULT = ['offset', 'description']
RESULT
=
[
"offset"
,
"offset"
,
"description"
]
RESULT
=
[
"offset"
,
"offset"
,
"description"
]
VERBOSE_HEADER_FORMAT
=
""
VERBOSE_HEADER_ARGS
=
[]
# If set to True, the progress status will be automatically updated for each result
# If set to True, the progress status will be automatically updated for each result
# containing a valid file attribute.
# containing a valid file attribute.
AUTO_UPDATE_STATUS
=
True
AUTO_UPDATE_STATUS
=
True
...
@@ -184,6 +187,7 @@ class Module(object):
...
@@ -184,6 +187,7 @@ class Module(object):
self
.
target_file_list
=
[]
self
.
target_file_list
=
[]
self
.
status
=
None
self
.
status
=
None
self
.
enabled
=
False
self
.
enabled
=
False
self
.
current_target_file_name
=
None
self
.
name
=
self
.
__class__
.
__name__
self
.
name
=
self
.
__class__
.
__name__
self
.
plugins
=
binwalk
.
core
.
plugin
.
Plugins
(
self
)
self
.
plugins
=
binwalk
.
core
.
plugin
.
Plugins
(
self
)
...
@@ -304,6 +308,11 @@ class Module(object):
...
@@ -304,6 +308,11 @@ class Module(object):
self
.
status
.
clear
()
self
.
status
.
clear
()
self
.
status
.
total
=
fp
.
length
self
.
status
.
total
=
fp
.
length
if
fp
is
not
None
:
self
.
current_target_file_name
=
fp
.
name
else
:
self
.
current_target_file_name
=
None
return
fp
return
fp
def
clear
(
self
,
results
=
True
,
errors
=
True
):
def
clear
(
self
,
results
=
True
,
errors
=
True
):
...
@@ -382,10 +391,12 @@ class Module(object):
...
@@ -382,10 +391,12 @@ class Module(object):
def
header
(
self
):
def
header
(
self
):
self
.
config
.
display
.
format_strings
(
self
.
HEADER_FORMAT
,
self
.
RESULT_FORMAT
)
self
.
config
.
display
.
format_strings
(
self
.
HEADER_FORMAT
,
self
.
RESULT_FORMAT
)
self
.
config
.
display
.
add_custom_header
(
self
.
VERBOSE_HEADER_FORMAT
,
self
.
VERBOSE_HEADER_ARGS
)
if
type
(
self
.
HEADER
)
==
type
([]):
if
type
(
self
.
HEADER
)
==
type
([]):
self
.
config
.
display
.
header
(
*
self
.
HEADER
)
self
.
config
.
display
.
header
(
*
self
.
HEADER
,
file_name
=
self
.
current_target_file_name
)
elif
self
.
HEADER
:
elif
self
.
HEADER
:
self
.
config
.
display
.
header
(
self
.
HEADER
)
self
.
config
.
display
.
header
(
self
.
HEADER
,
file_name
=
self
.
current_target_file_name
)
def
footer
(
self
):
def
footer
(
self
):
self
.
config
.
display
.
footer
()
self
.
config
.
display
.
footer
()
...
...
src/binwalk/modules/signature.py
View file @
d19ff934
...
@@ -45,6 +45,8 @@ class Signature(Module):
...
@@ -45,6 +45,8 @@ class Signature(Module):
MAGIC_FLAGS
=
magic
.
MAGIC_NO_CHECK_TEXT
|
magic
.
MAGIC_NO_CHECK_ENCODING
|
magic
.
MAGIC_NO_CHECK_APPTYPE
|
magic
.
MAGIC_NO_CHECK_TOKENS
MAGIC_FLAGS
=
magic
.
MAGIC_NO_CHECK_TEXT
|
magic
.
MAGIC_NO_CHECK_ENCODING
|
magic
.
MAGIC_NO_CHECK_APPTYPE
|
magic
.
MAGIC_NO_CHECK_TOKENS
VERBOSE_HEADER_FORMAT
=
"
%
s
%
d"
def
init
(
self
):
def
init
(
self
):
# Create SmartSignature and MagicParser class instances. These are mostly for internal use.
# Create SmartSignature and MagicParser class instances. These are mostly for internal use.
self
.
smart
=
binwalk
.
core
.
smart
.
SmartSignature
(
self
.
config
.
filter
,
ignore_smart_signatures
=
self
.
dumb_scan
)
self
.
smart
=
binwalk
.
core
.
smart
.
SmartSignature
(
self
.
config
.
filter
,
ignore_smart_signatures
=
self
.
dumb_scan
)
...
@@ -76,6 +78,8 @@ class Signature(Module):
...
@@ -76,6 +78,8 @@ class Signature(Module):
# Once the temporary magic files are loaded into libmagic, we don't need them anymore; delete the temp files
# Once the temporary magic files are loaded into libmagic, we don't need them anymore; delete the temp files
self
.
parser
.
rm_magic_files
()
self
.
parser
.
rm_magic_files
()
self
.
VERBOSE_HEADER_ARGS
=
[
"Signatures:"
,
self
.
parser
.
signature_count
]
def
validate
(
self
,
r
):
def
validate
(
self
,
r
):
'''
'''
Called automatically by self.result.
Called automatically by self.result.
...
...
src/binwalk/plugins/zlibvalid.py
View file @
d19ff934
...
@@ -23,7 +23,8 @@ class Plugin(object):
...
@@ -23,7 +23,8 @@ class Plugin(object):
# If this result is a zlib signature match, try to decompress the data
# If this result is a zlib signature match, try to decompress the data
if
self
.
tinfl
and
result
.
file
and
result
.
description
.
lower
()
.
startswith
(
'zlib'
):
if
self
.
tinfl
and
result
.
file
and
result
.
description
.
lower
()
.
startswith
(
'zlib'
):
# Seek to and read the suspected zlib data
# Seek to and read the suspected zlib data
fd
=
BlockFile
(
result
.
file
.
name
,
offset
=
result
.
offset
,
swap
=
self
.
module
.
config
.
swap_size
)
fd
=
self
.
module
.
config
.
open_file
(
result
.
file
.
name
,
offset
=
result
.
offset
)
#BlockFile(result.file.name, offset=result.offset, swap=self.module.config.swap_size)
data
=
fd
.
read
(
self
.
MAX_DATA_SIZE
)
data
=
fd
.
read
(
self
.
MAX_DATA_SIZE
)
fd
.
close
()
fd
.
close
()
...
...
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