{"record":{"id":"86e15fe07308c098","repo":"shadow1ng/fscan","slug":"ms17010-send-session-error-w","errorCode":null,"errorMessage":"ms17010_send_session_error: %w","messagePattern":"ms17010_send_session_error: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/services/ms17010.go","lineNumber":322,"sourceCode":"\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\n\tn, readErr = conn.Read(reply)\n\tif readErr != nil || n < 36 {\n\t\treturn false, \"\", false, fmt.Errorf(\"%s\", i18n.GetText(\"ms17010_session_failed\"))\n\t}\n\n\tif binary.LittleEndian.Uint32(reply[9:13]) != 0 {\n\t\treturn false, \"\", false, fmt.Errorf(\"%s\", i18n.GetText(\"ms17010_session_rejected\"))\n\t}\n\n\t// 提取系统信息\n\tvar osVersion string\n\tsessionSetupResponse := reply[36:n]\n\tif len(sessionSetupResponse) > 0 && sessionSetupResponse[0] != 0 && len(sessionSetupResponse) >= 10 {\n\t\tbyteCount := binary.LittleEndian.Uint16(sessionSetupResponse[7:9])\n\t\tif n == int(byteCount)+45 {\n\t\t\tfor i := 10; i < len(sessionSetupResponse)-1; i++ {","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/plugins/services/ms17010.go#L304-L340","documentation":"After a successful negotiate, the checker writes an SMB Session Setup AndX request to the connection. This error wraps the underlying write failure (%w) with the i18n message, meaning the TCP connection broke while sending the session setup packet.","triggerScenarios":"checkMS17010VulnerabilityAt returns this when conn.Write(sessionSetupRequest) returns a non-nil error after a successful negotiate exchange.","commonSituations":"Peer reset the connection between negotiate and session setup (server crashed on malformed negotiate reply handling); NAT/firewall dropped the flow mid-conversation; connection idle-timeout elapsed between the two packets on a slow link.","solutions":["Inspect the wrapped error (`errors.Unwrap`) to distinguish RST/broken pipe from timeout; a broken pipe right after negotiate usually means the peer killed the socket.","Retry the whole probe from scratch (new TCP connection) — the session is unrecoverable once the write fails.","Check for middleboxes idle-killing SMB connections and shorten the gap between negotiate and session setup (the checker does this immediately, so external reset is the likely cause).","Confirm the host's 445/tcp service is healthy (no crashed Samba/srv2 process) via the OS event logs."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"conn, err := net.DialTimeout(\"tcp\", host+\":445\", 3*time.Second)\nif err != nil { return err }\nconn.SetDeadline(time.Now().Add(5*time.Second)) // keep socket alive through all steps","typeGuard":null,"tryCatchPattern":"if _, err := conn.Write(sessionSetupRequest); err != nil {\n    return fmt.Errorf(\"ms17010 session setup write failed: %w\", err) // inspect via errors.Is(err, syscall.ECONNRESET)\n}","preventionTips":["Set socket deadlines covering the entire multi-step exchange.","Reconnect and retry the whole probe on write failure; sessions are not resumable.","Check for middleboxes that reset idle or unusual SMB flows.","Monitor target srv2/Samba health if failures cluster on one host."],"tags":["smb","network","tcp","ms17-10"],"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-14T05:17:10.506Z"}