Skip to content

Commit 2e1f225

Browse files
authored
Merge pull request Pennyw0rth#506 from Pennyw0rth/ruff
fix ruff
2 parents a284b00 + 4c9db0a commit 2e1f225

9 files changed

Lines changed: 35 additions & 35 deletions

File tree

nxc/modules/enum_impersonate.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
#Author:
2-
# deathflamingo
31
class NXCModule:
4-
"""Enumerate SQL Server users with impersonation rights"""
2+
"""
3+
Enumerate SQL Server users with impersonation rights
4+
Module by deathflamingo
5+
"""
56

67
name = "enum_impersonate"
78
description = "Enumerate users with impersonation privileges"
@@ -28,7 +29,7 @@ def get_impersonate_users(self) -> list:
2829
"""
2930
Fetches a list of users with impersonation rights.
3031
31-
Returns:
32+
Returns
3233
-------
3334
list: List of user names.
3435
"""

nxc/modules/enum_links.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
#Author:
2-
# deathflamingo
31
class NXCModule:
4-
"""Enumerate SQL Server linked servers"""
2+
"""
3+
Enumerate SQL Server linked servers
4+
Module by deathflamingo
5+
"""
56

67
name = "enum_links"
78
description = "Enumerate linked SQL Servers"
@@ -28,7 +29,7 @@ def get_linked_servers(self) -> list:
2829
"""
2930
Fetches a list of linked servers.
3031
31-
Returns:
32+
Returns
3233
-------
3334
list: List of linked server names.
3435
"""

nxc/modules/enum_logins.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
#Author:
2-
# deathflamingo
31
class NXCModule:
4-
"""Enumerate SQL Server logins"""
2+
"""
3+
Enumerate SQL Server logins
4+
Module by deathflamingo
5+
"""
56

67
name = "enum_logins"
78
description = "Enumerate SQL Server logins"
@@ -28,7 +29,7 @@ def get_logins(self) -> list:
2829
"""
2930
Fetches a list of SQL Server logins.
3031
31-
Returns:
32+
Returns
3233
-------
3334
list: List of login names.
3435
"""

nxc/modules/exec_on_link.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
#Author:
2-
# deathflamingo
31
class NXCModule:
4-
"""Execute commands on linked servers"""
2+
"""
3+
Execute commands on linked servers
4+
Module by deathflamingo
5+
"""
56

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

3738
def execute_on_link(self):
38-
"""
39-
Executes the specified command on the linked server.
40-
"""
39+
"""Executes the specified command on the linked server."""
4140
query = f"EXEC ('{self.command}') AT [{self.linked_server}];"
4241
result = self.mssql_conn.sql_query(query)
4342
self.context.log.display(f"Command output: {result}")

nxc/modules/link_enable_xp.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
#Author:
2-
# deathflamingo
31
class NXCModule:
4-
"""Enable or disable xp_cmdshell on a linked SQL server"""
2+
"""
3+
Enable or disable xp_cmdshell on a linked SQL server
4+
Module by deathflamingo
5+
"""
56

67
name = "link_enable_xp"
78
description = "Enable or disable xp_cmdshell on a linked SQL server"
@@ -43,10 +44,10 @@ def enable_xp_cmdshell(self):
4344
"""Enable xp_cmdshell on the linked server."""
4445
query = f"EXEC ('sp_configure ''show advanced options'', 1; RECONFIGURE;') AT [{self.linked_server}]"
4546
self.context.log.display(f"Enabling advanced options on {self.linked_server}...")
46-
out=self.query_and_get_output(query)
47+
out = self.query_and_get_output(query)
4748
query = f"EXEC ('sp_configure ''xp_cmdshell'', 1; RECONFIGURE;') AT [{self.linked_server}]"
4849
self.context.log.display(f"Enabling xp_cmdshell on {self.linked_server}...")
49-
out=self.query_and_get_output(query)
50+
out = self.query_and_get_output(query)
5051
self.context.log.display(out)
5152
self.context.log.success(f"xp_cmdshell enabled on {self.linked_server}")
5253

nxc/modules/link_xpcmd.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
#Author:
2-
# deathflamingo
31
class NXCModule:
4-
"""Run xp_cmdshell commands on a linked SQL server"""
2+
"""
3+
Run xp_cmdshell commands on a linked SQL server
4+
Module by deathflamingo
5+
"""
56

67
name = "link_xpcmd"
78
description = "Run xp_cmdshell commands on a linked SQL server"

nxc/modules/notepad++.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def options(self, context, module_options):
2020

2121
def on_admin_login(self, context, connection):
2222
found = 0
23-
for directory in connection.conn.listPath("C$", "Users\\*"):
23+
for directory in connection.conn.listPath("C$", "Users\\*"):
2424
if directory.get_longname() not in self.false_positive and directory.is_directory():
2525
try:
2626
notepad_backup_dir = f"Users\\{directory.get_longname()}\\AppData\\Roaming\\Notepad++\\backup\\"

nxc/modules/powershell_history.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def options(self, _, module_options):
2525
self.export = bool(module_options.get("EXPORT", False))
2626

2727
def on_admin_login(self, context, connection):
28-
for directory in connection.conn.listPath("C$", "Users\\*"):
28+
for directory in connection.conn.listPath("C$", "Users\\*"):
2929
if directory.get_longname() not in self.false_positive and directory.is_directory():
3030
try:
3131
powershell_history_dir = f"Users\\{directory.get_longname()}\\AppData\\Roaming\\Microsoft\\Windows\\PowerShell\\PSReadLine\\"
@@ -37,12 +37,8 @@ def on_admin_login(self, context, connection):
3737
connection.conn.getFile("C$", file_path, buf.write)
3838
buf.seek(0)
3939
file_content = buf.read().decode("utf-8", errors="ignore").lower()
40-
keywords = []
41-
for keyword in self.sensitive_keywords:
42-
if keyword in file_content:
43-
keywords.append(keyword.upper())
44-
45-
if keyword:
40+
keywords = [keyword.upper() for keyword in self.sensitive_keywords if keyword in file_content]
41+
if len(keywords):
4642
context.log.highlight(f"C:\\{file_path} [ {' '.join(keywords)} ]")
4743
else:
4844
context.log.highlight(f"C:\\{file_path}")

nxc/modules/shadowrdp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def on_admin_login(self, context, connection):
3838
remoteOps._RemoteOperations__rrp,
3939
regHandle,
4040
"Software\\Policies\\Microsoft\\Windows NT\\Terminal Services\\"
41-
)['phkResult']
41+
)["phkResult"]
4242

4343
# Checks if the key already exists or not
4444
try:

0 commit comments

Comments
 (0)