shadow1ng/fscan · error

service_conn_port_failed: %w

Error message

service_conn_port_failed: %w

What it means

The FindNet plugin's TCP connection to the target (port 135) failed in session.DialTCP, so Scan returns this wrapped error (%w wraps the underlying net error) from i18n key service_conn_port_failed. It reports that the endpoint mapper could not be reached, before any RPC bind or enumeration is attempted.

Source

Thrown at plugins/services/findnet.go:58

func (p *FindNetPlugin) Scan(ctx context.Context, info *common.HostInfo, session *common.ScanSession) *ScanResult {
	config := session.Config
	target := info.Target()

	// 检查是否为RPC端口
	if info.Port != 135 {
		return &ScanResult{
			Success: false,
			Service: "findnet",
			Error:   fmt.Errorf("%s", i18n.Tr("service_port_restriction", "FindNet", "135")),
		}
	}

	conn, err := session.DialTCP(ctx, "tcp", target, config.ModuleTimeout())
	if err != nil {
		return &ScanResult{
			Success: false,
			Service: "findnet",
			Error:   fmt.Errorf(i18n.Tr("service_conn_port_failed", "%w"), err),
		}
	}
	defer func() { _ = conn.Close() }()

	// 设置超时
	_ = conn.SetDeadline(time.Now().Add(config.ModuleTimeout()))

	// 执行RPC网络发现
	networkInfo, err := p.performNetworkDiscovery(conn)
	if err != nil {
		return &ScanResult{
			Success: false,
			Service: "findnet",
			Error:   err,
		}
	}

	// 记录发现的网络信息 (一次性输出,避免被其他日志打断)

View on GitHub (pinned to 95cc12e753)

Solutions

  1. Read the wrapped error: 'connection refused' means port closed/filtered-reject; 'i/o timeout' means dropped packets (firewall); 'no such host' means DNS.
  2. Confirm port 135 is reachable with nc -zv host 135 from the scanning host.
  3. Increase config.ModuleTimeout() if the link is slow, and verify proxy settings if the scan routes through one.
  4. Skip or deprioritize hosts where 135 is filtered — RPC enumeration cannot proceed without it.

Example fix

// before
session.DialTCP(ctx, "tcp", target, 2*time.Second) // i/o timeout on WAN
// after
session.DialTCP(ctx, "tcp", target, config.ModuleTimeout()) // e.g. 10s, tuned in config
Defensive patterns

Strategy: retry

Validate before calling

conn, err := net.DialTimeout("tcp", net.JoinHostPort(info.Host, "135"), 3*time.Second)
if err != nil {
    return fmt.Errorf("host %s:135 not reachable: %w", info.Host, err)
}
conn.Close()

Try / catch

res := plugin.Scan(ctx, info, session)
var nerr net.Error
if res.Error != nil && (errors.As(res.Error, &nerr) || errors.Is(res.Error, syscall.ECONNREFUSED)) {
    // back off and retry, or mark host:135 dead and skip RPC enumeration
    return retryWithBackoff(ctx, info, session)
}

Prevention

When it happens

Trigger: Dialing host:135 fails because the port is closed, a firewall drops/denies the packet, DNS fails for the host, the dial times out after config.ModuleTimeout(), or the session's network layer (proxy/dialer) is misconfigured.

Common situations: Windows hosts with RPC endpoint mapper firewalled (common on hardened networks); scanning across network segments without routing; timeout too short for slow WAN links; target host powered off or IP changed.

Understand the failure class

Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.

Related errors


AI-assisted analysis of shadow1ng/fscan@95cc12e753 (2026-09-06). Data as JSON: /api/errors/7178306f537b0323. Report an issue: GitHub.