From f3465ef0080ae56aa64fb2d89aaf7cf7bf253aa0 Mon Sep 17 00:00:00 2001 From: byt3bl33d3r Date: Thu, 1 Mar 2018 12:36:17 -0700 Subject: [PATCH] Fixed up @aj-cgtech changes --- README.md | 6 +++--- cme/crackmapexec.py | 4 ++-- cme/data/cme.conf | 1 + cme/first_run.py | 23 ++++++++++++----------- cme/protocols/mssql.py | 11 ++++------- cme/protocols/smb.py | 6 +++--- cme/protocols/ssh.py | 2 +- cme/protocols/winrm.py | 2 +- cme/thirdparty/pywinrm | 2 +- 9 files changed, 28 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 8b14bb8b..fa7583d3 100755 --- a/README.md +++ b/README.md @@ -43,11 +43,11 @@ Please see the installation wiki page [here](https://github.com/byt3bl33d3r/Crac # How to fund my tea & sushi reserve -BTC: 1ER8rRE6NTZ7RHN88zc6JY87LvtyuRUJGU +BTC: `1ER8rRE6NTZ7RHN88zc6JY87LvtyuRUJGU` -ETH: 0x91d9aDCf8B91f55BCBF0841616A01BeE551E90ee +ETH: `0x91d9aDCf8B91f55BCBF0841616A01BeE551E90ee` -LTC: LLMa2bsvXbgBGnnBwiXYazsj7Uz6zRe4fr +LTC: `LLMa2bsvXbgBGnnBwiXYazsj7Uz6zRe4fr` # To do - Kerberos support diff --git a/cme/crackmapexec.py b/cme/crackmapexec.py index 7a41db10..c76cc985 100755 --- a/cme/crackmapexec.py +++ b/cme/crackmapexec.py @@ -44,10 +44,10 @@ def main(): cme_path = os.path.expanduser('~/.cme') - config = ConfigParser({'pwn3d_label': 'Pwn3d!'}) + config = ConfigParser() config.read(os.path.join(cme_path, 'cme.conf')) - module = None + module = None module_server = None targets = [] jitter = None diff --git a/cme/data/cme.conf b/cme/data/cme.conf index 721bd004..f2a50cdb 100755 --- a/cme/data/cme.conf +++ b/cme/data/cme.conf @@ -1,6 +1,7 @@ [CME] workspace=default last_used_db= +pwn3d_label=Pwn3d! [Empire] api_host=127.0.0.1 diff --git a/cme/first_run.py b/cme/first_run.py index a48266ba..bc518c90 100755 --- a/cme/first_run.py +++ b/cme/first_run.py @@ -2,18 +2,18 @@ import os import sqlite3 import shutil import cme -from ConfigParser import ConfigParser, NoSectionError -from cme.helpers.logger import highlight +from ConfigParser import ConfigParser, NoSectionError, NoOptionError from cme.loaders.protocol_loader import protocol_loader from subprocess import check_output, PIPE from sys import exit -CME_PATH = os.path.expanduser('~/.cme') -TMP_PATH = os.path.join('/tmp', 'cme_hosted') -WS_PATH = os.path.join(CME_PATH, 'workspaces') +CME_PATH = os.path.expanduser('~/.cme') +TMP_PATH = os.path.join('/tmp', 'cme_hosted') +WS_PATH = os.path.join(CME_PATH, 'workspaces') CERT_PATH = os.path.join(CME_PATH, 'cme.pem') CONFIG_PATH = os.path.join(CME_PATH, 'cme.conf') + def first_run_setup(logger): if not os.path.exists(TMP_PATH): @@ -27,13 +27,13 @@ def first_run_setup(logger): folders = ['logs', 'modules', 'protocols', 'workspaces', 'obfuscated_scripts'] for folder in folders: if not os.path.exists(os.path.join(CME_PATH, folder)): - os.mkdir(os.path.join(CME_PATH,folder)) + os.mkdir(os.path.join(CME_PATH, folder)) if not os.path.exists(os.path.join(WS_PATH, 'default')): logger.info('Creating default workspace') os.mkdir(os.path.join(WS_PATH, 'default')) - p_loader = protocol_loader() + p_loader = protocol_loader() protocols = p_loader.get_protocols() for protocol in protocols.keys(): try: @@ -67,16 +67,17 @@ def first_run_setup(logger): try: config = ConfigParser() config.read(CONFIG_PATH) - current_workspace = config.get('CME', 'workspace') - except NoSectionError: - logger.info('v3.x configuration file detected, replacing with new version') + config.get('CME', 'workspace') + config.get('CME', 'pwn3d_label') + except (NoSectionError, NoOptionError): + logger.info('Old configuration file detected, replacing with new version') default_path = os.path.join(os.path.dirname(cme.__file__), 'data', 'cme.conf') shutil.copy(default_path, CME_PATH) if not os.path.exists(CERT_PATH): logger.info('Generating SSL certificate') try: - out = check_output(['openssl', 'help'], stderr=PIPE) + check_output(['openssl', 'help'], stderr=PIPE) except OSError as e: if e.errno == os.errno.ENOENT: logger.error('OpenSSL command line utility is not installed, could not generate certificate') diff --git a/cme/protocols/mssql.py b/cme/protocols/mssql.py index 11c164c6..b5d0d19c 100755 --- a/cme/protocols/mssql.py +++ b/cme/protocols/mssql.py @@ -171,13 +171,10 @@ class mssql(connection): self.db.add_admin_user('plaintext', domain, username, password, self.host) out = u'{}{}:{} {}'.format('{}\\'.format(domain.decode('utf-8')) if self.args.auth_type is 'windows' else '', - username.decode('utf-8'), - password.decode('utf-8'), - highlight('('+self.config.get('CME','pwn3d_label')+')') if self.admin_privs else '') - - + username.decode('utf-8'), + password.decode('utf-8'), + highlight('({})'.format(self.config.get('CME', 'pwn3d_label')) if self.admin_privs else '')) self.logger.success(out) - return True def hash_login(self, domain, username, ntlm_hash): @@ -207,7 +204,7 @@ class mssql(connection): out = u'{}\\{} {} {}'.format(domain.decode('utf-8'), username.decode('utf-8'), ntlm_hash, - highlight('('+self.config.get('CME','pwn3d_label')+')') if self.admin_privs else '') + highlight('({})'.format(self.config.get('CME', 'pwn3d_label')) if self.admin_privs else '')) self.logger.success(out) diff --git a/cme/protocols/smb.py b/cme/protocols/smb.py index 4dc4f056..279e5e0a 100755 --- a/cme/protocols/smb.py +++ b/cme/protocols/smb.py @@ -27,7 +27,6 @@ from cme.protocols.smb.passpol import PassPolDump from cme.helpers.logger import highlight from cme.helpers.misc import * from cme.helpers.powershell import create_ps_command -from ConfigParser import ConfigParser from pywerview.cli.helpers import * from pywerview.requester import RPCRequester from time import time @@ -91,6 +90,7 @@ def requires_smb_server(func): return wraps(func)(_decorator) + class smb(connection): def __init__(self, args, db, host): @@ -260,7 +260,7 @@ class smb(connection): out = u'{}\\{}:{} {}'.format(domain.decode('utf-8'), username.decode('utf-8'), password.decode('utf-8'), - highlight('('+self.config.get('CME','pwn3d_label')+')') if self.admin_privs else '') + highlight('({})'.format(self.config.get('CME', 'pwn3d_label')) if self.admin_privs else '')) self.logger.success(out) return True @@ -304,7 +304,7 @@ class smb(connection): out = u'{}\\{} {} {}'.format(domain.decode('utf-8'), username.decode('utf-8'), ntlm_hash, - highlight('('+self.config.get('CME','pwn3d_label')+')') if self.admin_privs else '') + highlight('({})'.format(self.config.get('CME', 'pwn3d_label')) if self.admin_privs else '')) self.logger.success(out) return True diff --git a/cme/protocols/ssh.py b/cme/protocols/ssh.py index 8040ab6c..e1a5df86 100644 --- a/cme/protocols/ssh.py +++ b/cme/protocols/ssh.py @@ -60,7 +60,7 @@ class ssh(connection): self.logger.success(u'{}:{} {}'.format(username.decode('utf-8'), password.decode('utf-8'), - highlight('('+self.config.get('CME','pwn3d_label')+')') if self.admin_privs else '')) + highlight('({})'.format(self.config.get('CME', 'pwn3d_label')) if self.admin_privs else ''))) return True except Exception as e: diff --git a/cme/protocols/winrm.py b/cme/protocols/winrm.py index e1f116f9..18da4b8c 100644 --- a/cme/protocols/winrm.py +++ b/cme/protocols/winrm.py @@ -120,7 +120,7 @@ class winrm(connection): self.logger.success(u'{}\\{}:{} {}'.format(self.domain.decode('utf-8'), username.decode('utf-8'), password.decode('utf-8'), - highlight('('+self.config.get('CME','pwn3d_label')+')'))) + highlight('({})'.format(self.config.get('CME', 'pwn3d_label')) if self.admin_privs else ''))) return True diff --git a/cme/thirdparty/pywinrm b/cme/thirdparty/pywinrm index f2fae367..354b1cd4 160000 --- a/cme/thirdparty/pywinrm +++ b/cme/thirdparty/pywinrm @@ -1 +1 @@ -Subproject commit f2fae367d3ac2abc3ed6fe9c7c17e6ffbac69e67 +Subproject commit 354b1cd49e1a28839832463abf691d9fff1f8e6f