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
338d94a4
Commit
338d94a4
authored
Dec 19, 2013
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated usage, removed --update
parent
778ee6f5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
131 deletions
+11
-131
module.py
src/binwalk/module.py
+8
-4
configuration.py
src/binwalk/modules/configuration.py
+2
-126
signature.py
src/binwalk/modules/signature.py
+1
-1
No files found.
src/binwalk/module.py
View file @
338d94a4
...
...
@@ -24,7 +24,6 @@ class ModuleOption(object):
@short - The short option to use (optional).
@long - The long option to use (if None, this option will not be displayed in help output).
@type - The accepted data type (one of: io.FileIO/argparse.FileType/binwalk.common.BlockFile, list, str, int, float).
@dtype - The accepted data type, as displayed in the help output.
Returns None.
'''
...
...
@@ -37,8 +36,13 @@ class ModuleOption(object):
self
.
type
=
type
self
.
dtype
=
str
(
dtype
)
if
not
self
.
dtype
and
self
.
type
:
self
.
dtype
=
str
(
self
.
type
)
if
not
self
.
dtype
:
if
self
.
type
in
[
io
.
FileIO
,
argparse
.
FileType
,
binwalk
.
common
.
BlockFile
]:
self
.
dtype
=
'file'
elif
self
.
type
in
[
int
,
float
,
str
]:
self
.
dtype
=
self
.
type
.
__name__
else
:
self
.
dtype
=
str
.
__name__
class
ModuleKwarg
(
object
):
'''
...
...
@@ -394,7 +398,7 @@ class Modules(object):
long_opt
=
'--'
+
module_option
.
long
if
module_option
.
nargs
>
0
:
optargs
=
"=
%
s
"
%
module_option
.
dtype
optargs
=
"=
<
%
s>
"
%
module_option
.
dtype
else
:
optargs
=
""
...
...
src/binwalk/modules/configuration.py
View file @
338d94a4
import
os
import
sys
import
argparse
import
binwalk.common
import
binwalk.module
import
binwalk.config
...
...
@@ -33,6 +34,7 @@ class Configuration(binwalk.module.Module):
binwalk
.
module
.
ModuleOption
(
long
=
'log'
,
short
=
'f'
,
nargs
=
1
,
type
=
argparse
.
FileType
,
kwargs
=
{
'log_file'
:
None
},
description
=
'Log results to file'
),
binwalk
.
module
.
ModuleOption
(
long
=
'csv'
,
...
...
@@ -64,10 +66,6 @@ class Configuration(binwalk.module.Module):
short
=
None
,
type
=
binwalk
.
common
.
BlockFile
,
kwargs
=
{
'files'
:
[]}),
binwalk
.
module
.
ModuleOption
(
short
=
'u'
,
long
=
'update'
,
kwargs
=
{
'do_update'
:
True
},
description
=
'Update magic signature files'
),
]
KWARGS
=
[
...
...
@@ -82,7 +80,6 @@ class Configuration(binwalk.module.Module):
binwalk
.
module
.
ModuleKwarg
(
name
=
'skip_unopened'
,
default
=
False
),
binwalk
.
module
.
ModuleKwarg
(
name
=
'files'
,
default
=
[]),
binwalk
.
module
.
ModuleKwarg
(
name
=
'show_help'
,
default
=
False
),
binwalk
.
module
.
ModuleKwarg
(
name
=
'do_update'
,
default
=
False
),
]
def
load
(
self
):
...
...
@@ -99,10 +96,6 @@ class Configuration(binwalk.module.Module):
binwalk
.
module
.
show_help
()
sys
.
exit
(
0
)
if
self
.
do_update
:
Update
(
self
.
verbose
)
.
update
()
sys
.
exit
(
0
)
self
.
_open_target_files
()
self
.
_set_verbosity
()
...
...
@@ -157,120 +150,3 @@ class Configuration(binwalk.module.Module):
plural
=
''
raise
Exception
(
"Failed to open
%
d file
%
s for scanning"
%
(
failed_open_count
,
plural
))
class
Update
(
object
):
'''
Class for updating binwalk configuration and signatures files from the subversion trunk.
Example usage:
from binwalk import Update
Update().update()
'''
BASE_URL
=
"https://raw.github.com/devttys0/binwalk/master/src/binwalk/"
MAGIC_PREFIX
=
"magic/"
CONFIG_PREFIX
=
"config/"
def
__init__
(
self
,
verbose
):
'''
Class constructor.
@verbose - Verbose flag.
Returns None.
'''
self
.
verbose
=
verbose
self
.
config
=
Config
()
def
update
(
self
):
'''
Updates all system wide signatures and config files.
Returns None.
'''
self
.
update_binwalk
()
self
.
update_bincast
()
self
.
update_binarch
()
self
.
update_extract
()
self
.
update_zlib
()
self
.
update_compressd
()
def
_do_update_from_git
(
self
,
prefix
,
fname
):
'''
Updates the specified file to the latest version of that file in SVN.
@prefix - The URL subdirectory where the file is located.
@fname - The name of the file to update.
Returns None.
'''
# Get the local http proxy, if any
# csoban.kesmarki
proxy_url
=
os
.
getenv
(
'HTTP_PROXY'
)
if
proxy_url
:
proxy_support
=
urllib2
.
ProxyHandler
({
'http'
:
proxy_url
})
opener
=
urllib2
.
build_opener
(
proxy_support
)
urllib2
.
install_opener
(
opener
)
url
=
self
.
BASE_URL
+
prefix
+
fname
try
:
if
self
.
verbose
:
print
(
"Fetching
%
s..."
%
url
)
data
=
urllib2
.
urlopen
(
url
)
.
read
()
open
(
self
.
config
.
paths
[
'system'
][
fname
],
"wb"
)
.
write
(
data
)
except
KeyboardInterrupt
as
e
:
raise
e
except
Exception
as
e
:
raise
Exception
(
"Update._do_update_from_git failed to update file '
%
s':
%
s"
%
(
url
,
str
(
e
)))
def
update_binwalk
(
self
):
'''
Updates the binwalk signature file.
Returns None.
'''
self
.
_do_update_from_git
(
self
.
MAGIC_PREFIX
,
self
.
config
.
BINWALK_MAGIC_FILE
)
def
update_bincast
(
self
):
'''
Updates the bincast signature file.
Returns None.
'''
self
.
_do_update_from_git
(
self
.
MAGIC_PREFIX
,
self
.
config
.
BINCAST_MAGIC_FILE
)
def
update_binarch
(
self
):
'''
Updates the binarch signature file.
Returns None.
'''
self
.
_do_update_from_git
(
self
.
MAGIC_PREFIX
,
self
.
config
.
BINARCH_MAGIC_FILE
)
def
update_zlib
(
self
):
'''
Updates the zlib signature file.
Returns None.
'''
self
.
_do_update_from_git
(
self
.
MAGIC_PREFIX
,
self
.
config
.
ZLIB_MAGIC_FILE
)
def
update_compressd
(
self
):
'''
Updates the compress'd signature file.
Returns None.
'''
self
.
_do_update_from_git
(
self
.
MAGIC_PREFIX
,
self
.
config
.
COMPRESSD_MAGIC_FILE
)
def
update_extract
(
self
):
'''
Updates the extract.conf file.
Returns None.
'''
self
.
_do_update_from_git
(
self
.
CONFIG_PREFIX
,
self
.
config
.
EXTRACT_FILE
)
src/binwalk/modules/signature.py
View file @
338d94a4
...
...
@@ -19,7 +19,7 @@ class Signature(binwalk.module.Module):
nargs
=
1
,
kwargs
=
{
'magic_files'
:
[]},
type
=
[],
dtype
=
str
,
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