Commit 5ce83d5a by devttys0

Additional directory restructuring.

parent e9d9055a
...@@ -39,8 +39,8 @@ class Config: ...@@ -39,8 +39,8 @@ class Config:
# Sub directories # Sub directories
BINWALK_USER_DIR = ".binwalk" BINWALK_USER_DIR = ".binwalk"
BINWALK_MAGIC_DIR = "magics" BINWALK_MAGIC_DIR = "magic"
BINWALK_CONFIG_DIR = "configs" BINWALK_CONFIG_DIR = "config"
BINWALK_PLUGINS_DIR = "plugins" BINWALK_PLUGINS_DIR = "plugins"
# File names # File names
......
...@@ -120,7 +120,7 @@ class Module(object): ...@@ -120,7 +120,7 @@ class Module(object):
# A list of binwalk.core.module.ModuleKwargs accepted by __init__ # A list of binwalk.core.module.ModuleKwargs accepted by __init__
KWARGS = [] KWARGS = []
# A dictionary of module dependencies; all modules depend on binwalk.core.modules.configuration.Configuration # A dictionary of module dependencies; all modules depend on binwalk.modules.configuration.Configuration
DEPENDS = {'config' : 'Configuration', 'extractor' : 'Extractor'} DEPENDS = {'config' : 'Configuration', 'extractor' : 'Extractor'}
# Format string for printing the header during a scan # Format string for printing the header during a scan
...@@ -395,10 +395,10 @@ class Modules(object): ...@@ -395,10 +395,10 @@ class Modules(object):
Returns a list of modules that contain the specified attribute. Returns a list of modules that contain the specified attribute.
''' '''
import binwalk.core.modules import binwalk.modules
modules = [] modules = []
for (name, module) in inspect.getmembers(binwalk.core.modules): for (name, module) in inspect.getmembers(binwalk.modules):
if inspect.isclass(module) and hasattr(module, attribute): if inspect.isclass(module) and hasattr(module, attribute):
modules.append(module) modules.append(module)
...@@ -469,17 +469,17 @@ class Modules(object): ...@@ -469,17 +469,17 @@ class Modules(object):
return module(**kwargs) return module(**kwargs)
def dependencies(self, module): def dependencies(self, module):
import binwalk.core.modules import binwalk.modules
kwargs = {} kwargs = {}
if hasattr(module, "DEPENDS"): if hasattr(module, "DEPENDS"):
for (kwarg, dependency) in iterator(module.DEPENDS): for (kwarg, dependency) in iterator(module.DEPENDS):
# The dependency module must be imported by binwalk.core.modules.__init__.py # The dependency module must be imported by binwalk.modules.__init__.py
if hasattr(binwalk.core.modules, dependency): if hasattr(binwalk.modules, dependency):
dependency = getattr(binwalk.core.modules, dependency) dependency = getattr(binwalk.modules, dependency)
else: else:
sys.stderr.write("WARNING: %s depends on %s which was not found in binwalk.core.modules.__init__.py\n" % (str(module), dependency)) sys.stderr.write("WARNING: %s depends on %s which was not found in binwalk.modules.__init__.py\n" % (str(module), dependency))
continue continue
# No recursive dependencies, thanks # No recursive dependencies, thanks
......
...@@ -8,7 +8,7 @@ from binwalk.core.config import * ...@@ -8,7 +8,7 @@ from binwalk.core.config import *
from binwalk.core.compat import * from binwalk.core.compat import *
from binwalk.core.module import Module, Option, Kwarg, show_help from binwalk.core.module import Module, Option, Kwarg, show_help
class Configuration(): class Configuration(Module):
TITLE = "General" TITLE = "General"
...@@ -108,6 +108,7 @@ class Configuration(): ...@@ -108,6 +108,7 @@ class Configuration():
return self return self
def _cleanup(self): def _cleanup(self):
if hasattr(self, 'target_files'):
for fp in self.target_files: for fp in self.target_files:
fp.close() fp.close()
......
...@@ -19,7 +19,7 @@ class Plugin: ...@@ -19,7 +19,7 @@ class Plugin:
if self.enabled: if self.enabled:
# Replace the existing LZMA extraction command with our own # Replace the existing LZMA extraction command with our own
rules = self.extractor.get_rules() rules = self.module.extractor.get_rules()
for i in range(0, len(rules)): for i in range(0, len(rules)):
if rules[i]['regex'].match(self.SIGNATURE): if rules[i]['regex'].match(self.SIGNATURE):
self.original_cmd = rules[i]['cmd'] self.original_cmd = rules[i]['cmd']
......
import ctypes import ctypes
import ctypes.util import ctypes.util
from binwalk.common import BlockFile from binwalk.core.common import BlockFile
class Plugin: class Plugin:
''' '''
......
...@@ -97,7 +97,7 @@ os.chdir(working_directory) ...@@ -97,7 +97,7 @@ os.chdir(working_directory)
print("generating binwalk magic file") print("generating binwalk magic file")
magic_files = listdir("magic") magic_files = listdir("magic")
magic_files.sort() magic_files.sort()
fd = open("binwalk/magics/binwalk", "wb") fd = open("binwalk/magic/binwalk", "wb")
for magic in magic_files: for magic in magic_files:
fpath = path.join("magic", magic) fpath = path.join("magic", magic)
if path.isfile(fpath): if path.isfile(fpath):
...@@ -105,7 +105,7 @@ for magic in magic_files: ...@@ -105,7 +105,7 @@ for magic in magic_files:
fd.close() fd.close()
# The data files to install along with the binwalk module # The data files to install along with the binwalk module
install_data_files = ["magics/*", "configs/*", "plugins/*", "modules/*"] install_data_files = ["magic/*", "config/*", "plugins/*", "modules/*", "core/*"]
# Install the binwalk module, script and support files # Install the binwalk module, script and support files
setup( name = "binwalk", setup( name = "binwalk",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment