Files
Pennyw0rth-NetExec/cme/loaders/protocol_loader.py
T
byt3bl33d3r 9fefd167b0 Initial commit for v4.0
Just fyi for anyone reading this, it's not even close to being
finished.

The amount of changes are pretty insane, this commit is to serve as a
refrence point for myself.

Highlights for v4.0:
- The whole codebase has been re-written from scratch
- Codebase has been cut around 2/4
- Protocols are now modular! In theory we could use CME for everything
- Module chaining has been removed for now, still trying to figure out a
more elegant solution
- Workspaces have implemented in cmedb
- The smb protocol's database schema has been changed to support storing users,
groups and computers with their respective memberships and relations.
- I'm in the process of re-writing most of the modules, will re-add them
once i've finished
2016-12-15 00:28:00 -07:00

37 lines
1.3 KiB
Python
Executable File

import imp
import os
import sys
import cme
class protocol_loader:
def __init__(self):
self.cme_path = os.path.expanduser('~/.cme')
def load_protocol(self, protocol_path):
protocol = imp.load_source('protocol', protocol_path)
#if self.module_is_sane(module, module_path):
return protocol
def get_protocols(self):
protocols = {}
protocol_paths = [os.path.join(os.path.dirname(cme.__file__), 'protocols'), os.path.join(self.cme_path, 'protocols')]
for path in protocol_paths:
for protocol in os.listdir(path):
if protocol[-3:] == '.py' and protocol[:-3] != '__init__':
protocol_path = os.path.join(path, protocol)
protocol_name = protocol[:-3]
protocols[protocol_name] = {'path' : protocol_path}
db_file_path = os.path.join(path, protocol_name, 'database.py')
db_nav_path = os.path.join(path, protocol_name, 'db_navigator.py')
if os.path.exists(db_file_path):
protocols[protocol_name]['dbpath'] = db_file_path
if os.path.exists(db_nav_path):
protocols[protocol_name]['nvpath'] = db_nav_path
return protocols