Skip to content

Commit

Permalink
Merge pull request #277 from sepauli/sepauli/fix-mssql_priv
Browse files Browse the repository at this point in the history
fix mssql_priv
  • Loading branch information
Marshall-Hallenbeck authored Apr 27, 2024
2 parents 0ffa19d + d7918cd commit 60db634
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion nxc/modules/adcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def options(self, context, module_options):
SERVER PKI Enrollment Server to enumerate templates for. Default is None, use CN name
BASE_DN The base domain name for the LDAP query
"""
self.context = context
self.regex = re.compile("(https?://.+)")

self.server = None
Expand All @@ -39,6 +38,7 @@ def options(self, context, module_options):

def on_login(self, context, connection):
"""On a successful LDAP login we perform a search for all PKI Enrollment Server or Certificate Templates Names."""
self.context = context
if self.server is None:
search_filter = "(objectClass=pKIEnrollmentService)"
else:
Expand Down
2 changes: 1 addition & 1 deletion nxc/modules/daclread.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ def options(self, context, module_options):
Based on the work of @_nwodtuhs and @BlWasp_.
"""
self.context = context

context.log.debug(f"module_options: {module_options}")

Expand Down Expand Up @@ -273,6 +272,7 @@ def options(self, context, module_options):
self.filename = None

def on_login(self, context, connection):
self.context = context
"""On a successful LDAP login we perform a search for the targets' SID, their Security Descriptors and the principal's SID if there is one specified"""
context.log.highlight("Be careful, this module cannot read the DACLS recursively.")
self.baseDN = connection.ldapConnection._baseDN
Expand Down
14 changes: 6 additions & 8 deletions nxc/modules/mssql_priv.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ def options(self, context, module_options):
- rollback (remove sysadmin privilege)
"""
self.action = None
self.context = context

if "ACTION" in module_options:
self.action = module_options["ACTION"]

def on_login(self, context, connection):
self.context = context
# get mssql connection
self.mssql_conn = connection.conn
# fetch the current user
Expand Down Expand Up @@ -441,13 +441,11 @@ def is_admin_user(self, username) -> bool:
:rtype: bool
"""
res = self.query_and_get_output(f"SELECT IS_SRVROLEMEMBER('sysadmin', '{username}')")
try:
if int(res):
self.admin_privs = True
return True
else:
return False
except Exception:
is_admin = res[0][""]
if is_admin:
self.admin_privs = True
return True
else:
return False

def revert_context(self, exec_as):
Expand Down
1 change: 0 additions & 1 deletion nxc/modules/nanodump.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def options(self, context, module_options):
NANO_EXE_NAME Name of the nano executable (default: nano.exe)
DIR_RESULT Location where the dmp are stored (default: DIR_RESULT = NANO_PATH)
"""
self.context = context
self.remote_tmp_dir = "C:\\Windows\\Temp\\"
self.share = "C$"
self.tmp_share = self.remote_tmp_dir.split(":")[1]
Expand Down
2 changes: 1 addition & 1 deletion nxc/modules/user-desc.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def options(self, context, module_options):
"""
self.log_file = None
self.desc_count = 0
self.context = context
self.account_names = set()
self.keywords = {"pass", "creds", "creden", "key", "secret", "default"}

Expand Down Expand Up @@ -71,6 +70,7 @@ def on_login(self, context, connection):
On successful LDAP login we perform a search for all user objects that have a description.
Users can specify additional LDAP filters that are applied to the query.
"""
self.context = context
self.create_log_file(connection.conn.getRemoteHost(), datetime.now().strftime("%Y%m%d_%H%M%S"))
context.log.info(f"Starting LDAP search with search filter '{self.search_filter}'")

Expand Down

0 comments on commit 60db634

Please sign in to comment.