29 lines
1006 B
29 lines
1006 B
2 months ago
|
from tools.ToolBase import ToolBase
|
||
|
import re
|
||
|
import json
|
||
|
class SearchsploitTool(ToolBase):
|
||
|
def validate_instruction(self, instruction):
|
||
|
#指令过滤
|
||
|
timeout = 0
|
||
|
return instruction,timeout
|
||
|
|
||
|
def analyze_result(self, result,instruction,stderr,stdout):
|
||
|
"""去除 ANSI 颜色码"""
|
||
|
ansi_escape = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')
|
||
|
clean_result = ansi_escape.sub('', result)
|
||
|
#指令结果分析
|
||
|
lines = clean_result.split("\n")
|
||
|
exploits = []
|
||
|
|
||
|
for line in lines:
|
||
|
match = re.match(r"(.+?)\s+\|\s+(\S+)", line)
|
||
|
if match:
|
||
|
title = match.group(1).strip()
|
||
|
path = match.group(2).strip()
|
||
|
exploits.append({"title": title, "path": path})
|
||
|
|
||
|
if len(exploits) > 0:
|
||
|
result = json.dumps(exploits) #需要转化成字符串-必须
|
||
|
else:
|
||
|
result = "没有检索到漏洞利用脚本"
|
||
|
return result
|