mirror of
https://github.com/shadow1ng/fscan.git
synced 2025-09-14 14:06:44 +08:00

主要改进: - 创建BaseScanStrategy基础类提取通用功能,减少60%代码重复 - 新增PortDiscoveryService分离端口发现逻辑,提升职责清晰度 - 优化插件匹配算法,从O(n×m×p)降至O(n×p)复杂度 - 修复插件适用性判断逻辑错误,确保精确端口匹配 - 完善国际化支持,新增21个i18n消息定义 - 代码行数显著减少:LocalScanner(-50%)、ServiceScanner(-42%)、WebScanner(-44%) 技术优化: - 组合模式替代继承,提升扩展性 - 策略模式实现插件过滤器,支持Local/Service/Web类型 - 服务分离提升可测试性和维护性 - 性能优化减少嵌套循环和重复计算 确保漏洞扫描插件列表与实际执行插件保持精确一致。
283 lines
8.0 KiB
Go
283 lines
8.0 KiB
Go
package messages
|
||
|
||
/*
|
||
parse.go - 解析相关消息
|
||
|
||
包含参数解析、目标解析、凭据解析等相关的
|
||
国际化消息定义。
|
||
*/
|
||
|
||
// ParseMessages 解析相关消息
|
||
var ParseMessages = map[string]map[string]string{
|
||
// ========================= 解析错误消息 =========================
|
||
"parse_error_empty_input": {
|
||
LangZH: "输入参数为空",
|
||
LangEN: "Input parameters are empty",
|
||
},
|
||
"parse_error_config_failed": {
|
||
LangZH: "解析配置失败: %v",
|
||
LangEN: "Failed to parse configuration: %v",
|
||
},
|
||
"parse_error_parser_not_init": {
|
||
LangZH: "解析器未初始化",
|
||
LangEN: "Parser not initialized",
|
||
},
|
||
"parse_error_credential_failed": {
|
||
LangZH: "凭据解析失败: %v",
|
||
LangEN: "Failed to parse credentials: %v",
|
||
},
|
||
"parse_error_target_failed": {
|
||
LangZH: "目标解析失败: %v",
|
||
LangEN: "Failed to parse targets: %v",
|
||
},
|
||
"parse_error_network_failed": {
|
||
LangZH: "网络解析失败: %v",
|
||
LangEN: "Failed to parse network configuration: %v",
|
||
},
|
||
"parse_error_validation_failed": {
|
||
LangZH: "验证失败: %v",
|
||
LangEN: "Validation failed: %v",
|
||
},
|
||
"parse_error_update_vars_failed": {
|
||
LangZH: "更新全局变量失败: %v",
|
||
LangEN: "Failed to update global variables: %v",
|
||
},
|
||
"parse_error_target_empty": {
|
||
LangZH: "目标输入为空",
|
||
LangEN: "Target input is empty",
|
||
},
|
||
"parse_error_credential_empty": {
|
||
LangZH: "凭据输入为空",
|
||
LangEN: "Credential input is empty",
|
||
},
|
||
"parse_error_network_empty": {
|
||
LangZH: "网络配置为空",
|
||
LangEN: "Network configuration is empty",
|
||
},
|
||
"parse_error_invalid_ip": {
|
||
LangZH: "无效的IP地址: %s",
|
||
LangEN: "Invalid IP address: %s",
|
||
},
|
||
"parse_error_invalid_port": {
|
||
LangZH: "无效的端口: %s",
|
||
LangEN: "Invalid port: %s",
|
||
},
|
||
"parse_error_invalid_url": {
|
||
LangZH: "无效的URL: %s",
|
||
LangEN: "Invalid URL: %s",
|
||
},
|
||
"parse_error_file_not_found": {
|
||
LangZH: "文件未找到: %s",
|
||
LangEN: "File not found: %s",
|
||
},
|
||
"parse_error_file_read_failed": {
|
||
LangZH: "读取文件失败: %s",
|
||
LangEN: "Failed to read file: %s",
|
||
},
|
||
|
||
// ========================= 目标解析消息 =========================
|
||
"target_parse_start": {
|
||
LangZH: "开始解析目标",
|
||
LangEN: "Starting target parsing",
|
||
},
|
||
"target_parse_complete": {
|
||
LangZH: "目标解析完成",
|
||
LangEN: "Target parsing completed",
|
||
},
|
||
"target_hosts_found": {
|
||
LangZH: "目标主机: %s",
|
||
LangEN: "Target hosts: %s",
|
||
},
|
||
"target_hosts_count": {
|
||
LangZH: "目标主机: %s ... (共%d个)",
|
||
LangEN: "Target hosts: %s ... (total %d)",
|
||
},
|
||
"target_urls_found": {
|
||
LangZH: "目标URL: %s",
|
||
LangEN: "Target URLs: %s",
|
||
},
|
||
"target_urls_count": {
|
||
LangZH: "目标URL: %s ... (共%d个)",
|
||
LangEN: "Target URLs: %s ... (total %d)",
|
||
},
|
||
"target_ports_found": {
|
||
LangZH: "扫描端口: %s",
|
||
LangEN: "Scan ports: %s",
|
||
},
|
||
"target_ports_count": {
|
||
LangZH: "扫描端口: %s ... (共%d个)",
|
||
LangEN: "Scan ports: %s ... (total %d)",
|
||
},
|
||
"target_exclude_ports": {
|
||
LangZH: "排除端口: %s",
|
||
LangEN: "Exclude ports: %s",
|
||
},
|
||
"target_local_mode": {
|
||
LangZH: "本地扫描模式",
|
||
LangEN: "Local scan mode",
|
||
},
|
||
|
||
// ========================= 凭据相关消息 =========================
|
||
"credential_username_count": {
|
||
LangZH: "用户名数量: %d",
|
||
LangEN: "Username count: %d",
|
||
},
|
||
"credential_password_count": {
|
||
LangZH: "密码数量: %d",
|
||
LangEN: "Password count: %d",
|
||
},
|
||
"credential_hash_count": {
|
||
LangZH: "Hash数量: %d",
|
||
LangEN: "Hash count: %d",
|
||
},
|
||
|
||
// ========================= Parsers包专用消息 =========================
|
||
"parser_validation_input_empty": {
|
||
LangZH: "验证输入为空",
|
||
LangEN: "Validation input is empty",
|
||
},
|
||
"parser_empty_input": {
|
||
LangZH: "输入参数为空",
|
||
LangEN: "Input parameters are empty",
|
||
},
|
||
"parser_file_empty": {
|
||
LangZH: "文件名为空",
|
||
LangEN: "File name is empty",
|
||
},
|
||
"parser_file_too_big": {
|
||
LangZH: "文件过大: %d bytes, 最大限制: %d bytes",
|
||
LangEN: "File too large: %d bytes, max limit: %d bytes",
|
||
},
|
||
"parser_cannot_open_file": {
|
||
LangZH: "无法打开文件",
|
||
LangEN: "Cannot open file",
|
||
},
|
||
"parser_file_not_exists": {
|
||
LangZH: "文件不存在或无法访问",
|
||
LangEN: "File does not exist or cannot be accessed",
|
||
},
|
||
"parser_file_read_timeout": {
|
||
LangZH: "文件读取超时",
|
||
LangEN: "File read timeout",
|
||
},
|
||
"parser_file_scan_failed": {
|
||
LangZH: "文件扫描失败",
|
||
LangEN: "File scan failed",
|
||
},
|
||
"parser_username_too_long": {
|
||
LangZH: "用户名过长: %d字符,最大允许: %d",
|
||
LangEN: "Username too long: %d characters, max allowed: %d",
|
||
},
|
||
"parser_username_invalid_chars": {
|
||
LangZH: "用户名包含非法字符",
|
||
LangEN: "Username contains invalid characters",
|
||
},
|
||
"parser_password_empty": {
|
||
LangZH: "不允许空密码",
|
||
LangEN: "Empty passwords not allowed",
|
||
},
|
||
"parser_password_too_long": {
|
||
LangZH: "密码过长: %d字符,最大允许: %d",
|
||
LangEN: "Password too long: %d characters, max allowed: %d",
|
||
},
|
||
"parser_hash_empty": {
|
||
LangZH: "哈希值为空",
|
||
LangEN: "Hash value is empty",
|
||
},
|
||
"parser_hash_invalid_format": {
|
||
LangZH: "哈希值格式无效,需要32位十六进制字符",
|
||
LangEN: "Invalid hash format, requires 32-character hexadecimal",
|
||
},
|
||
"parser_proxy_url_invalid": {
|
||
LangZH: "代理URL格式无效: %v",
|
||
LangEN: "Invalid proxy URL format: %v",
|
||
},
|
||
"parser_proxy_protocol_unsupported": {
|
||
LangZH: "不支持的代理协议: %s",
|
||
LangEN: "Unsupported proxy protocol: %s",
|
||
},
|
||
"parser_proxy_host_empty": {
|
||
LangZH: "代理主机名为空",
|
||
LangEN: "Proxy hostname is empty",
|
||
},
|
||
"parser_proxy_port_invalid": {
|
||
LangZH: "代理端口号无效: %s",
|
||
LangEN: "Invalid proxy port: %s",
|
||
},
|
||
"parser_proxy_port_out_of_range": {
|
||
LangZH: "代理端口号超出范围: %d",
|
||
LangEN: "Proxy port out of range: %d",
|
||
},
|
||
"parser_proxy_insecure": {
|
||
LangZH: "不允许使用不安全的HTTP代理",
|
||
LangEN: "Insecure HTTP proxy not allowed",
|
||
},
|
||
"parser_user_agent_too_long": {
|
||
LangZH: "用户代理字符串过长",
|
||
LangEN: "User agent string too long",
|
||
},
|
||
"parser_user_agent_invalid_chars": {
|
||
LangZH: "用户代理包含非法字符",
|
||
LangEN: "User agent contains invalid characters",
|
||
},
|
||
"parser_cookie_too_long": {
|
||
LangZH: "Cookie字符串过长",
|
||
LangEN: "Cookie string too long",
|
||
},
|
||
"parser_error_count_limit": {
|
||
LangZH: "错误数量过多,仅显示前%d个",
|
||
LangEN: "Too many errors, showing only first %d",
|
||
},
|
||
"parser_no_scan_target": {
|
||
LangZH: "未指定任何扫描目标",
|
||
LangEN: "No scan targets specified",
|
||
},
|
||
"parser_no_target_default": {
|
||
LangZH: "未指定扫描目标,将使用默认配置",
|
||
LangEN: "No scan targets specified, using default configuration",
|
||
},
|
||
"parser_multiple_scan_modes": {
|
||
LangZH: "不能同时使用多种扫描模式",
|
||
LangEN: "Cannot use multiple scan modes simultaneously",
|
||
},
|
||
"parser_proxy_ping_warning": {
|
||
LangZH: "使用代理时建议禁用Ping检测",
|
||
LangEN: "Recommend disabling Ping detection when using proxy",
|
||
},
|
||
"parser_multiple_modes_conflict": {
|
||
LangZH: "不能同时指定多种扫描模式(主机扫描、URL扫描、本地模式)",
|
||
LangEN: "Cannot specify multiple scan modes (host scan, URL scan, local mode) simultaneously",
|
||
},
|
||
"parser_proxy_ping_fail": {
|
||
LangZH: "代理模式下Ping检测可能失效",
|
||
LangEN: "Ping detection may fail in proxy mode",
|
||
},
|
||
"parser_exclude_ports_invalid": {
|
||
LangZH: "排除端口无效",
|
||
LangEN: "Exclude ports invalid",
|
||
},
|
||
"parser_many_targets_warning": {
|
||
LangZH: "大量目标(%d),可能耗时较长",
|
||
LangEN: "Large number of targets (%d), may take a long time",
|
||
},
|
||
"parser_too_many_ports": {
|
||
LangZH: "端口数量过多",
|
||
LangEN: "Too many ports",
|
||
},
|
||
"parser_timeout_too_short": {
|
||
LangZH: "超时过短",
|
||
LangEN: "Timeout too short",
|
||
},
|
||
"parser_timeout_too_long": {
|
||
LangZH: "超时过长",
|
||
LangEN: "Timeout too long",
|
||
},
|
||
"parser_invalid_scan_mode": {
|
||
LangZH: "无效的扫描模式: %s",
|
||
LangEN: "Invalid scan mode: %s",
|
||
},
|
||
"parse_error_invalid_target_format": {
|
||
LangZH: "无效的目标地址格式: %s",
|
||
LangEN: "Invalid target address format: %s",
|
||
},
|
||
} |