shadow1ng/fscan · error

parser_invalid_start_ip

Error message

parser_invalid_start_ip

What it means

In parseIPRangeString, after splitting, the start part is parsed with net.ParseIP. If it is not a valid IP literal, the function returns 'parser_invalid_start_ip' with the offending string. It means the left side of the '-' range is not a parseable IP address.

Source

Thrown at common/parsers/parsers.go:352

	}
	// 检查 - 前面的部分是否是有效IP
	startPart := s[:idx]
	return net.ParseIP(startPart) != nil
}

// parseIPRangeString 解析IP范围字符串
func parseIPRangeString(rangeStr string) ([]string, error) {
	parts := strings.Split(rangeStr, "-")
	if len(parts) != 2 {
		return nil, fmt.Errorf("%s", i18n.Tr("parser_invalid_ip_range_fmt", rangeStr))
	}

	startIPStr := strings.TrimSpace(parts[0])
	endIPStr := strings.TrimSpace(parts[1])

	startIP := net.ParseIP(startIPStr)
	if startIP == nil {
		return nil, fmt.Errorf("%s", i18n.Tr("parser_invalid_start_ip", startIPStr))
	}

	// 处理简写格式 (如: 192.168.1.1-100)
	if len(endIPStr) < 4 || !strings.Contains(endIPStr, ".") {
		return parseIPShortRange(startIPStr, endIPStr)
	}

	// 处理完整格式 (如: 192.168.1.1-192.168.1.100)
	endIP := net.ParseIP(endIPStr)
	if endIP == nil {
		return nil, fmt.Errorf("%s", i18n.Tr("parser_invalid_end_ip", endIPStr))
	}

	return parseIPFullRange(startIP, endIP)
}

// parseIPShortRange 解析短格式IP范围
func parseIPShortRange(startIPStr, endSuffix string) ([]string, error) {

View on GitHub (pinned to 95cc12e753)

Solutions

  1. Write the start address as a full dotted-quad IPv4, e.g. 192.168.1.1
  2. Remove hostnames — ranges must start with an IP literal
  3. Pre-validate with net.ParseIP(parts[0]) != nil before calling ParseIP

Example fix

// before
ParseIP("192.168.1-192.168.1.5", "")
// after
ParseIP("192.168.1.1-192.168.1.5", "")
Defensive patterns

Strategy: validation

Validate before calling

func validStartIP(rangeStr string) bool {
	parts := strings.Split(rangeStr, "-")
	return len(parts) == 2 && net.ParseIP(strings.TrimSpace(parts[0])) != nil
}

Try / catch

if !validStartIP(rangeStr) {
	return fmt.Errorf("start of %q is not an IP", rangeStr)
}
_, err := parsers.ParseIP(rangeStr, "")

Prevention

When it happens

Trigger: parseIPRangeString receiving ranges like 'abc-192.168.1.10' or '192.168.1-192.168.1.5' where strings.TrimSpace(parts[0]) fails net.ParseIP.

Common situations: Truncated first octets (forgot a segment), hostnames on the left side of a range, or stray whitespace/characters in scripts generating the target list.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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