{"record":{"id":"9c89584752959700","repo":"shadow1ng/fscan","slug":"ms17010-set-timeout-error-w","errorCode":null,"errorMessage":"ms17010_set_timeout_error: %w","messagePattern":"ms17010_set_timeout_error: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/services/ms17010.go","lineNumber":301,"sourceCode":"\t\tcommon.LogError(i18n.Tr(\"ms17010_pipe_decode_error\", err))\n\t\treturn\n\t}\n}\n\n// 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","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/plugins/services/ms17010.go#L283-L319","documentation":"Immediately after connecting, checkMS17010VulnerabilityAt calls conn.SetDeadline to bound the whole probe; if SetDeadline itself errors, the failure is wrapped as \"ms17010_set_timeout_error\". This is rare and only happens when the connection is already dead or the deadline value is invalid.","triggerScenarios":"conn.SetDeadline(time.Now().Add(timeout)) returns an error because the TCP connection was closed between DialTCP and SetDeadline (e.g. RST race), or the net.Conn implementation doesn't support deadlines (not the case for real TCP conns).","commonSituations":"Target resets the connection immediately after accept (inline IPS/firewall), extremely aggressive timeouts of zero/negative values from misconfigured ModuleTimeout, or resource exhaustion closing the fd.","solutions":["Inspect the wrapped error; 'use of closed network connection' means the peer or stack killed the conn — retry or treat as connection failure.","Ensure session.Config.ModuleTimeout() returns a positive duration; fix the timeout configuration.","Retry the probe once; an immediate RST race is usually transient.","If it persists, verify no middlebox is resetting connections to port 445."],"exampleFix":"// before\nconfig := loadConfig() // ModuleTimeout possibly 0\n// after: guarantee a sane timeout\nif session.Config.ModuleTimeout() <= 0 {\n    session.Config.SetModuleTimeout(10 * time.Second)\n}","handlingStrategy":"retry","validationCode":"if session.Config.ModuleTimeout() <= 0 { return fmt.Errorf(\"ModuleTimeout must be positive\") }","typeGuard":null,"tryCatchPattern":"if err != nil {\n    if strings.Contains(err.Error(), \"closed network connection\") {\n        return retryProbe(ctx, address, session) // transient RST race\n    }\n    return err\n}","preventionTips":["Configure a positive, sane ModuleTimeout (e.g. 10s)","Retry probes once to absorb transient connection resets","Watch for middleboxes RST-ing SMB connections"],"tags":["go","network","tcp","deadline","timeout","ms17010"],"backgroundTag":"request-timeout","analyzedSha":"95cc12e753bf43de7004e5aef42a9ffba3934303","analyzedAt":"2026-09-06T17:07:30.094Z","contentChangedAt":"2026-09-06T17:07:30.094Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}