{"record":{"id":"5c3510c7b848b143","repo":"shadow1ng/fscan","slug":"smb-port-only","errorCode":null,"errorMessage":"smb_port_only","messagePattern":"smb_port_only","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"plugins/services/smb.go","lineNumber":37,"sourceCode":"}\n\nfunc NewSmbPlugin() *SmbPlugin {\n\treturn &SmbPlugin{\n\t\tBasePlugin: plugins.NewBasePlugin(\"smb\"),\n\t}\n}\n\nfunc (p *SmbPlugin) Scan(ctx context.Context, info *common.HostInfo, session *common.ScanSession) *plugins.Result {\n\tconfig := session.Config\n\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 {","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/plugins/services/smb.go#L19-L55","documentation":"The SMB module only supports Windows SMB ports. Scan validates info.Port immediately and, unless the port is 445 (SMB over TCP) or 139 (SMB over NetBIOS), returns a failed ScanResult with smb_port_only. This is an input guard, not a network failure: the module refuses to run protocol probing on unsupported ports.","triggerScenarios":"Scan is called with an info whose Port is anything other than 445 or 139 — e.g. the target list includes SMB-over-QUIC 443, or a generic port sweep hands every open port to the SMB module.","commonSituations":"Misconfigured scan target lists including arbitrary ports; expecting SMB over 443 (SMB over QUIC, unsupported here); port-forwarding setups that expose SMB behind a nonstandard external port without mapping it back.","solutions":["Restrict SMB targets to ports 445 or 139 in the scan configuration.","If SMB is published on a nonstandard port, add a port mapping or test from a position where 445 is reachable.","Route other ports to the correct service modules instead of the SMB plugin."],"exampleFix":"// before\ntargets := [\"10.0.0.5:443\"] // smb_port_only\n// after\ntargets := [\"10.0.0.5:445\", \"10.0.0.5:139\"]","handlingStrategy":"validation","validationCode":"if port != 445 && port != 139 {\n    return errors.New(\"SMB module requires port 445 or 139; got \" + strconv.Itoa(port))\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"smb_port_only\") {\n    // drop target from SMB queue; log config mistake\n}","preventionTips":["Build SMB target lists strictly from hosts with 445/139 open.","Remember SMB-over-QUIC (443) is not supported by this module.","Validate target port lists in CI before running scans."],"tags":["smb","port-validation","configuration","windows"],"backgroundTag":"invalid-argument-value","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"}