Skip to content

Commit

Permalink
fix ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
mpgn committed Dec 17, 2024
1 parent 277a78c commit 4c9db0a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 26 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

0 comments on commit 4c9db0a

Please sign in to comment.