@@ -103,7 +103,7 @@ def __xpCmdshellTest(self):
103103 threadData .disableStdOut = True
104104
105105 logger .info ("testing if xp_cmdshell extended procedure is usable" )
106- output = self .evalCmd ("echo 1" )
106+ output = self .xpCmdshellEvalCmd ("echo 1" )
107107
108108 if isNoneValue (output ):
109109 errMsg = "it seems that the temporary directory ('%s') used for " % self .getRemoteTempPath ()
@@ -179,15 +179,18 @@ def xpCmdshellEvalCmd(self, cmd, first=None, last=None):
179179 else :
180180 inject .goStacked (self .xpCmdshellForgeCmd (cmd , self .cmdTblName ))
181181 query = "SELECT %s FROM %s" % (self .tblField , self .cmdTblName )
182- if any (isTechniqueAvailable (_ ) for _ in (PAYLOAD .TECHNIQUE .UNION , PAYLOAD .TECHNIQUE .ERROR )) or conf .direct :
182+
183+ if conf .direct or any (isTechniqueAvailable (_ ) for _ in (PAYLOAD .TECHNIQUE .UNION , PAYLOAD .TECHNIQUE .ERROR )):
183184 output = inject .getValue (query , resumeValue = False , blind = False )
184185 else :
185186 output = []
186187 count = inject .getValue ("SELECT COUNT(*) FROM %s" % self .cmdTblName , resumeValue = False , inband = False , error = False , expected = EXPECTED .INT , charsetType = CHARSET_TYPE .DIGITS )
188+
187189 if isNumPosStrValue (count ):
188190 for index in getLimitRange (count ):
189191 query = agent .limitQuery (index , query , self .tblField )
190192 output .append (inject .getValue (query , inband = False , error = False , resumeValue = False ))
193+
191194 inject .goStacked ("DELETE FROM %s" % self .cmdTblName )
192195
193196 if output and isListLike (output ) and len (output ) > 1 :
@@ -196,6 +199,8 @@ def xpCmdshellEvalCmd(self, cmd, first=None, last=None):
196199 elif not output [- 1 ].strip ():
197200 output = output [:- 1 ]
198201
202+ output = "\n " .join (line for line in output )
203+
199204 return output
200205
201206 def xpCmdshellInit (self ):
0 commit comments