{"record":{"id":"1288396b7245f75f","repo":"bettercap/bettercap","slug":"invalid-start-port-s-s","errorCode":null,"errorMessage":"invalid start port %s: %s","messagePattern":"invalid start port (.+?): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/syn_scan/syn_scan_parsers.go","lineNumber":41,"sourceCode":"\t\t\treturn fmt.Errorf(\"error while parsing IP range '%s': %s\", arg, err)\n\t\t} else {\n\t\t\tmod.addresses = list.Expand()\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (mod *SynScanner) parsePorts(args []string) (err error) {\n\targc := len(args)\n\tmod.stats.totProbes = 0\n\tmod.stats.doneProbes = 0\n\tmod.startPort = 1\n\tmod.endPort = 65535\n\n\tif argc > 1 && str.Trim(args[1]) != \"\" {\n\t\tif mod.startPort, err = strconv.Atoi(str.Trim(args[1])); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid start port %s: %s\", args[1], err)\n\t\t} else if mod.startPort > 65535 {\n\t\t\tmod.startPort = 65535\n\t\t}\n\t\tmod.endPort = mod.startPort\n\t}\n\n\tif argc > 2 && str.Trim(args[2]) != \"\" {\n\t\tif mod.endPort, err = strconv.Atoi(str.Trim(args[2])); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid end port %s: %s\", args[2], err)\n\t\t}\n\t}\n\n\tif mod.endPort < mod.startPort {\n\t\treturn fmt.Errorf(\"end port %d is greater than start port %d\", mod.endPort, mod.startPort)\n\t}\n\n\treturn\n}","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/bettercap/bettercap/blob/8eca2820f3c41d2004434ed5a291d87462caeeb7/modules/syn_scan/syn_scan_parsers.go#L23-L59","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nsyn.parse_ports 10.0.0.1 $START-\n// after\nsyn.parse_ports 10.0.0.1 80 443","handlingStrategy":"validation","validationCode":"const start = args[1]?.trim() ?? ''\nif (start !== '' && !/^\\d+$/.test(start)) {\n  throw new Error(`start port must be an integer, got: ${start}`)\n}","typeGuard":"function isValidPort(s) { return /^\\d+$/.test(s.trim()) && +s.trim() <= 65535 }","tryCatchPattern":"try {\n  session.Run('syn.parse_ports ' + target + ' ' + start)\n} catch (e) {\n  if (String(e).includes('invalid start port')) {\n    console.error('Fix the start port argument:', start)\n  } else { throw e }\n}","preventionTips":["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"],"tags":["bettercap","port-scanning","argument-validation","cli"],"backgroundTag":"invalid-port-argument","analyzedSha":"8eca2820f3c41d2004434ed5a291d87462caeeb7","analyzedAt":"2026-09-02T12:49:00.712Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T16:17:10.729Z"}