shadow1ng/fscan · error

portfinger_probe_protocol_invalid

Error message

portfinger_probe_protocol_invalid

What it means

parseProbeInfo requires a probe definition of at least 5 characters: a 4-byte protocol identifier plus at least one payload character. Shorter strings cannot contain a valid probe header, so this error is returned instead of panicking.

Source

Thrown at core/portfinger/probe_parser.go:37

	// 解析各个字段
	directiveName := data[:blankIndex]
	Flag := data[blankIndex+1 : blankIndex+2]
	delimiter := data[blankIndex+2 : blankIndex+3]
	directiveStr := data[blankIndex+3:]

	directive.DirectiveName = directiveName
	directive.Flag = Flag
	directive.Delimiter = delimiter
	directive.DirectiveStr = directiveStr

	return directive
}

// parseProbeInfo 解析探测器信息,返回错误替代 panic
func (p *Probe) parseProbeInfo(probeStr string) error {
	if len(probeStr) < 5 {
		return fmt.Errorf("%s", i18n.GetText("portfinger_probe_protocol_invalid"))
	}

	// 提取协议和其他信息
	proto := probeStr[:4]
	other := probeStr[4:]

	// 验证协议类型
	if proto != "TCP " && proto != "UDP " {
		return fmt.Errorf("%s", i18n.GetText("portfinger_probe_protocol_invalid"))
	}

	// 验证其他信息不为空
	if len(other) == 0 {
		return fmt.Errorf("%s", i18n.GetText("portfinger_probe_name_invalid"))
	}

	// 解析指令
	directive := p.getDirectiveSyntax(other)

View on GitHub (pinned to 95cc12e753)

Solutions

  1. Fix or remove the short/malformed probe line in the probe definitions file.
  2. Restore the original probe database file (re-download the stock definitions).
  3. Pre-filter lines: skip empties and validate a minimum length/known protocol prefix (e.g. 'TCP ', 'UDP ') before calling fromString.

Example fix

// before
ProbeFromString("TCP") // < 5 chars, errors
// after
ProbeFromString("TCP GET / HTTP/1.0\r\n\r\n")
Defensive patterns

Strategy: validation

Validate before calling

func probeLineOK(line string) bool {
    return len(line) >= 5 && (strings.HasPrefix(line, "TCP ") || strings.HasPrefix(line, "UDP "))
}

Try / catch

pr := &Probe{}
if err := pr.parseProbeInfo(line); err != nil {
    log.Warnf("skipping invalid probe line %q: %v", line, err)
    return nil
}

Prevention

When it happens

Trigger: fromString receiving an empty, whitespace-only, or truncated probe line (fewer than 5 chars) when loading the probe database.

Common situations: Blank or malformed lines in the probe file being parsed as probes; files truncated by a failed download or bad merge; comment/garbage lines not filtered before parsing.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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