{"record":{"id":"f415d5aab4b2260c","repo":"shadow1ng/fscan","slug":"failed-to-connect-host-s","errorCode":null,"errorMessage":"failed to connect host: %s","messagePattern":"failed to connect host: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/services/ms17010_exp.go","lineNumber":137,"sourceCode":"\treturn nil\n}\n\nfunc makeKernelUserPayload(sc []byte) []byte {\n\t// test DoublePulsar\n\tbuf := bytes.Buffer{}\n\tbuf.Write(loader[:])\n\t// write sc size\n\tsize := make([]byte, 2)\n\tbinary.LittleEndian.PutUint16(size, uint16(len(sc)))\n\tbuf.Write(size)\n\tbuf.Write(sc)\n\treturn buf.Bytes()\n}\n\nfunc smb1AnonymousConnectIPC(address string) (*smbHeader, net.Conn, error) {\n\tconn, err := net.DialTimeout(\"tcp\", address, 10*time.Second)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to connect host: %s\", err)\n\t}\n\tvar ok bool\n\tdefer func() {\n\t\tif !ok {\n\t\t\t_ = conn.Close()\n\t\t}\n\t}()\n\terr = smbClientNegotiate(conn)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to negotiate: %s\", err)\n\t}\n\traw, header, err := smb1AnonymousLogin(conn)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to login with anonymous: %s\", err)\n\t}\n\t_, err = getOSName(raw)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to get OS name: %s\", err)","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/plugins/services/ms17010_exp.go#L119-L155","documentation":"This error is returned by smb1AnonymousConnectIPC when the initial TCP dial to the target (net.DialTimeout on the address:port, 10s timeout) fails (plugins/services/ms17010_exp.go:137). The library throws it because the SMB1 anonymous IPC session cannot even be established at the transport layer. The wrapped net.OpError tells you whether it was refused, timed out, or was unreachable.","triggerScenarios":"Calling exploit()/smb1AnonymousConnectIPC with an address where nothing listens on the port (connection refused), the host is down or unroutable (i/o timeout / no route to host), or DNS name does not resolve.","commonSituations":"Scanning hosts that have SMB (445) firewalled off; wrong port passed in the address string; target VM powered off; scanning across a VPN where the subnet is unreachable; IPv6 literal without brackets in host:port form.","solutions":["Verify the address includes the correct port (host:port, e.g. 192.168.1.10:445) and resolves","Probe the port first (nc -zv host 445) to confirm reachability before running the exploit","Check firewall/ACL on the target and any intermediate network allows TCP to the SMB port","Increase tolerance for slow hosts: the dial uses a fixed 10s timeout; retry hosts that time out intermittently"],"exampleFix":"// before\nconn, err := net.DialTimeout(\"tcp\", address, 10*time.Second)\nif err != nil {\n    return nil, nil, fmt.Errorf(\"failed to connect host: %s\", err)\n}\n// after\nif _, _, err := net.SplitHostPort(address); err != nil {\n    address = net.JoinHostPort(address, \"445\") // default SMB port\n}\nconn, err := net.DialTimeout(\"tcp\", address, 10*time.Second)\nif err != nil {\n    return nil, nil, fmt.Errorf(\"failed to connect host %s: %w\", address, err)\n}","handlingStrategy":"validation","validationCode":"// Validate reachability before calling the exploit\nfunc requireSMBPort(address string) error {\n    _, port, err := net.SplitHostPort(address)\n    if err != nil { return fmt.Errorf(\"address must be host:port: %w\", err) }\n    conn, err := net.DialTimeout(\"tcp\", address, 5*time.Second)\n    if err != nil { return err }\n    _ = conn.Close()\n    _ = port\n    return nil\n}","typeGuard":"func validHostPort(s string) bool {\n    host, port, err := net.SplitHostPort(s)\n    if err != nil || host == \"\" { return false }\n    p, err := strconv.Atoi(port)\n    return err == nil && p > 0 && p < 65536\n}","tryCatchPattern":"header, conn, err := smb1AnonymousConnectIPC(addr)\nif err != nil && strings.Contains(err.Error(), \"failed to connect host\") {\n    log.Printf(\"unreachable %s: %v\", addr, err)\n    return // skip host, do not retry in-process\n}","preventionTips":["Always pass host:port (default SMB port 445) — bare hostnames fail SplitHostPort later","Pre-check port reachability with nc or a short dial before batch scanning","Exclude known-firewalled subnets from scan targets","Distinguish refused (host up, port closed) vs timeout (host down/filtered) from the wrapped *net.OpError"],"tags":["network","tcp","smb","connection","dial"],"backgroundTag":"connection-refused","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"}