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-depend
binwalk
Commits
464cb3b0
Commit
464cb3b0
authored
Dec 21, 2013
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added binwalk_simple example
parent
39c081fb
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
21 deletions
+40
-21
module.py
src/binwalk/core/module.py
+30
-20
configuration.py
src/binwalk/modules/configuration.py
+1
-0
entropy.py
src/binwalk/modules/entropy.py
+2
-1
extractor.py
src/binwalk/modules/extractor.py
+1
-0
signature.py
src/binwalk/modules/signature.py
+1
-0
binwalk_simple.py
src/scripts/examples/binwalk_simple.py
+5
-0
No files found.
src/binwalk/core/module.py
View file @
464cb3b0
...
@@ -14,7 +14,7 @@ class Option(object):
...
@@ -14,7 +14,7 @@ class Option(object):
A container class that allows modules to declare command line options.
A container class that allows modules to declare command line options.
'''
'''
def
__init__
(
self
,
kwargs
=
{},
priority
=
0
,
description
=
""
,
short
=
""
,
long
=
""
,
type
=
None
,
dtype
=
""
):
def
__init__
(
self
,
kwargs
=
{},
priority
=
0
,
description
=
""
,
short
=
""
,
long
=
""
,
type
=
None
,
dtype
=
None
):
'''
'''
Class constructor.
Class constructor.
...
@@ -34,9 +34,9 @@ class Option(object):
...
@@ -34,9 +34,9 @@ class Option(object):
self
.
short
=
short
self
.
short
=
short
self
.
long
=
long
self
.
long
=
long
self
.
type
=
type
self
.
type
=
type
self
.
dtype
=
str
(
dtype
)
self
.
dtype
=
dtype
if
not
self
.
dtype
:
if
not
self
.
dtype
and
self
.
type
:
if
self
.
type
in
[
io
.
FileIO
,
argparse
.
FileType
,
binwalk
.
core
.
common
.
BlockFile
]:
if
self
.
type
in
[
io
.
FileIO
,
argparse
.
FileType
,
binwalk
.
core
.
common
.
BlockFile
]:
self
.
dtype
=
'file'
self
.
dtype
=
'file'
elif
self
.
type
in
[
int
,
float
,
str
]:
elif
self
.
type
in
[
int
,
float
,
str
]:
...
@@ -155,6 +155,9 @@ class Module(object):
...
@@ -155,6 +155,9 @@ class Module(object):
# Modules with higher priorities are executed first
# Modules with higher priorities are executed first
PRIORITY
=
5
PRIORITY
=
5
# Modules with a higher order are displayed first in help output
ORDER
=
5
def
__init__
(
self
,
dependency
=
False
,
**
kwargs
):
def
__init__
(
self
,
dependency
=
False
,
**
kwargs
):
self
.
errors
=
[]
self
.
errors
=
[]
self
.
results
=
[]
self
.
results
=
[]
...
@@ -469,28 +472,34 @@ class Modules(object):
...
@@ -469,28 +472,34 @@ class Modules(object):
return
sorted
(
modules
,
key
=
modules
.
get
,
reverse
=
True
)
return
sorted
(
modules
,
key
=
modules
.
get
,
reverse
=
True
)
def
help
(
self
):
def
help
(
self
):
modules
=
{}
help_string
=
"
\n
Binwalk v
%
s
\n
Craig Heffner, http://www.binwalk.org
\n
"
%
binwalk
.
core
.
settings
.
Settings
.
VERSION
help_string
=
"
\n
Binwalk v
%
s
\n
Craig Heffner, http://www.binwalk.org
\n
"
%
binwalk
.
core
.
settings
.
Settings
.
VERSION
for
obj
in
self
.
list
(
attribute
=
"CLI"
):
# Build a dictionary of modules and their ORDER attributes.
if
obj
.
CLI
:
# This makes it easy to sort modules by their ORDER attribute for display.
help_string
+=
"
\n
%
s Options:
\n
"
%
obj
.
TITLE
for
module
in
self
.
list
(
attribute
=
"CLI"
):
if
module
.
CLI
:
modules
[
module
]
=
module
.
ORDER
for
module_option
in
obj
.
CLI
:
for
module
in
sorted
(
modules
,
key
=
modules
.
get
,
reverse
=
True
):
if
module_option
.
long
:
help_string
+=
"
\n
%
s Options:
\n
"
%
module
.
TITLE
long_opt
=
'--'
+
module_option
.
long
for
module_option
in
module
.
CLI
:
if
module_option
.
long
:
long_opt
=
'--'
+
module_option
.
long
if
module_option
.
type
is
not
Non
e
:
if
module_option
.
dtyp
e
:
optargs
=
"=<
%
s>"
%
module_option
.
dtype
optargs
=
"=<
%
s>"
%
module_option
.
dtype
else
:
else
:
optargs
=
""
optargs
=
""
if
module_option
.
short
:
if
module_option
.
short
:
short_opt
=
"-"
+
module_option
.
short
+
","
short_opt
=
"-"
+
module_option
.
short
+
","
else
:
else
:
short_opt
=
" "
short_opt
=
" "
fmt
=
"
%%
s
%%
s
%%-%
ds
%%
s
\n
"
%
(
32
-
len
(
long_opt
))
fmt
=
"
%%
s
%%
s
%%-%
ds
%%
s
\n
"
%
(
32
-
len
(
long_opt
))
help_string
+=
fmt
%
(
short_opt
,
long_opt
,
optargs
,
module_option
.
description
)
help_string
+=
fmt
%
(
short_opt
,
long_opt
,
optargs
,
module_option
.
description
)
return
help_string
+
"
\n
"
return
help_string
+
"
\n
"
...
@@ -553,7 +562,8 @@ class Modules(object):
...
@@ -553,7 +562,8 @@ class Modules(object):
if
not
has_key
(
self
.
loaded_modules
,
dependency
):
if
not
has_key
(
self
.
loaded_modules
,
dependency
):
# self.run will automatically add the dependency class instance to self.loaded_modules
# self.run will automatically add the dependency class instance to self.loaded_modules
self
.
run
(
dependency
)
self
.
run
(
dependency
)
# If a dependency failed, consider this a non-recoverable error and raise an exception
if
self
.
loaded_modules
[
dependency
]
.
errors
:
if
self
.
loaded_modules
[
dependency
]
.
errors
:
raise
ModuleException
(
"Failed to load "
+
str
(
dependency
))
raise
ModuleException
(
"Failed to load "
+
str
(
dependency
))
else
:
else
:
...
...
src/binwalk/modules/configuration.py
View file @
464cb3b0
...
@@ -11,6 +11,7 @@ from binwalk.core.module import Module, Option, Kwarg, show_help
...
@@ -11,6 +11,7 @@ from binwalk.core.module import Module, Option, Kwarg, show_help
class
Configuration
(
Module
):
class
Configuration
(
Module
):
TITLE
=
"General"
TITLE
=
"General"
ORDER
=
0
DEPENDS
=
{}
DEPENDS
=
{}
...
...
src/binwalk/modules/entropy.py
View file @
464cb3b0
...
@@ -18,7 +18,8 @@ class Entropy(Module):
...
@@ -18,7 +18,8 @@ class Entropy(Module):
COLORS
=
[
'r'
,
'g'
,
'c'
,
'b'
,
'm'
]
COLORS
=
[
'r'
,
'g'
,
'c'
,
'b'
,
'm'
]
TITLE
=
"Entropy"
TITLE
=
"Entropy"
ORDER
=
8
CLI
=
[
CLI
=
[
Option
(
short
=
'E'
,
Option
(
short
=
'E'
,
long
=
'entropy'
,
long
=
'entropy'
,
...
...
src/binwalk/modules/extractor.py
View file @
464cb3b0
...
@@ -26,6 +26,7 @@ class Extractor(Module):
...
@@ -26,6 +26,7 @@ class Extractor(Module):
MAX_READ_SIZE
=
10
*
1024
*
1024
MAX_READ_SIZE
=
10
*
1024
*
1024
TITLE
=
'Extraction'
TITLE
=
'Extraction'
ORDER
=
9
CLI
=
[
CLI
=
[
Option
(
short
=
'e'
,
Option
(
short
=
'e'
,
...
...
src/binwalk/modules/signature.py
View file @
464cb3b0
...
@@ -7,6 +7,7 @@ from binwalk.core.module import Module, Option, Kwarg
...
@@ -7,6 +7,7 @@ from binwalk.core.module import Module, Option, Kwarg
class
Signature
(
Module
):
class
Signature
(
Module
):
TITLE
=
"Signature Scan"
TITLE
=
"Signature Scan"
ORDER
=
10
CLI
=
[
CLI
=
[
Option
(
short
=
'B'
,
Option
(
short
=
'B'
,
...
...
src/scripts/examples/binwalk_simple.py
0 → 100755
View file @
464cb3b0
#!/usr/bin/env python
import
binwalk
binwalk
.
Modules
()
.
execute
()
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