Merge branch 'tests_marshall' into modules_marshall
# Conflicts: # cme/loaders/module_loader.pymain
commit
82e3dad5af
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import imp
|
||||
import types
|
||||
from importlib.machinery import SourceFileLoader
|
||||
import os
|
||||
import cme
|
||||
|
@ -49,7 +50,7 @@ class module_loader:
|
|||
|
||||
def load_module(self, module_path):
|
||||
try:
|
||||
module = SourceFileLoader('payload_module', module_path).load_module().CMEModule()
|
||||
module = imp.load_source('payload_module', module_path).CMEModule()
|
||||
if self.module_is_sane(module, module_path):
|
||||
return module
|
||||
except Exception as e:
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import imp
|
||||
import types
|
||||
from importlib.machinery import SourceFileLoader
|
||||
import os
|
||||
import sys
|
||||
import cme
|
||||
|
||||
class protocol_loader:
|
||||
|
||||
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)
|
||||
loader = SourceFileLoader('protocol', protocol_path)
|
||||
protocol = types.ModuleType(loader.name)
|
||||
loader.exec_module(protocol)
|
||||
#if self.module_is_sane(module, module_path):
|
||||
return protocol
|
||||
|
||||
|
@ -27,7 +28,7 @@ class protocol_loader:
|
|||
protocol_path = os.path.join(path, protocol)
|
||||
protocol_name = protocol[:-3]
|
||||
|
||||
protocols[protocol_name] = {'path' : protocol_path}
|
||||
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')
|
||||
|
|
|
@ -1177,41 +1177,8 @@ class smb(connection):
|
|||
|
||||
def users(self):
|
||||
users = []
|
||||
for dc_ip in self.get_dc_ips():
|
||||
try:
|
||||
users = get_netuser(
|
||||
dc_ip,
|
||||
self.domain,
|
||||
self.username,
|
||||
password=self.password,
|
||||
lmhash=self.lmhash,
|
||||
nthash=self.nthash,
|
||||
queried_username=self.args.users,
|
||||
queried_domain='',
|
||||
ads_path=str(),
|
||||
admin_count=False,
|
||||
spn=False,
|
||||
unconstrained=False,
|
||||
allow_delegation=False,
|
||||
custom_filter=str()
|
||||
)
|
||||
|
||||
self.logger.success('Enumerated domain user(s)')
|
||||
for user in users:
|
||||
domain = self.domainfromdsn(user.distinguishedname)
|
||||
self.logger.highlight('{}\\{:<30} badpwdcount: {} desc: {}'.format(
|
||||
domain,
|
||||
user.samaccountname,
|
||||
getattr(user, 'badpwdcount', 0),
|
||||
user.description[0] if hasattr(user, 'description') else '')
|
||||
)
|
||||
# self.db.add_user(domain, user.samaccountname)
|
||||
break
|
||||
except Exception as e:
|
||||
self.logger.error('Error enumerating domain users using dc ip {}: {}'.format(dc_ip, e))
|
||||
self.logger.info('Trying with SAMRPC protocol')
|
||||
users = UserSamrDump(self).dump()
|
||||
break
|
||||
self.logger.info('Trying do dump local users with SAMRPC protocol')
|
||||
users = UserSamrDump(self).dump()
|
||||
return users
|
||||
|
||||
def hosts(self):
|
||||
|
|
|
@ -51,7 +51,6 @@ masky = "^0.2.0"
|
|||
sqlalchemy = "^2.0.4"
|
||||
aiosqlite = "^0.18.0"
|
||||
pytest = "^7.2.2"
|
||||
pytest-asyncio = "^0.21.0"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
flake8 = "*"
|
||||
|
|
|
@ -27,7 +27,7 @@ def db_engine():
|
|||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def db(db_engine):
|
||||
def db_setup(db_engine):
|
||||
proto = "smb"
|
||||
setup_logger()
|
||||
logger = CMEAdapter()
|
||||
|
@ -46,6 +46,12 @@ def db(db_engine):
|
|||
delete_workspace("test")
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def db(db_setup):
|
||||
yield db_setup
|
||||
db_setup.clear_database()
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def sess(db_engine):
|
||||
session_factory = sessionmaker(
|
||||
|
@ -86,7 +92,6 @@ def test_add_host(db):
|
|||
assert host.zerologon is True
|
||||
assert host.petitpotam is False
|
||||
assert host.dc is False
|
||||
db.clear_database()
|
||||
|
||||
|
||||
def test_update_host(db, sess):
|
||||
|
@ -129,7 +134,6 @@ def test_update_host(db, sess):
|
|||
assert host.zerologon is False
|
||||
assert host.petitpotam is False
|
||||
assert host.dc is False
|
||||
db.clear_database()
|
||||
|
||||
|
||||
def test_add_credential():
|
||||
|
|
Loading…
Reference in New Issue