{"record":{"id":"db8f70dbf5dbf958","repo":"shadow1ng/fscan","slug":"s-w","errorCode":null,"errorMessage":"%s: %w","messagePattern":"%s: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/services/findnet.go","lineNumber":142,"sourceCode":"\n\tif len(parts) == 0 {\n\t\treturn i18n.GetText(\"findnet_complete\")\n\t}\n\treturn strings.Join(parts, \", \")\n}\n\n// RPC数据包定义\nvar (\n\trpcBuffer1, _ = hex.DecodeString(\"05000b03100000004800000001000000b810b810000000000100000000000100c4fefc9960521b10bbcb00aa0021347a00000000045d888aeb1cc9119fe808002b10486002000000\")\n\trpcBuffer2, _ = hex.DecodeString(\"050000031000000018000000010000000000000000000500\")\n\trpcBuffer3, _ = hex.DecodeString(\"0900ffff0000\")\n)\n\n// performNetworkDiscovery 执行RPC网络发现\nfunc (p *FindNetPlugin) performNetworkDiscovery(conn net.Conn) (*NetworkInfo, error) {\n\t// 发送第一个RPC请求\n\tif _, err := conn.Write(rpcBuffer1); err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: %w\", i18n.GetText(\"findnet_rpc_request1_failed\"), err)\n\t}\n\n\t// 读取响应\n\treply := make([]byte, 4096)\n\tif _, err := conn.Read(reply); err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: %w\", i18n.GetText(\"findnet_rpc_response1_failed\"), err)\n\t}\n\n\t// 发送第二个RPC请求\n\tif _, err := conn.Write(rpcBuffer2); err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: %w\", i18n.GetText(\"findnet_rpc_request2_failed\"), err)\n\t}\n\n\t// 读取网络信息响应\n\tn, err := conn.Read(reply)\n\tif err != nil || n < 42 {\n\t\treturn nil, fmt.Errorf(\"%s: %w\", i18n.GetText(\"findnet_rpc_response2_failed\"), err)\n\t}","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/plugins/services/findnet.go#L124-L160","documentation":"performNetworkDiscovery wraps a failed conn.Write of the first RPC request buffer (rpcBuffer1) used for RPC network discovery over a raw TCP connection. The i18n message ('RPC request 1 failed'-style) is prefixed to the underlying net error with %w so callers can errors.Is/As the wrapped cause. This is a low-level I/O failure, not an authentication result.","triggerScenarios":"Scan -> performNetworkDiscovery: the first conn.Write(rpcBuffer1) on the target host's RPC port returns an error — connection reset, broken pipe, or write on an already-closed/failed connection.","commonSituations":"Target host closes the TCP connection immediately upon connect (RPC service not actually listening on that port); firewall or IDS resets the connection after inspecting the payload; scanning a non-RPC port that got bound by another service; network unreachable mid-scan.","solutions":["Check that the target port actually hosts the service (nmap/service probe) before scanning","Retry the scan; transient resets are common on lossy networks","Inspect the wrapped error with errors.Is(err, syscall.ECONNRESET)/net.Error to classify host vs network issues","Verify firewall rules don't drop/reset connections to the discovery port"],"exampleFix":"// before\nif _, err := conn.Write(rpcBuffer1); err != nil {\n    return nil, fmt.Errorf(\"%s: %w\", i18n.GetText(\"findnet_rpc_request1_failed\"), err)\n}\n// after\nif _, err := conn.Write(rpcBuffer1); err != nil {\n    if errors.Is(err, syscall.EPIPE) || errors.Is(err, syscall.ECONNRESET) {\n        return nil, fmt.Errorf(\"%s: %w\", i18n.GetText(\"findnet_rpc_request1_failed\"), err) // host not RPC; skip\n    }\n    return nil, fmt.Errorf(\"%s: %w\", i18n.GetText(\"findnet_rpc_request1_failed\"), err)\n}","handlingStrategy":"try-catch","validationCode":"// Go: pre-check connectivity before Scan\nconn, err := net.DialTimeout(\"tcp\", target, 3*time.Second)\nif err != nil { return fmt.Errorf(\"target unreachable: %w\", err) }\nconn.Close()","typeGuard":"func isTransientNetErr(err error) bool {\n    var ne net.Error\n    return errors.As(err, &ne) && ne.Timeout() || errors.Is(err, syscall.ECONNRESET) || errors.Is(err, syscall.EPIPE)\n}","tryCatchPattern":"info, err := plugin.performNetworkDiscovery(conn)\nif err != nil {\n    if isTransientNetErr(err) { /* retry or skip host */ }\n    log.Printf(\"discovery failed for %s: %v\", target, err)\n    return\n}","preventionTips":["Probe the port with a service check before RPC discovery","Set explicit read/write deadlines on the connection","Classify wrapped errors with errors.Is/As instead of string matching","Retry transient network errors with backoff"],"tags":["network","rpc","discovery","tcp"],"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"}