{"record":{"id":"898930416d7dfc01","repo":"shadow1ng/fscan","slug":"ms17010-send-protocol-error-w","errorCode":null,"errorMessage":"ms17010_send_protocol_error: %w","messagePattern":"ms17010_send_protocol_error: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/services/ms17010.go","lineNumber":306,"sourceCode":"// checkMS17010Vulnerability 检测MS17-010漏洞 (从原始MS17010.go复制和适配)\nfunc (p *MS17010Plugin) checkMS17010Vulnerability(ctx context.Context, ip string, session *common.ScanSession) (bool, string, bool, error) {\n\treturn p.checkMS17010VulnerabilityAt(ctx, net.JoinHostPort(ip, \"445\"), session)\n}\n\nfunc (p *MS17010Plugin) checkMS17010VulnerabilityAt(ctx context.Context, address string, session *common.ScanSession) (bool, string, bool, error) {\n\tconn, err := session.DialTCP(ctx, \"tcp\", address, session.Config.ModuleTimeout())\n\tif err != nil {\n\t\treturn false, \"\", false, fmt.Errorf(\"%s: %w\", i18n.GetText(\"ms17010_connection_error\"), err)\n\t}\n\tdefer func() { _ = conn.Close() }()\n\n\tif err = conn.SetDeadline(time.Now().Add(session.Config.ModuleTimeout())); err != nil {\n\t\treturn false, \"\", false, fmt.Errorf(\"%s: %w\", i18n.GetText(\"ms17010_set_timeout_error\"), err)\n\t}\n\n\t// SMB协议协商\n\tif _, err = conn.Write(negotiateProtocolRequest); err != nil {\n\t\treturn false, \"\", false, fmt.Errorf(\"%s: %w\", i18n.GetText(\"ms17010_send_protocol_error\"), err)\n\t}\n\n\treply := make([]byte, 1024)\n\tn, readErr := conn.Read(reply)\n\tif readErr != nil || n < 36 {\n\t\t// 连接被关闭或响应不完整，通常表示目标不支持SMBv1\n\t\treturn false, \"\", false, fmt.Errorf(\"%s\", i18n.GetText(\"ms17010_smbv1_unsupported\"))\n\t}\n\n\tif binary.LittleEndian.Uint32(reply[9:13]) != 0 {\n\t\treturn false, \"\", false, fmt.Errorf(\"%s\", i18n.GetText(\"ms17010_smbv1_rejected\"))\n\t}\n\n\t// 建立会话\n\tif _, err = conn.Write(sessionSetupRequest); err != nil {\n\t\treturn false, \"\", false, fmt.Errorf(\"%s: %w\", i18n.GetText(\"ms17010_send_session_error\"), err)\n\t}\n","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/plugins/services/ms17010.go#L288-L324","documentation":"During SMB negotiation, checkMS17010VulnerabilityAt writes the negotiateProtocolRequest packet and wraps any conn.Write failure as \"ms17010_send_protocol_error\". The probe cannot deliver the SMBv1 negotiation, so the vulnerability check aborts with this error propagated to Scan/Exploit.","triggerScenarios":"conn.Write(negotiateProtocolRequest) fails because the peer closed/reset the connection right after connect, the network dropped mid-session, or the context deadline expired killing the conn.","commonSituations":"Firewalls/IPS that accept the TCP handshake then RST the SMB payload, targets rejecting SMBv1 traffic immediately, or unstable Wi-Fi/VPN links during the scan.","solutions":["Unwrap the error: 'broken pipe'/'connection reset by peer' indicates the target or a middlebox killed the connection — treat as 'SMB not reachable' rather than a bug.","Retry once after a short delay; transient resets are common on noisy networks.","Verify with nmap -p445 --script smb-protocols that the target accepts SMB negotiation at all.","Increase ModuleTimeout if deadline-expired errors appear under load."],"exampleFix":"// before: hard failure on transient write error\nres := plugin.Scan(ctx, host, session)\nif res.Error != nil { log.Fatal(res.Error) }\n// after: tolerate transient SMB send failures\nif res.Error != nil && strings.Contains(res.Error.Error(), \"protocol\") {\n    log.Printf(\"SMB negotiation failed for %s, host may block SMBv1\", host.Host)\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err != nil {\n    if errors.Is(err, syscall.EPIPE) || errors.Is(err, syscall.ECONNRESET) {\n        return fmt.Errorf(\"target dropped SMB negotiation, treating as unreachable\")\n    }\n    return err\n}","preventionTips":["Retry the negotiation once on reset/broken-pipe errors","Confirm targets actually accept SMBv1 before scanning (smb-protocols probe)","Increase timeouts under high network load"],"tags":["go","network","smb","broken-pipe","ms17010"],"backgroundTag":"broken-pipe","analyzedSha":"95cc12e753bf43de7004e5aef42a9ffba3934303","analyzedAt":"2026-09-06T17:07:30.094Z","contentChangedAt":"2026-09-06T17:07:30.094Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}