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
c297fbc3
Commit
c297fbc3
authored
8 years ago
by
Craig Heffner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added load_file method support for plugins
parent
1e0491ee
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
15 deletions
+28
-15
__init__.py
src/binwalk/__init__.py
+2
-1
magic.py
src/binwalk/core/magic.py
+1
-6
module.py
src/binwalk/core/module.py
+10
-8
plugin.py
src/binwalk/core/plugin.py
+15
-0
No files found.
src/binwalk/__init__.py
View file @
c297fbc3
__all__
=
[
'scan'
,
'execute'
,
'ModuleException'
]
from
binwalk.core.module
import
Modules
,
ModuleException
from
binwalk.core.module
import
Modules
from
binwalk.core.exceptions
import
ModuleException
# Convenience functions
def
scan
(
*
args
,
**
kwargs
):
...
...
This diff is collapsed.
Click to expand it.
src/binwalk/core/magic.py
View file @
c297fbc3
...
...
@@ -9,12 +9,7 @@ import struct
import
datetime
import
binwalk.core.common
import
binwalk.core.compat
class
ParserException
(
Exception
):
'''
Exception thrown specifically for signature file parsing errors.
'''
pass
from
binwalk.core.exceptions
import
ParserException
class
SignatureResult
(
binwalk
.
core
.
module
.
Result
):
'''
...
...
This diff is collapsed.
Click to expand it.
src/binwalk/core/module.py
View file @
c297fbc3
...
...
@@ -17,6 +17,7 @@ import binwalk.core.settings
import
binwalk.core.plugin
from
threading
import
Thread
from
binwalk.core.compat
import
*
from
binwalk.core.exceptions
import
*
class
Option
(
object
):
'''
...
...
@@ -319,6 +320,13 @@ class Module(object):
def
_plugins_pre_scan
(
self
):
self
.
plugins
.
pre_scan_callbacks
(
self
)
def
_plugins_load_file
(
self
,
fp
):
try
:
self
.
plugins
.
load_file_callbacks
(
fp
)
return
True
except
IgnoreFileException
:
return
False
def
_plugins_new_file
(
self
,
fp
):
self
.
plugins
.
new_file_callbacks
(
fp
)
...
...
@@ -398,7 +406,8 @@ class Module(object):
if
not
fp
:
break
else
:
if
self
.
config
.
file_name_filter
(
fp
)
==
False
:
if
(
self
.
config
.
file_name_filter
(
fp
)
==
False
or
self
.
_plugins_load_file
(
fp
)
==
False
):
fp
.
close
()
fp
=
None
continue
...
...
@@ -588,13 +597,6 @@ class Status(object):
for
(
k
,
v
)
in
iterator
(
self
.
kwargs
):
setattr
(
self
,
k
,
v
)
class
ModuleException
(
Exception
):
'''
Module exception class.
Nothing special here except the name.
'''
pass
class
Modules
(
object
):
'''
Main class used for running and managing modules.
...
...
This diff is collapsed.
Click to expand it.
src/binwalk/core/plugin.py
View file @
c297fbc3
...
...
@@ -7,6 +7,7 @@ import inspect
import
binwalk.core.common
import
binwalk.core.settings
from
binwalk.core.compat
import
*
from
binwalk.core.exceptions
import
IgnoreFileException
class
Plugin
(
object
):
'''
...
...
@@ -80,6 +81,7 @@ class Plugins(object):
SCAN
=
'scan'
NEWFILE
=
'new_file'
LOADFILE
=
'load_file'
PRESCAN
=
'pre_scan'
POSTSCAN
=
'post_scan'
MODULE_EXTENSION
=
'.py'
...
...
@@ -88,6 +90,7 @@ class Plugins(object):
self
.
scan
=
[]
self
.
pre_scan
=
[]
self
.
new_file
=
[]
self
.
load_file
=
[]
self
.
post_scan
=
[]
self
.
parent
=
parent
self
.
settings
=
binwalk
.
core
.
settings
.
Settings
()
...
...
@@ -108,6 +111,8 @@ class Plugins(object):
callback
(
obj
)
except
KeyboardInterrupt
as
e
:
raise
e
except
IgnoreFileException
as
e
:
raise
e
except
Exception
as
e
:
binwalk
.
core
.
common
.
warning
(
"
%
s.
%
s failed:
%
s"
%
(
callback
.
__module__
,
callback
.
__name__
,
e
))
...
...
@@ -215,6 +220,13 @@ class Plugins(object):
pass
try
:
self
.
load_file
.
append
(
getattr
(
class_instance
,
self
.
LOADFILE
))
except
KeyboardInterrupt
as
e
:
raise
e
except
Exception
as
e
:
pass
try
:
self
.
pre_scan
.
append
(
getattr
(
class_instance
,
self
.
PRESCAN
))
except
KeyboardInterrupt
as
e
:
raise
e
...
...
@@ -243,6 +255,9 @@ class Plugins(object):
def
pre_scan_callbacks
(
self
,
obj
):
return
self
.
_call_plugins
(
self
.
pre_scan
)
def
load_file_callbacks
(
self
,
fp
):
return
self
.
_call_plugins
(
self
.
load_file
,
fp
)
def
new_file_callbacks
(
self
,
fp
):
return
self
.
_call_plugins
(
self
.
new_file
,
fp
)
...
...
This diff is collapsed.
Click to expand it.
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