-
Notifications
You must be signed in to change notification settings - Fork 0
Input Validation
As of v1.2.0, inputs that have a well-defined shape (targets, ports, CIDR
ranges, domains) are validated before they reach a tool. This catches typos
early and keeps malformed values out of sudo command lines.
Two pieces cooperate:
-
Validator functions in
lib/core.sh, namedfys_is_*. Each takes one argument, returns0when the value is well-formed and1otherwise, and prints nothing. Callers decide how to react. -
The
prompt_validwrapper inlib/installer.sh:port=$(prompt_valid "Port" fys_is_port) || return 0
It reads a value, runs the validator, and re-prompts on bad input. An empty answer is treated as "abort": it logs
No value provided.and returns1, which the|| return 0turns into a clean trip back to the menu. So you can always back out of any validated prompt by pressing Enter.
A bad-but-non-empty value prints Invalid value: <x> and asks again.
| Function | Accepts | Examples |
|---|---|---|
fys_is_port |
A single TCP/UDP port, 1–65535. |
22, 443, 65535
|
fys_is_port_spec |
Comma lists and ranges of ports (nmap/masscan style). Empty rejected. |
80, 1-1000, 22,80,443, 1-65535
|
fys_is_ipv4 |
A dotted-quad IPv4 with each octet 0–255. | 192.168.1.10 |
fys_is_hostname |
An RFC-1123 hostname (labels of letters/digits/hyphens, ≤253 chars). |
example.com, scanme.nmap.org
|
fys_is_host |
IPv4 or hostname. | either of the above |
fys_is_cidr |
IPv4 CIDR; prefix 0–32. |
192.168.1.0/24, 10.0.0.0/8
|
fys_is_host_or_cidr |
A host or a CIDR range. | host, IP, or CIDR |
| Tool / prompt | Validator |
|---|---|
| Nmap target | fys_is_host_or_cidr |
| Netcat target / port |
fys_is_host / fys_is_port
|
| Tcpdump port / host |
fys_is_port / fys_is_host
|
| hping3 target / port |
fys_is_host / fys_is_port
|
| arp-scan range | fys_is_cidr |
| Masscan target / ports |
fys_is_host_or_cidr / fys_is_port_spec
|
| Nikto host / port |
fys_is_host / fys_is_port (default 80) |
| dnsenum domain | fys_is_hostname |
Free-form prompts (URLs, interfaces, custom BPF filters, "custom args" modes)
use prompt_value and are not shape-validated, because there is no single
correct form. Treat those as you would a raw shell argument.
When you add a tool, reuse these rather than rolling your own regex:
target=$(prompt_valid "Target (ip/host)" fys_is_host) || return 0
port=$(prompt_valid "Port" fys_is_port) || return 0Always pair prompt_valid with || return 0 so an empty answer returns the
user to the menu. See Extending FeedYourSpider.
FeedYourSpider · GPL-3.0-or-later · by Melvin PETIT — Use only on authorized targets.
Getting started
Reference
Internals
Project