You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
self.logger.debug(f"Concatenated result together for easier parsing: {result}")
24
-
# if you prepend SilentlyContinue it will still output the error, but it will still continue on (so it's not silent...)
25
32
if"Preparing modules for first use"inresultand"Completed"notinresult:
26
33
self.logger.error("Error when executing PowerShell (received 'preparing modules for first use'), try prepending $ProgressPreference = 'SilentlyContinue'; to your command")
27
34
exceptExceptionase:
28
35
self.logger.error(f"Error when attempting to execute command via xp_cmdshell: {e}")
29
36
30
37
try:
31
-
self.logger.debug("Attempting to disable xp cmd shell")
32
-
self.disable_xp_cmdshell()
38
+
ifnotxp_cmdshell_was_enabled:
39
+
self.logger.debug("xp_cmdshell was not enabled originally, attempting to disable it.")
40
+
self.disable_xp_cmdshell()
41
+
else:
42
+
self.logger.debug("xp_cmdshell was originally enabled, leaving it enabled.")
33
43
exceptExceptionase:
34
44
self.logger.error(f"[OPSEC] Error when attempting to disable xp_cmdshell: {e}")
45
+
35
46
returnresult
36
47
48
+
defis_xp_cmdshell_enabled(self):
49
+
query="EXEC sp_configure 'xp_cmdshell';"
50
+
self.logger.debug(f"Checking if xp_cmdshell is enabled: {query}")
51
+
result=self.mssql_conn.sql_query(query)
52
+
# Assuming the query returns a list of dictionaries with 'config_value' as the key
0 commit comments