shadow1ng/fscan · error

parser_ipv4_only

Error message

parser_ipv4_only

What it means

parseIPFullRange converts both endpoints with To4() and requires them to be IPv4. If either endpoint is nil as IPv4 (e.g. an IPv6 address), this error is returned. The range engine only supports IPv4 expansion.

Source

Thrown at common/parsers/parsers.go:400

	startNum, err := strconv.Atoi(ipParts[3])
	if err != nil || startNum > endNum {
		return nil, fmt.Errorf("%s", i18n.Tr("parser_invalid_ip_range_val", startIPStr, endSuffix))
	}

	var allIP []string
	for i := startNum; i <= endNum; i++ {
		allIP = append(allIP, fmt.Sprintf("%s.%d", prefixIP, i))
	}

	return allIP, nil
}

// parseIPFullRange 解析完整格式的IP范围
func parseIPFullRange(startIP, endIP net.IP) ([]string, error) {
	start4 := startIP.To4()
	end4 := endIP.To4()
	if start4 == nil || end4 == nil {
		return nil, fmt.Errorf("%s", i18n.GetText("parser_ipv4_only"))
	}

	startInt := (int(start4[0]) << 24) | (int(start4[1]) << 16) | (int(start4[2]) << 8) | int(start4[3])
	endInt := (int(end4[0]) << 24) | (int(end4[1]) << 16) | (int(end4[2]) << 8) | int(end4[3])

	if startInt > endInt {
		return nil, fmt.Errorf("%s", i18n.GetText("parser_start_gt_end"))
	}

	var ips []string
	current := make(net.IP, len(start4))
	copy(current, start4)

	for {
		ips = append(ips, current.String())
		if current.Equal(end4) {
			break
		}

View on GitHub (pinned to 95cc12e753)

Solutions

  1. Use IPv4 addresses on both sides of the range, e.g. '192.168.1.1-192.168.1.254'.
  2. Filter or reject IPv6 targets before passing them to the IP range parser.
  3. Extend/patch the parser if IPv6 range support is required — the current implementation does not support it.

Example fix

// before
ParseIPRangeString("2001:db8::1-2001:db8::ff")
// after
ParseIPRangeString("192.168.1.1-192.168.1.254")
Defensive patterns

Strategy: validation

Validate before calling

func isIPv4Range(start, end string) bool {
    return net.ParseIP(start).To4() != nil && net.ParseIP(end).To4() != nil
}

Try / catch

ips, err := parseIPRangeString(rangeStr)
if err != nil {
    return fmt.Errorf("IPv4 required for range %q: %w", rangeStr, err)
}

Prevention

When it happens

Trigger: Calling parseIPRangeString with a full range where start or end is IPv6, e.g. '2001:db8::1-2001:db8::5', or an unparseable endpoint that yields a nil To4().

Common situations: Scanning dual-stack hosts where users paste IPv6 addresses into an IPv4-only range field; mixed ranges like '192.168.1.1-2001:db8::2'.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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