{"record":{"id":"7c488783756720ec","repo":"shadow1ng/fscan","slug":"smb-probe-failed-w","errorCode":null,"errorMessage":"smb_probe_failed: %w","messagePattern":"smb_probe_failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/services/smb.go","lineNumber":47,"sourceCode":"\tstate := session.State\n\ttarget := info.Target()\n\n\t// 检查端口\n\tif info.Port != 445 && info.Port != 139 {\n\t\treturn &ScanResult{\n\t\t\tSuccess: false,\n\t\t\tService: \"smb\",\n\t\t\tError:   fmt.Errorf(\"%s\", i18n.GetText(\"smb_port_only\")),\n\t\t}\n\t}\n\n\t// 1. 协议探测和信息收集\n\tsmbTarget, err := probeTarget(ctx, info.Host, info.Port, config.ModuleTimeout(), session)\n\tif err != nil {\n\t\treturn &ScanResult{\n\t\t\tSuccess: false,\n\t\t\tService: \"smb\",\n\t\t\tError:   fmt.Errorf(\"%s: %w\", i18n.GetText(\"smb_probe_failed\"), err),\n\t\t}\n\t}\n\n\t// 输出信息收集结果\n\tp.logSMBInfo(target, smbTarget, session)\n\n\t// 2. 漏洞检测 (仅SMBv2+且端口445)\n\tif smbTarget.Protocol == SMBProtocol2 && info.Port == 445 {\n\t\tif checkSMBGhost(ctx, info.Host, config.ModuleTimeout(), session) {\n\t\t\tsmbTarget.Vulnerable = &SMBVuln{CVE20200796: true}\n\t\t\tsession.LogVuln(i18n.Tr(\"smbghost_vuln\", target))\n\t\t}\n\t}\n\n\t// 如果禁用暴力破解，只返回信息收集结果\n\tif config.DisableBrute {\n\t\treturn p.buildInfoResult(smbTarget)\n\t}","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/plugins/services/smb.go#L29-L65","documentation":"After the port check, Scan calls probeTarget to negotiate an SMB session and gather protocol/OS information. Any error from probeTarget is wrapped as \"smb_probe_failed: <cause>\" using %w so the underlying cause (dial failure, negotiation failure, timeout) remains retrievable via errors.Unwrap/Is/As. It means the SMB protocol probe itself failed, not merely the port check.","triggerScenarios":"probeTarget returns an error — DialTCP failure, no SMB dialect negotiated (host is not SMB), session setup rejected at the protocol level, or deadline exceeded — and Scan wraps it with i18n.GetText(\"smb_probe_failed\") at smb.go:47.","commonSituations":"Port open (from a prior TCP check) but the service is not SMB; SMBv1 disabled on modern Windows and the probe can't agree on SMB2/3; firewall allowing SYN but resetting SMB traffic; host firewall or tarpit causing timeouts.","solutions":["Inspect the wrapped cause with errors.Unwrap / %v of the returned error to see if it is dial, negotiation, or timeout.","Confirm the port truly speaks SMB (nmap --script smb-* or smbclient -L //<host>).","Ensure the client supports SMB2/SMB3 since SMBv1 is commonly disabled.","Raise the probe timeout for high-latency links and verify no middlebox resets the session."],"exampleFix":"// before\nerr == nil assumption; log only \"smb_probe_failed\" // hides cause\n// after\nif err != nil { var ne net.Error; if errors.As(err, &ne) && ne.Timeout() { /* increase timeout */ } }\nresult.Error = fmt.Errorf(\"smb_probe_failed: %w\", err) // preserve cause","handlingStrategy":"try-catch","validationCode":"conn, err := net.DialTimeout(\"tcp\", host+\":445\", 5*time.Second)\nif err == nil {\n    // optional: send NBSS session request to confirm SMB before full probe\n    conn.Close()\n} else { /* skip: will fail smb_probe_failed anyway */ }","typeGuard":null,"tryCatchPattern":"res, err := plugin.Scan(ctx, target)\nif err != nil && strings.Contains(err.Error(), \"smb_probe_failed\") {\n    var ne net.Error\n    if errors.As(err, &ne) && ne.Timeout() {\n        // increase timeout and retry once\n    } else if errors.Is(err, syscall.ECONNRESET) {\n        // non-SMB service or middlebox reset; skip host\n    }\n}","preventionTips":["Confirm the service is SMB before running the module (banner or NBSS check).","Keep SMB2/3 support enabled client-side; assume SMBv1 is disabled on targets.","Always inspect the wrapped cause (%w) rather than the top-level message.","Set probe timeouts based on measured RTT to the target network."],"tags":["smb","network","protocol-negotiation","error-wrapping"],"backgroundTag":"network-request-failed","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"}