{"record":{"id":"177bf5df493daacb","repo":"shadow1ng/fscan","slug":"netbios-smb-session-send-failed-w","errorCode":null,"errorMessage":"netbios_smb_session_send_failed: %w","messagePattern":"netbios_smb_session_send_failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"plugins/services/netbios.go","lineNumber":249,"sourceCode":"\t\t0x00, 0x00, 0x00, 0x4A, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD4, 0x00, 0x00, 0xA0, 0xCF, 0x00, 0x60,\n\t\t0x48, 0x06, 0x06, 0x2B, 0x06, 0x01, 0x05, 0x05, 0x02, 0xA0, 0x3E, 0x30, 0x3C, 0xA0, 0x0E, 0x30,\n\t\t0x0C, 0x06, 0x0A, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x02, 0x02, 0x0A, 0xA2, 0x2A, 0x04,\n\t\t0x28, 0x4E, 0x54, 0x4C, 0x4D, 0x53, 0x53, 0x50, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x82, 0x08,\n\t\t0xA2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t\t0x00, 0x05, 0x02, 0xCE, 0x0E, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x57, 0x00, 0x69, 0x00, 0x6E, 0x00,\n\t\t0x64, 0x00, 0x6F, 0x00, 0x77, 0x00, 0x73, 0x00, 0x20, 0x00, 0x53, 0x00, 0x65, 0x00, 0x72, 0x00,\n\t\t0x76, 0x00, 0x65, 0x00, 0x72, 0x00, 0x20, 0x00, 0x32, 0x00, 0x30, 0x00, 0x30, 0x00, 0x33, 0x00,\n\t\t0x20, 0x00, 0x33, 0x00, 0x37, 0x00, 0x39, 0x00, 0x30, 0x00, 0x20, 0x00, 0x53, 0x00, 0x65, 0x00,\n\t\t0x72, 0x00, 0x76, 0x00, 0x69, 0x00, 0x63, 0x00, 0x65, 0x00, 0x20, 0x00, 0x50, 0x00, 0x61, 0x00,\n\t\t0x63, 0x00, 0x6B, 0x00, 0x20, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x57, 0x00, 0x69, 0x00,\n\t\t0x6E, 0x00, 0x64, 0x00, 0x6F, 0x00, 0x77, 0x00, 0x73, 0x00, 0x20, 0x00, 0x53, 0x00, 0x65, 0x00,\n\t\t0x72, 0x00, 0x76, 0x00, 0x65, 0x00, 0x72, 0x00, 0x20, 0x00, 0x32, 0x00, 0x30, 0x00, 0x30, 0x00,\n\t\t0x33, 0x00, 0x20, 0x00, 0x35, 0x00, 0x2E, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t}\n\n\t_, err = conn.Write(smbSessionSetup)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: %w\", i18n.GetText(\"netbios_smb_session_send_failed\"), err)\n\t}\n\n\tresponse2 := make([]byte, 2048)\n\tn, err := conn.Read(response2)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: %w\", i18n.GetText(\"netbios_smb_session_read_failed\"), err)\n\t}\n\n\treturn p.parseNetBIOSSession(response2[:n])\n}\n\n// parseNetBIOSNames 解析NetBIOS名称查询响应\nfunc (p *NetBIOSPlugin) parseNetBIOSNames(data []byte) (*NetBIOSInfo, error) {\n\tinfo := &NetBIOSInfo{Valid: false}\n\n\tif len(data) < 57 {\n\t\treturn info, fmt.Errorf(\"%s\", i18n.GetText(\"netbios_response_too_short\"))\n\t}","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/plugins/services/netbios.go#L231-L267","documentation":"This error occurs in queryNetBIOSSession when writing the SMB Session Setup request (smbSessionSetup, an NTLMSSP negotiate packet) to the established TCP 139 connection fails. The library wraps the net.Conn.Write error with the i18n message 'netbios_smb_session_send_failed'. The SMB negotiate round-trip succeeded but the connection broke before the second request could be sent.","triggerScenarios":"Scan -> queryNetBIOSSession completes the first negotiate read, then conn.Write(smbSessionSetup) errors: the peer reset or closed the connection after the negotiate reply, or the SetDeadline(ModuleTimeout) expired before the write completed.","commonSituations":"Servers that accept the negotiate but reject the session (some Samba configs close after negotiate); IPS dropping the larger session-setup packet; scanning Windows hosts that require SMB2+ and abort legacy NTLM setup; tight ModuleTimeout on loaded networks.","solutions":["Extend config.ModuleTimeout() so the second write is not cut off by the deadline.","Confirm the target supports the legacy NTLMSSP session-setup flow (modern hosts often need SMB2/3 on port 445 instead).","Check firewalls/IPS logs for RST injection after SMB negotiate.","Distinguish timeout vs reset in the wrapped error with errors.As(net.Error) and log host + cause."],"exampleFix":"// before\n_, err = conn.Write(smbSessionSetup)\nif err != nil {\n    return nil, fmt.Errorf(\"%s: %w\", i18n.GetText(\"netbios_smb_session_send_failed\"), err)\n}\n\n// after\n_, err = conn.Write(smbSessionSetup)\nif err != nil {\n    var nerr net.Error\n    if errors.As(err, &nerr) && nerr.Timeout() {\n        return nil, fmt.Errorf(\"smb session setup send timed out for %s\", host)\n    }\n    return nil, fmt.Errorf(\"%s: %w\", i18n.GetText(\"netbios_smb_session_send_failed\"), err)\n}","handlingStrategy":"try-catch","validationCode":"// confirm negotiate round-trip succeeded before sending session setup\nif len(response1) == 0 {\n    return fmt.Errorf(\"empty negotiate response; aborting session setup for %s\", host)\n}\nif time.Until(deadline) < time.Second {\n    return fmt.Errorf(\"less than 1s left on deadline before session setup\")\n}","typeGuard":"func isBrokenPipe(err error) bool {\n    return errors.Is(err, syscall.EPIPE) || errors.Is(err, syscall.ECONNRESET) || errors.Is(err, io.ErrClosedPipe)\n}","tryCatchPattern":"_, err = conn.Write(smbSessionSetup)\nif err != nil {\n    if isBrokenPipe(err) {\n        return nil, fmt.Errorf(\"host %s dropped connection before session setup\", host)\n    }\n    var nerr net.Error\n    if errors.As(err, &nerr) && nerr.Timeout() {\n        return nil, fmt.Errorf(\"session setup send timed out for %s\", host)\n    }\n    return nil, fmt.Errorf(\"%s: %w\", i18n.GetText(\"netbios_smb_session_send_failed\"), err)\n}","preventionTips":["Extend the deadline after the negotiate round-trip so the session setup isn't starved.","Detect peer-closed connections (EPIPE/ECONNRESET) and skip the host early.","For hosts rejecting legacy NTLM setup, probe SMB2/3 on port 445 instead.","Log the raw wrapped error per host to spot IPS/firewall reset patterns."],"tags":["network","netbios","smb","ntlm","tcp"],"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"}