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
6148802a
Commit
6148802a
authored
Dec 09, 2016
by
Louis Granboulan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the possibility of having user-defined modules (not only plugins for existing modules)
parent
cd6e27b5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
module.py
src/binwalk/core/module.py
+18
-0
settings.py
src/binwalk/core/settings.py
+2
-0
No files found.
src/binwalk/core/module.py
View file @
6148802a
...
@@ -673,6 +673,24 @@ class Modules(object):
...
@@ -673,6 +673,24 @@ class Modules(object):
if
inspect
.
isclass
(
module
)
and
hasattr
(
module
,
attribute
):
if
inspect
.
isclass
(
module
)
and
hasattr
(
module
,
attribute
):
modules
[
module
]
=
module
.
PRIORITY
modules
[
module
]
=
module
.
PRIORITY
# user-defined modules
import
imp
user_modules
=
binwalk
.
core
.
settings
.
Settings
()
.
user
.
modules
for
file_name
in
os
.
listdir
(
user_modules
):
if
not
file_name
.
endswith
(
'.py'
):
continue
module_name
=
file_name
[:
-
3
]
try
:
user_module
=
imp
.
load_source
(
module_name
,
os
.
path
.
join
(
user_modules
,
file_name
))
except
KeyboardInterrupt
as
e
:
raise
e
except
Exception
as
e
:
binwalk
.
core
.
common
.
warning
(
"Error loading module '
%
s':
%
s"
%
(
file_name
,
str
(
e
)))
for
(
name
,
module
)
in
inspect
.
getmembers
(
user_module
):
if
inspect
.
isclass
(
module
)
and
hasattr
(
module
,
attribute
):
modules
[
module
]
=
module
.
PRIORITY
return
sorted
(
modules
,
key
=
modules
.
get
,
reverse
=
True
)
return
sorted
(
modules
,
key
=
modules
.
get
,
reverse
=
True
)
def
help
(
self
):
def
help
(
self
):
...
...
src/binwalk/core/settings.py
View file @
6148802a
...
@@ -23,6 +23,7 @@ class Settings:
...
@@ -23,6 +23,7 @@ class Settings:
BINWALK_USER_DIR
=
"binwalk"
BINWALK_USER_DIR
=
"binwalk"
BINWALK_MAGIC_DIR
=
"magic"
BINWALK_MAGIC_DIR
=
"magic"
BINWALK_CONFIG_DIR
=
"config"
BINWALK_CONFIG_DIR
=
"config"
BINWALK_MODULES_DIR
=
"modules"
BINWALK_PLUGINS_DIR
=
"plugins"
BINWALK_PLUGINS_DIR
=
"plugins"
# File names
# File names
...
@@ -43,6 +44,7 @@ class Settings:
...
@@ -43,6 +44,7 @@ class Settings:
self
.
user
=
common
.
GenericContainer
(
binarch
=
self
.
_user_path
(
self
.
BINWALK_MAGIC_DIR
,
self
.
BINARCH_MAGIC_FILE
),
self
.
user
=
common
.
GenericContainer
(
binarch
=
self
.
_user_path
(
self
.
BINWALK_MAGIC_DIR
,
self
.
BINARCH_MAGIC_FILE
),
magic
=
self
.
_magic_signature_files
(
user_only
=
True
),
magic
=
self
.
_magic_signature_files
(
user_only
=
True
),
extract
=
self
.
_user_path
(
self
.
BINWALK_CONFIG_DIR
,
self
.
EXTRACT_FILE
),
extract
=
self
.
_user_path
(
self
.
BINWALK_CONFIG_DIR
,
self
.
EXTRACT_FILE
),
modules
=
self
.
_user_path
(
self
.
BINWALK_MODULES_DIR
),
plugins
=
self
.
_user_path
(
self
.
BINWALK_PLUGINS_DIR
))
plugins
=
self
.
_user_path
(
self
.
BINWALK_PLUGINS_DIR
))
...
...
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