You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
969 B
31 lines
969 B
# Hping3工具类
|
|
from tools.ToolBase import ToolBase
|
|
|
|
class Hping3Tool(ToolBase):
|
|
def validate_instruction(self, instruction):
|
|
'''
|
|
hping3指令过滤,过滤规则
|
|
1.需要有-c,若没有则添加-c 5 指定发包5次
|
|
2.--flood 以最大速度发送数据包,需要禁止
|
|
:param instruction:
|
|
:return:
|
|
'''
|
|
timeout = 0
|
|
# 拆分原始指令为列表
|
|
cmd_parts = instruction.split()
|
|
|
|
# 过滤掉--flood参数
|
|
filtered_parts = [part for part in cmd_parts if part != "--flood"]
|
|
|
|
# 检查是否包含-c参数
|
|
has_c_flag = "-c" in filtered_parts
|
|
if not has_c_flag:
|
|
# 添加-c 5到指令末尾
|
|
filtered_parts.extend(["-c", "10"])
|
|
|
|
# 重组为字符串
|
|
return " ".join(filtered_parts),timeout
|
|
|
|
def analyze_result(self, result,instruction,stderr,stdout):
|
|
#hping3 原结果返回
|
|
return result
|