mirror of
https://github.com/shadow1ng/fscan.git
synced 2025-09-14 14:06:44 +08:00
fix: 修复指定host:port时缺少端口开放信息显示的问题
问题: - 使用 ./fscan -h 127.0.0.1:22 时没有显示端口开放信息 - 直接跳到漏洞扫描阶段,缺少端口发现过程的可见性 - 原因:预设host:port直接return,跳过了EnhancedPortScan调用 修复方案: - 新增 validatePresetPorts 方法 - 对预设的host:port也执行端口验证和服务识别 - 调用 EnhancedPortScan 显示完整的端口开放信息 修复前: [0ms] 开始主机扫描 → [0ms] 存活端口数量: 1 → [0ms] 开始漏洞扫描 修复后: [0ms] 开始主机扫描 → [5ms] 端口开放 127.0.0.1:22 [ssh] → [5ms] 开始漏洞扫描 效果: - 保持了统一的扫描流程显示 - 用户能看到端口连通性验证过程 - 预设端口也显示服务识别结果
This commit is contained in:
parent
3b50f42474
commit
31e59c9bee
@ -60,9 +60,9 @@ func (p *PortDiscoveryService) shouldPerformLivenessCheck(hosts []string) bool {
|
||||
func (p *PortDiscoveryService) discoverAlivePorts(hosts []string) []string {
|
||||
var alivePorts []string
|
||||
|
||||
// 如果已经有明确指定的host:port,则优先使用并跳过常规端口扫描
|
||||
// 如果已经有明确指定的host:port,验证连通性并显示端口信息
|
||||
if len(common.HostPort) > 0 {
|
||||
alivePorts = append(alivePorts, common.HostPort...)
|
||||
alivePorts = p.validatePresetPorts(common.HostPort)
|
||||
alivePorts = common.RemoveDuplicate(alivePorts)
|
||||
common.LogBase(i18n.GetText("scan_alive_ports_count", len(alivePorts)))
|
||||
common.HostPort = nil
|
||||
@ -131,3 +131,30 @@ func (p *PortDiscoveryService) handleUDPPorts(hosts []string) []string {
|
||||
|
||||
return udpPorts
|
||||
}
|
||||
|
||||
// validatePresetPorts 验证预设的host:port并显示端口信息(模拟端口扫描过程)
|
||||
func (p *PortDiscoveryService) validatePresetPorts(hostPorts []string) []string {
|
||||
var validPorts []string
|
||||
|
||||
for _, hostPort := range hostPorts {
|
||||
// 解析host:port
|
||||
hostParts := strings.Split(hostPort, ":")
|
||||
if len(hostParts) != 2 {
|
||||
continue
|
||||
}
|
||||
|
||||
host := hostParts[0]
|
||||
port := hostParts[1]
|
||||
|
||||
// 模拟单端口扫描,显示端口开放信息和服务识别
|
||||
mockHosts := []string{host}
|
||||
portResult := EnhancedPortScan(mockHosts, port, common.Timeout)
|
||||
|
||||
// 如果端口验证成功,添加到结果中
|
||||
if len(portResult) > 0 {
|
||||
validPorts = append(validPorts, portResult...)
|
||||
}
|
||||
}
|
||||
|
||||
return validPorts
|
||||
}
|
Loading…
Reference in New Issue
Block a user