EDITED: я нашел решение, посмотрев на длину возвращаемого вывода, как показано ниже.
try:
exitcode, output = subprocess.getstatusoutput(command)
print(exitcode)
if exitcode == 0:
print("INFO : XSSStrike tool is running successfully ...")
if len(output) == 32:
print('XSS injection check : \' results:\' \'' "None" '\'' + \
' ... [ ' + self.OKGREEN + 'OK' + self.endColor + ' ]')
else:
print(
'XSS injection check : \' results:\' \''" found vulnerable pages to xss injection " '\'' + \
' ... [ ' + self.WARNING + 'WARN' + self.endColor + ' ]')
self.nm_of_fails += 1
print(str(output))
Я использую этот метод для автоматизации - перейдите к заданному пути инструмента - прочтите JSON config - получить результаты от инструмента - оценить результаты
это фрагмент метода, в котором я использую подпроцесс для запуска команды cmd, эта команда имеет параметры для инструмента для фильтрации вывода консоли, который возвращается в (tooloutput = subprocess.getoutput (command))
depth = value["crawl-depth"]
if self.cookie == '':
command = "cd " + tool_path + " && python xsstrike.py -u " + url + " --params --crawl -l " + depth + " --skip --blind --file-log-level VULN --console-log-level VULN --log-file " + formatName
else:
cookie_para = f'"cookie:{self.cookie}"'
command = "cd " + tool_path + " && python xsstrike.py -u " + url + " --header " + cookie_para + " --params --crawl -l " + depth + " --skip --blind --file-log-level VULN --console-log-level VULN --log-file " + formatName
tooloutput = subprocess.getoutput(command)
if len(tooloutput) != 0:
print("INFO: XSSStrike TOOL FULL RESULTS: " + tooloutput)
else:
print("no results ")
почему длина toolouput равна нулю? когда инструмент завершает работу, автоматически ли завершается подпроцесс?