Skip to content

Commit 4d8583e

Browse files
committed
Remove boilerplate
1 parent 5d3955b commit 4d8583e

1 file changed

Lines changed: 3 additions & 12 deletions

File tree

nxc/modules/link_xpcmd.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,6 @@ def on_login(self, context, connection):
3030
self.context.log.fail("Please provide both LINKED_SERVER and CMD options.")
3131
return
3232

33-
self.run_xp_cmdshell(self.command)
34-
35-
def run_xp_cmdshell(self, cmd):
36-
"""Run the specified command via xp_cmdshell on the linked server."""
37-
query = f"EXEC ('xp_cmdshell ''{cmd}''') AT [{self.linked_server}]"
38-
self.context.log.display(f"Running command on {self.linked_server}: {cmd}")
39-
result = self.query_and_get_output(query)
40-
self.context.log.success(f"Command output:\n{result}")
41-
42-
def query_and_get_output(self, query):
43-
"""Executes a query and returns the output."""
44-
return self.mssql_conn.sql_query(query)
33+
self.context.log.display(f"Running command on {self.linked_server}: {self.command}")
34+
result = self.mssql_conn.sql_query(f"EXEC ('xp_cmdshell ''{self.command}''') AT [{self.linked_server}]")
35+
self.context.log.success(f"Command output: {result}")

0 commit comments

Comments
 (0)