shadow1ng/fscan · error
ms17010_connection_error: %w
Error message
ms17010_connection_error: %w
What it means
checkMS17010VulnerabilityAt wraps the DialTCP failure to the target's port 445 with "ms17010_connection_error" plus the underlying OS error. The MS17-010 probe cannot even establish a TCP connection, so no vulnerability assessment is possible and Scan/Exploit surface this wrapped error.
Source
Thrown at plugins/services/ms17010.go:296
common.LogError(i18n.Tr("ms17010_pipe_decrypt_error", err))
return
}
trans2SessionSetupRequest, err = hex.DecodeString(decrypted)
if err != nil {
common.LogError(i18n.Tr("ms17010_pipe_decode_error", err))
return
}
}
// checkMS17010Vulnerability 检测MS17-010漏洞 (从原始MS17010.go复制和适配)
func (p *MS17010Plugin) checkMS17010Vulnerability(ctx context.Context, ip string, session *common.ScanSession) (bool, string, bool, error) {
return p.checkMS17010VulnerabilityAt(ctx, net.JoinHostPort(ip, "445"), session)
}
func (p *MS17010Plugin) checkMS17010VulnerabilityAt(ctx context.Context, address string, session *common.ScanSession) (bool, string, bool, error) {
conn, err := session.DialTCP(ctx, "tcp", address, session.Config.ModuleTimeout())
if err != nil {
return false, "", false, fmt.Errorf("%s: %w", i18n.GetText("ms17010_connection_error"), err)
}
defer func() { _ = conn.Close() }()
if err = conn.SetDeadline(time.Now().Add(session.Config.ModuleTimeout())); err != nil {
return false, "", false, fmt.Errorf("%s: %w", i18n.GetText("ms17010_set_timeout_error"), err)
}
// SMB协议协商
if _, err = conn.Write(negotiateProtocolRequest); err != nil {
return false, "", false, fmt.Errorf("%s: %w", i18n.GetText("ms17010_send_protocol_error"), err)
}
reply := make([]byte, 1024)
n, readErr := conn.Read(reply)
if readErr != nil || n < 36 {
// 连接被关闭或响应不完整,通常表示目标不支持SMBv1
return false, "", false, fmt.Errorf("%s", i18n.GetText("ms17010_smbv1_unsupported"))
}View on GitHub (pinned to 95cc12e753)
Solutions
- Check the unwrapped cause (errors.Unwrap): 'connection refused' means host up but 445 closed; 'i/o timeout'/'no route to host' means network/firewall.
- Verify port 445 is open from the scanner host: nc -vz <ip> 445 or nmap -p445 <ip>.
- Exclude unreachable hosts from the MS17-10 scan list or pre-check connectivity with the same DialTCP call.
- Fix routing/firewall: allow inbound 445 on the target or run the scanner from a network segment with access.
Example fix
// before: treating all failures the same
res := plugin.Scan(ctx, host, session)
if res.Error != nil { log.Fatal(res.Error) }
// after: distinguish connection errors
if res.Error != nil && strings.Contains(res.Error.Error(), "connection") {
log.Printf("host %s unreachable on 445, skipping", host.Host)
} else if res.Error != nil {
log.Printf("probe error: %v", res.Error)
} Defensive patterns
Strategy: retry
Validate before calling
conn, err := net.DialTimeout("tcp", net.JoinHostPort(host, "445"), 3*time.Second)
if err != nil { return fmt.Errorf("%s:445 unreachable, skipping ms17010", host) }
_ = conn.Close() Try / catch
if err != nil {
var netErr net.Error
if errors.As(err, &netErr) && netErr.Timeout() {
return fmt.Errorf("target 445 filtered/timeout: %w", err)
}
return err
} Prevention
- Pre-check port 445 reachability before running the plugin
- Classify refused vs timeout vs no-route to decide skip vs retry
- Keep scanner and targets on routable networks (VPN up, firewall allows 445)
When it happens
Trigger: session.DialTCP(ctx, "tcp", ip:445, timeout) fails because the port is closed, the host is down/unreachable, a firewall drops the SYN, or DNS/routing for the IP is wrong.
Common situations: Scanning hosts where SMB (445) is firewalled, scanning offline machines, wrong subnet/VPN not connected, or Windows Defender Firewall blocking inbound 445 from the scanner.
Understand the failure class
Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.
Related errors
- ms17010_set_timeout_error: %w
- ms17010_send_protocol_error: %w
- MS17-010 exp failed: %w
- failed to connect host: %s
- service_target_unreachable: %w
AI-assisted analysis of shadow1ng/fscan@95cc12e753 (2026-09-06).
Data as JSON: /api/errors/2ddb13dca3aeceaa.
Report an issue: GitHub.