bettercap/bettercap · error
invalid start port %s: %s
Error message
invalid start port %s: %s
What it means
syn_scan's `syn.parse_ports` (parsePorts) accepts an optional start port as its second argument and parses it with strconv.Atoi. If the trimmed argument is not a valid integer, the module refuses to configure the port range and returns this error. It is a pure argument-validation error raised before any packets are sent.
Source
Thrown at modules/syn_scan/syn_scan_parsers.go:41
return fmt.Errorf("error while parsing IP range '%s': %s", arg, err)
} else {
mod.addresses = list.Expand()
}
}
return nil
}
func (mod *SynScanner) parsePorts(args []string) (err error) {
argc := len(args)
mod.stats.totProbes = 0
mod.stats.doneProbes = 0
mod.startPort = 1
mod.endPort = 65535
if argc > 1 && str.Trim(args[1]) != "" {
if mod.startPort, err = strconv.Atoi(str.Trim(args[1])); err != nil {
return fmt.Errorf("invalid start port %s: %s", args[1], err)
} else if mod.startPort > 65535 {
mod.startPort = 65535
}
mod.endPort = mod.startPort
}
if argc > 2 && str.Trim(args[2]) != "" {
if mod.endPort, err = strconv.Atoi(str.Trim(args[2])); err != nil {
return fmt.Errorf("invalid end port %s: %s", args[2], err)
}
}
if mod.endPort < mod.startPort {
return fmt.Errorf("end port %d is greater than start port %d", mod.endPort, mod.startPort)
}
return
}View on GitHub (pinned to 8eca2820f3)
Solutions
- Pass a plain decimal integer for the start port argument, e.g. `syn.parse_ports 192.168.1.10 1 65535`.
- If passing variables from a script, verify they are non-empty numeric strings before invoking the module.
- Remember ports above 65535 are silently clamped, so only non-numeric values cause this error.
Example fix
// before syn.parse_ports 10.0.0.1 $START- // after syn.parse_ports 10.0.0.1 80 443
Defensive patterns
Strategy: validation
Validate before calling
const start = args[1]?.trim() ?? ''
if (start !== '' && !/^\d+$/.test(start)) {
throw new Error(`start port must be an integer, got: ${start}`)
} Type guard
function isValidPort(s) { return /^\d+$/.test(s.trim()) && +s.trim() <= 65535 } Try / catch
try {
session.Run('syn.parse_ports ' + target + ' ' + start)
} catch (e) {
if (String(e).includes('invalid start port')) {
console.error('Fix the start port argument:', start)
} else { throw e }
} Prevention
- Always pass plain decimal integers for port arguments
- Validate scripted variables are numeric before interpolation
- Remember only values >65535 are clamped; all other bad input errors out
When it happens
Trigger: Running `syn.parse_ports <target> <start>` where the start port argument is empty-looking-but-non-numeric text (e.g. a placeholder, a stray letter, or a value with units like `80/tcp`). The trimmed string must parse as an int.
Common situations: Typing a port range in a non-numeric notation (`80-90` as the start argument instead of two args), copy-pasting commands with hidden characters, or scripting with an unset shell variable that renders as literal text.
Related errors
- invalid end port %s: %s
- end port %d is greater than start port %d
- %d is not a valid channel number
- %d is not a valid wifi channel
- expression '%s' doesn't parse
AI-assisted analysis of bettercap/bettercap@8eca2820f3 (2026-09-02).
Data as JSON: /api/errors/1288396b7245f75f.
Report an issue: GitHub.