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
9ff6aaa6
Commit
9ff6aaa6
authored
Jul 29, 2014
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed IDA offset/length bugs; added binwalk.execute function; updated example scripts
parent
4ca9b19d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
35 deletions
+62
-35
setup.py
setup.py
+1
-1
__init__.py
src/binwalk/__init__.py
+4
-1
common.py
src/binwalk/core/common.py
+43
-23
idb.py
src/binwalk/core/idb.py
+12
-8
binwalk_simple.py
src/scripts/examples/binwalk_simple.py
+1
-1
signature_scan.py
src/scripts/examples/signature_scan.py
+1
-1
No files found.
setup.py
View file @
9ff6aaa6
...
...
@@ -149,7 +149,7 @@ if os.getenv("BUILD_PYQTGRAPH") == "1":
# Install the module, script, and support files
setup
(
name
=
MODULE_NAME
,
version
=
"2.
0
.0"
,
version
=
"2.
1
.0"
,
description
=
"Firmware analysis tool"
,
author
=
"Craig Heffner"
,
url
=
"https://github.com/devttys0/
%
s"
%
MODULE_NAME
,
...
...
src/binwalk/__init__.py
View file @
9ff6aaa6
__all__
=
[
'Modules'
,
'ModuleException'
]
__all__
=
[
'
execute'
,
'
Modules'
,
'ModuleException'
]
import
sys
import
binwalk.core.common
...
...
@@ -8,3 +8,6 @@ import binwalk.core.common
sys
.
path
.
append
(
binwalk
.
core
.
common
.
get_libs_path
())
from
binwalk.core.module
import
Modules
,
ModuleException
def
execute
(
*
args
,
**
kwargs
):
return
Modules
(
*
args
,
**
kwargs
)
.
execute
()
src/binwalk/core/common.py
View file @
9ff6aaa6
...
...
@@ -176,6 +176,12 @@ def strings(filename, minimum=4):
else
:
result
=
""
class
GenericContainer
(
object
):
def
__init__
(
self
,
**
kwargs
):
for
(
k
,
v
)
in
iterator
(
kwargs
):
setattr
(
self
,
k
,
v
)
class
MathExpression
(
object
):
'''
Class for safely evaluating mathematical expressions from a string.
...
...
@@ -268,52 +274,66 @@ class BlockFile(BLOCK_FILE_PARENT_CLASS):
Returns None.
'''
self
.
total_read
=
0
self
.
swap_size
=
swap
self
.
block_read_size
=
self
.
DEFAULT_BLOCK_READ_SIZE
self
.
block_peek_size
=
self
.
DEFAULT_BLOCK_PEEK_SIZE
# This is so that custom parent classes can access/modify arguments as necessary
self
.
args
=
GenericContainer
(
fname
=
fname
,
mode
=
mode
,
length
=
length
,
offset
=
offset
,
block
=
block
,
peek
=
peek
,
swap
=
swap
,
size
=
0
)
# Python 2.6 doesn't like modes like 'rb' or 'wb'
mode
=
mode
.
replace
(
'b'
,
''
)
mode
=
self
.
args
.
mode
.
replace
(
'b'
,
''
)
try
:
self
.
size
=
file_size
(
fname
)
except
KeyboardInterrupt
as
e
:
raise
e
except
Exception
:
self
.
size
=
0
if
offset
<
0
:
self
.
offset
=
self
.
size
+
offset
super
(
self
.
__class__
,
self
)
.
__init__
(
fname
,
mode
)
self
.
swap_size
=
self
.
args
.
swap
if
self
.
args
.
size
:
self
.
size
=
self
.
args
.
size
else
:
self
.
offset
=
offset
try
:
self
.
size
=
file_size
(
self
.
args
.
fname
)
except
KeyboardInterrupt
as
e
:
raise
e
except
Exception
:
self
.
size
=
0
if
self
.
args
.
offset
<
0
:
self
.
offset
=
self
.
size
+
self
.
args
.
offset
else
:
self
.
offset
=
self
.
args
.
offset
if
self
.
offset
<
0
:
self
.
offset
=
0
elif
self
.
offset
>
self
.
size
:
self
.
offset
=
self
.
size
if
offset
<
0
:
self
.
length
=
offset
*
-
1
elif
length
:
self
.
length
=
length
if
self
.
args
.
offset
<
0
:
self
.
length
=
self
.
args
.
offset
*
-
1
elif
self
.
args
.
length
:
self
.
length
=
self
.
args
.
length
else
:
self
.
length
=
self
.
size
-
offset
self
.
length
=
self
.
size
-
self
.
args
.
offset
if
self
.
length
<
0
:
self
.
length
=
0
elif
self
.
length
>
self
.
size
:
self
.
length
=
self
.
size
if
block
is
not
None
:
self
.
block_read_size
=
block
if
self
.
args
.
block
is
not
None
:
self
.
block_read_size
=
self
.
args
.
block
self
.
base_block_size
=
self
.
block_read_size
if
peek
is
not
None
:
self
.
block_peek_size
=
peek
if
self
.
args
.
peek
is
not
None
:
self
.
block_peek_size
=
self
.
args
.
peek
self
.
base_peek_size
=
self
.
block_peek_size
super
(
self
.
__class__
,
self
)
.
__init__
(
fname
,
mode
)
# Work around for python 2.6 where FileIO._name is not defined
try
:
self
.
name
...
...
src/binwalk/core/idb.py
View file @
9ff6aaa6
...
...
@@ -51,18 +51,22 @@ class IDBFileIO(io.FileIO):
else
:
self
.
__idb__
=
True
self
.
name
=
fname
self
.
idb_start
=
0
self
.
idb_pos
=
0
self
.
idb_end
=
end_address
()
if
self
.
size
==
0
:
self
.
size
=
end_address
()
-
start_address
()
if
self
.
length
==
0
:
self
.
length
=
self
.
size
if
self
.
offset
==
0
:
self
.
offset
=
start_address
()
if
self
.
args
.
size
==
0
:
self
.
args
.
size
=
end_address
()
if
self
.
args
.
offset
==
0
:
self
.
args
.
offset
=
start_address
()
elif
self
.
args
.
offset
<
0
:
self
.
args
.
length
=
self
.
args
.
offset
*
-
1
self
.
args
.
offset
=
end_address
()
+
self
.
args
.
offset
if
self
.
args
.
length
==
0
or
self
.
args
.
length
>
(
end_address
()
-
start_address
()):
self
.
args
.
length
=
end_address
()
-
start_address
()
def
read
(
self
,
n
=-
1
):
if
not
self
.
__idb__
:
...
...
src/scripts/examples/binwalk_simple.py
View file @
9ff6aaa6
...
...
@@ -4,4 +4,4 @@ import binwalk
# Since no options are specified, they are by default taken from sys.argv.
# Effecitvely, this duplicates the functionality of the normal binwalk script.
binwalk
.
Modules
()
.
execute
()
binwalk
.
execute
()
src/scripts/examples/signature_scan.py
View file @
9ff6aaa6
...
...
@@ -5,7 +5,7 @@ import binwalk
try
:
# Perform a signature scan against the files specified on the command line and suppress the usual binwalk output.
for
module
in
binwalk
.
Modules
()
.
execute
(
*
sys
.
argv
[
1
:],
signature
=
True
,
quiet
=
True
):
for
module
in
binwalk
.
execute
(
*
sys
.
argv
[
1
:],
signature
=
True
,
quiet
=
True
):
print
(
"
%
s Results:"
%
module
.
name
)
for
result
in
module
.
results
:
print
(
"
\t
%
s 0x
%.8
X
%
s"
%
(
result
.
file
.
name
,
result
.
offset
,
result
.
description
))
...
...
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