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
45486db3
Commit
45486db3
authored
Jan 10, 2014
by
devttys0
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/devttys0/binwalk
parents
14eda44c
3745d7ea
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
22 deletions
+37
-22
module.py
src/binwalk/core/module.py
+34
-19
smart.py
src/binwalk/core/smart.py
+2
-2
signature.py
src/binwalk/modules/signature.py
+1
-1
No files found.
src/binwalk/core/module.py
View file @
45486db3
...
...
@@ -42,8 +42,17 @@ class Option(object):
elif
self
.
type
in
[
int
,
float
,
str
]:
self
.
dtype
=
self
.
type
.
__name__
else
:
self
.
type
=
str
self
.
dtype
=
str
.
__name__
def
convert
(
self
,
value
):
if
self
.
type
and
(
self
.
type
.
__name__
==
self
.
dtype
):
return
self
.
type
(
value
)
elif
self
.
type
==
list
:
return
[
value
]
else
:
return
value
class
Kwarg
(
object
):
'''
A container class allowing modules to specify their expected __init__ kwarg(s).
...
...
@@ -734,7 +743,7 @@ class Modules(object):
elif
module_option
.
type
is
list
:
parser_kwargs
[
'action'
]
=
ListActionParser
parser
.
short_to_long
[
module_option
.
short
]
=
module_option
.
long
parser_kwargs
[
'nargs'
]
=
'+'
#
parser_kwargs['nargs'] = '+'
parser
.
add_argument
(
*
parser_args
,
**
parser_kwargs
)
...
...
@@ -765,30 +774,36 @@ class Modules(object):
# If the specified type for these kwargs is None, just set the kwarg to its specified default value.
# Else, set it to the value specified from the user.
if
module_option
.
type
is
not
None
:
value
=
args
[
module_option
.
long
]
else
:
value
=
default_value
# Convert the user-supplied value into the type specified in module_option.type.
# Do this manually as argparse doesn't seem to be able to handle hexadecimal values.
#if module_option.type is not None:
try
:
# Only convert the user-supplied value to a specific type if this kwarg's default
# type is the same as the type specified for the module option.
if
value
!=
default_value
and
type
(
default_value
)
==
module_option
.
type
:
if
module_option
.
type
==
int
:
kwargs
[
name
]
=
int
(
value
,
0
)
elif
module_option
.
type
==
float
:
kwargs
[
name
]
=
float
(
value
)
else
:
kwargs
[
name
]
=
value
else
:
kwargs
[
name
]
=
value
kwargs
[
name
]
=
module_option
.
convert
(
args
[
module_option
.
long
])
except
KeyboardInterrupt
as
e
:
raise
e
except
Exception
as
e
:
raise
ModuleException
(
"Invalid usage:
%
s"
%
str
(
e
))
#else:
#value = default_value
# Convert the user-supplied value into the type specified in module_option.type.
# Do this manually as argparse doesn't seem to be able to handle hexadecimal values.
#try:
# Only convert the user-supplied value to a specific type if this kwarg's default
# type is the same as the type specified for the module option.
# if value != default_value and type(default_value) == module_option.type:
# if module_option.type == int:
# kwargs[name] = int(value, 0)
# elif module_option.type == float:
# kwargs[name] = float(value)
# else:
# kwargs[name] = value
# else:
# kwargs[name] = value
#except KeyboardInterrupt as e:
# raise e
#except Exception as e:
# raise ModuleException("Invalid usage: %s" % str(e))
return
kwargs
def
kwargs
(
self
,
obj
,
kwargs
):
...
...
src/binwalk/core/smart.py
View file @
45486db3
...
...
@@ -157,7 +157,7 @@ class Signature(object):
'''
quoted_string
=
get_quoted_strings
(
data
)
if
quoted_string
:
data
=
data
.
replace
(
quoted_string
,
""
)
data
=
data
.
replace
(
'"'
+
quoted_string
+
'"'
,
""
)
return
data
def
one_of_many
(
self
,
data
,
tag
):
...
...
@@ -195,7 +195,7 @@ class Signature(object):
if
tag
.
tag
in
safe_data
:
arg
=
safe_data
.
split
(
tag
.
tag
)[
1
]
.
split
(
tag
.
TAG_DELIM_END
)[
0
]
return
(
data
,
arg
)
def
get_math_arg
(
self
,
data
,
tag
):
...
...
src/binwalk/modules/signature.py
View file @
45486db3
...
...
@@ -28,7 +28,7 @@ class Signature(Module):
description
=
'Cast offsets as a given data type (use -y to specify the data type / endianess)'
),
Option
(
short
=
'm'
,
long
=
'magic'
,
kwargs
=
{
'magic_files'
:
[]},
kwargs
=
{
'
enabled'
:
True
,
'
magic_files'
:
[]},
type
=
list
,
dtype
=
'file'
,
description
=
'Specify a custom magic file to use'
),
...
...
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