Skip to content

Commit

Permalink
Merge pull request #506 from Pennyw0rth/ruff
Browse files Browse the repository at this point in the history
fix ruff
  • Loading branch information
mpgn authored Dec 17, 2024
2 parents a284b00 + 4c9db0a commit 2e1f225
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 35 deletions.
9 changes: 5 additions & 4 deletions nxc/modules/enum_impersonate.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#Author:
# deathflamingo
class NXCModule:
"""Enumerate SQL Server users with impersonation rights"""
"""
Enumerate SQL Server users with impersonation rights
Module by deathflamingo
"""

name = "enum_impersonate"
description = "Enumerate users with impersonation privileges"
Expand All @@ -28,7 +29,7 @@ def get_impersonate_users(self) -> list:
"""
Fetches a list of users with impersonation rights.
Returns:
Returns
-------
list: List of user names.
"""
Expand Down
9 changes: 5 additions & 4 deletions nxc/modules/enum_links.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#Author:
# deathflamingo
class NXCModule:
"""Enumerate SQL Server linked servers"""
"""
Enumerate SQL Server linked servers
Module by deathflamingo
"""

name = "enum_links"
description = "Enumerate linked SQL Servers"
Expand All @@ -28,7 +29,7 @@ def get_linked_servers(self) -> list:
"""
Fetches a list of linked servers.
Returns:
Returns
-------
list: List of linked server names.
"""
Expand Down
9 changes: 5 additions & 4 deletions nxc/modules/enum_logins.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#Author:
# deathflamingo
class NXCModule:
"""Enumerate SQL Server logins"""
"""
Enumerate SQL Server logins
Module by deathflamingo
"""

name = "enum_logins"
description = "Enumerate SQL Server logins"
Expand All @@ -28,7 +29,7 @@ def get_logins(self) -> list:
"""
Fetches a list of SQL Server logins.
Returns:
Returns
-------
list: List of login names.
"""
Expand Down
11 changes: 5 additions & 6 deletions nxc/modules/exec_on_link.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#Author:
# deathflamingo
class NXCModule:
"""Execute commands on linked servers"""
"""
Execute commands on linked servers
Module by deathflamingo
"""

name = "exec_on_link"
description = "Execute commands on a SQL Server linked server"
Expand Down Expand Up @@ -35,9 +36,7 @@ def on_login(self, context, connection):
self.execute_on_link()

def execute_on_link(self):
"""
Executes the specified command on the linked server.
"""
"""Executes the specified command on the linked server."""
query = f"EXEC ('{self.command}') AT [{self.linked_server}];"
result = self.mssql_conn.sql_query(query)
self.context.log.display(f"Command output: {result}")
11 changes: 6 additions & 5 deletions nxc/modules/link_enable_xp.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#Author:
# deathflamingo
class NXCModule:
"""Enable or disable xp_cmdshell on a linked SQL server"""
"""
Enable or disable xp_cmdshell on a linked SQL server
Module by deathflamingo
"""

name = "link_enable_xp"
description = "Enable or disable xp_cmdshell on a linked SQL server"
Expand Down Expand Up @@ -43,10 +44,10 @@ def enable_xp_cmdshell(self):
"""Enable xp_cmdshell on the linked server."""
query = f"EXEC ('sp_configure ''show advanced options'', 1; RECONFIGURE;') AT [{self.linked_server}]"
self.context.log.display(f"Enabling advanced options on {self.linked_server}...")
out=self.query_and_get_output(query)
out = self.query_and_get_output(query)
query = f"EXEC ('sp_configure ''xp_cmdshell'', 1; RECONFIGURE;') AT [{self.linked_server}]"
self.context.log.display(f"Enabling xp_cmdshell on {self.linked_server}...")
out=self.query_and_get_output(query)
out = self.query_and_get_output(query)
self.context.log.display(out)
self.context.log.success(f"xp_cmdshell enabled on {self.linked_server}")

Expand Down
7 changes: 4 additions & 3 deletions nxc/modules/link_xpcmd.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#Author:
# deathflamingo
class NXCModule:
"""Run xp_cmdshell commands on a linked SQL server"""
"""
Run xp_cmdshell commands on a linked SQL server
Module by deathflamingo
"""

name = "link_xpcmd"
description = "Run xp_cmdshell commands on a linked SQL server"
Expand Down
2 changes: 1 addition & 1 deletion nxc/modules/notepad++.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def options(self, context, module_options):

def on_admin_login(self, context, connection):
found = 0
for directory in connection.conn.listPath("C$", "Users\\*"):
for directory in connection.conn.listPath("C$", "Users\\*"):
if directory.get_longname() not in self.false_positive and directory.is_directory():
try:
notepad_backup_dir = f"Users\\{directory.get_longname()}\\AppData\\Roaming\\Notepad++\\backup\\"
Expand Down
10 changes: 3 additions & 7 deletions nxc/modules/powershell_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def options(self, _, module_options):
self.export = bool(module_options.get("EXPORT", False))

def on_admin_login(self, context, connection):
for directory in connection.conn.listPath("C$", "Users\\*"):
for directory in connection.conn.listPath("C$", "Users\\*"):
if directory.get_longname() not in self.false_positive and directory.is_directory():
try:
powershell_history_dir = f"Users\\{directory.get_longname()}\\AppData\\Roaming\\Microsoft\\Windows\\PowerShell\\PSReadLine\\"
Expand All @@ -37,12 +37,8 @@ def on_admin_login(self, context, connection):
connection.conn.getFile("C$", file_path, buf.write)
buf.seek(0)
file_content = buf.read().decode("utf-8", errors="ignore").lower()
keywords = []
for keyword in self.sensitive_keywords:
if keyword in file_content:
keywords.append(keyword.upper())

if keyword:
keywords = [keyword.upper() for keyword in self.sensitive_keywords if keyword in file_content]
if len(keywords):
context.log.highlight(f"C:\\{file_path} [ {' '.join(keywords)} ]")
else:
context.log.highlight(f"C:\\{file_path}")
Expand Down
2 changes: 1 addition & 1 deletion nxc/modules/shadowrdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def on_admin_login(self, context, connection):
remoteOps._RemoteOperations__rrp,
regHandle,
"Software\\Policies\\Microsoft\\Windows NT\\Terminal Services\\"
)['phkResult']
)["phkResult"]

# Checks if the key already exists or not
try:
Expand Down

0 comments on commit 2e1f225

Please sign in to comment.