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
55075e57
Commit
55075e57
authored
Jan 08, 2014
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed handling of module errors and invalid integer options
parent
bab7c0c3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
76 additions
and
57 deletions
+76
-57
INSTALL
INSTALL
+2
-3
common.py
src/binwalk/core/common.py
+2
-1
display.py
src/binwalk/core/display.py
+4
-1
module.py
src/binwalk/core/module.py
+30
-15
binwalk
src/binwalk/magic/binwalk
+0
-0
binwalk
src/scripts/binwalk
+38
-37
No files found.
INSTALL
View file @
55075e57
...
...
@@ -74,9 +74,8 @@ Most distros don't have pyqtgraph in their default repositories, so it's best to
MANUALLY INSTALLING EXTRACTION UTILITIES
-------------------------------------------
Binwalk can automatically invoke external extraction utilities to extract various types of files that it
may find during a scan. These utilities are optional, but recommended if you plan on using binwalk's
extraction features.
Binwalk can automatically invoke external extraction utilities to extract various types of files that it may find during
a scan. These utilities are optional, but recommended if you plan on using binwalk's extraction features.
Most utilities can be installed from your distro's repositories (package names may vary slightly based
on your particular distro):
...
...
src/binwalk/core/common.py
View file @
55075e57
# Common functions.
# Common functions used throughout various parts of binwalk code.
import
io
import
os
import
re
...
...
src/binwalk/core/display.py
View file @
55075e57
...
...
@@ -5,7 +5,10 @@ import binwalk.core.common
from
binwalk.core.compat
import
*
class
Display
(
object
):
'''
Class to handle display of output and writing to log files.
This class is instantiated for all modules implicitly and should not need to be invoked directly by most modules.
'''
SCREEN_WIDTH
=
0
HEADER_WIDTH
=
150
DEFAULT_FORMAT
=
"
%
s
\n
"
...
...
src/binwalk/core/module.py
View file @
55075e57
...
...
@@ -149,7 +149,7 @@ class Module(object):
attribute
=
'extractor'
),
]
# A list of
dependenci
es that can be filled in as needed by each individual module.
# A list of
binwalk.core.module.Dependency instanc
es that can be filled in as needed by each individual module.
DEPENDS
=
[]
# Format string for printing the header during a scan.
...
...
@@ -407,6 +407,11 @@ class Module(object):
sys
.
stderr
.
write
(
"
\n
"
+
e
.
module
+
" Error: "
+
e
.
description
+
"
\n\n
"
)
def
header
(
self
):
'''
Displays the scan header, as defined by self.HEADER and self.HEADER_FORMAT.
Returns None.
'''
self
.
config
.
display
.
format_strings
(
self
.
HEADER_FORMAT
,
self
.
RESULT_FORMAT
)
self
.
config
.
display
.
add_custom_header
(
self
.
VERBOSE_FORMAT
,
self
.
VERBOSE
)
...
...
@@ -416,6 +421,11 @@ class Module(object):
self
.
config
.
display
.
header
(
self
.
HEADER
,
file_name
=
self
.
current_target_file_name
)
def
footer
(
self
):
'''
Displays the scan footer.
Returns None.
'''
self
.
config
.
display
.
footer
()
def
main
(
self
,
parent
):
...
...
@@ -720,20 +730,25 @@ class Modules(object):
last_priority
[
name
]
=
module_option
.
priority
# Do this manually as argparse doesn't seem to be able to handle hexadecimal values
if
module_option
.
type
==
int
:
kwargs
[
name
]
=
int
(
value
,
0
)
elif
module_option
.
type
==
float
:
kwargs
[
name
]
=
float
(
value
)
elif
module_option
.
type
==
dict
:
if
not
has_key
(
kwargs
,
name
):
kwargs
[
name
]
=
{}
kwargs
[
name
][
len
(
kwargs
[
name
])]
=
value
elif
module_option
.
type
==
list
:
if
not
has_key
(
kwargs
,
name
):
kwargs
[
name
]
=
[]
kwargs
[
name
]
.
append
(
value
)
else
:
kwargs
[
name
]
=
value
try
:
if
module_option
.
type
==
int
:
kwargs
[
name
]
=
int
(
value
,
0
)
elif
module_option
.
type
==
float
:
kwargs
[
name
]
=
float
(
value
)
elif
module_option
.
type
==
dict
:
if
not
has_key
(
kwargs
,
name
):
kwargs
[
name
]
=
{}
kwargs
[
name
][
len
(
kwargs
[
name
])]
=
value
elif
module_option
.
type
==
list
:
if
not
has_key
(
kwargs
,
name
):
kwargs
[
name
]
=
[]
kwargs
[
name
]
.
append
(
value
)
else
:
kwargs
[
name
]
=
value
except
KeyboardInterrupt
as
e
:
raise
e
except
Exception
as
e
:
raise
ModuleException
(
"Invalid usage:
%
s"
%
str
(
e
))
return
kwargs
...
...
src/binwalk/magic/binwalk
View file @
55075e57
No preview for this file type
src/scripts/binwalk
View file @
55075e57
...
...
@@ -6,47 +6,48 @@ from threading import Thread
from
binwalk.core.compat
import
user_input
def
display_status
(
m
):
# Display the current scan progress when the enter key is pressed.
while
True
:
try
:
user_input
()
sys
.
stderr
.
write
(
"Progress:
%.2
f
%%
(
%
d /
%
d)
\n\n
"
%
(((
float
(
m
.
status
.
completed
)
/
float
(
m
.
status
.
total
))
*
100
),
m
.
status
.
completed
,
m
.
status
.
total
))
except
KeyboardInterrupt
as
e
:
raise
e
except
Exception
:
pass
# Display the current scan progress when the enter key is pressed.
while
True
:
try
:
user_input
()
sys
.
stderr
.
write
(
"Progress:
%.2
f
%%
(
%
d /
%
d)
\n\n
"
%
(((
float
(
m
.
status
.
completed
)
/
float
(
m
.
status
.
total
))
*
100
),
m
.
status
.
completed
,
m
.
status
.
total
))
except
KeyboardInterrupt
as
e
:
raise
e
except
Exception
:
pass
def
usage
(
modules
):
sys
.
stderr
.
write
(
modules
.
help
())
sys
.
exit
(
1
)
sys
.
stderr
.
write
(
modules
.
help
())
sys
.
exit
(
1
)
def
main
():
modules
=
binwalk
.
Modules
()
# Start the display_status function as a daemon thread.
t
=
Thread
(
target
=
display_status
,
args
=
(
modules
,))
t
.
setDaemon
(
True
)
t
.
start
()
try
:
if
len
(
sys
.
argv
)
==
1
:
usage
(
modules
)
elif
not
modules
.
execute
():
modules
.
execute
(
*
sys
.
argv
[
1
:],
signature
=
True
)
except
binwalk
.
ModuleException
as
e
:
sys
.
exit
(
1
)
modules
=
binwalk
.
Modules
()
# Start the display_status function as a daemon thread.
t
=
Thread
(
target
=
display_status
,
args
=
(
modules
,))
t
.
setDaemon
(
True
)
t
.
start
()
try
:
if
len
(
sys
.
argv
)
==
1
:
usage
(
modules
)
elif
not
modules
.
execute
():
modules
.
execute
(
*
sys
.
argv
[
1
:],
signature
=
True
)
except
binwalk
.
ModuleException
as
e
:
sys
.
stderr
.
write
(
str
(
e
)
+
'
\n
'
)
sys
.
exit
(
1
)
if
__name__
==
'__main__'
:
try
:
# Special options for profiling the code. For debug use only.
if
'--profile'
in
sys
.
argv
:
import
cProfile
sys
.
argv
.
pop
(
sys
.
argv
.
index
(
'--profile'
))
cProfile
.
run
(
'main()'
)
else
:
main
()
except
IOError
:
pass
except
KeyboardInterrupt
:
sys
.
stdout
.
write
(
"
\n
"
)
try
:
# Special options for profiling the code. For debug use only.
if
'--profile'
in
sys
.
argv
:
import
cProfile
sys
.
argv
.
pop
(
sys
.
argv
.
index
(
'--profile'
))
cProfile
.
run
(
'main()'
)
else
:
main
()
except
IOError
:
pass
except
KeyboardInterrupt
:
sys
.
stdout
.
write
(
"
\n
"
)
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