/**
* Zod schemas for network security tools
*/
import { z } from "zod";
/**
* Nmap port scan schema
*/
export const NmapScanSchema = z.object({
target: z
.string()
.min(1)
.max(255)
.describe(
"Target IP address, hostname, or CIDR range (e.g., '192.168.1.1', 'example.com', '10.0.0.0/24')"
),
ports: z
.string()
.optional()
.describe(
"Port specification (e.g., '22', '1-1000', '22,80,443', '-' for all ports). Default: top 1000 ports"
),
scan_type: z
.enum(["tcp_syn", "tcp_connect", "udp", "ack", "null", "fin", "xmas"])
.default("tcp_syn")
.describe("Nmap scan type (tcp_syn requires root)"),
timing: z
.enum(["paranoid", "sneaky", "polite", "normal", "aggressive", "insane"])
.default("normal")
.describe("Timing template: paranoid (T0) to insane (T5)"),
os_detection: z
.boolean()
.default(false)
.describe("Enable OS detection (-O, requires root)"),
service_version: z
.boolean()
.default(false)
.describe("Probe for service versions (-sV)"),
script_scan: z
.string()
.optional()
.describe("NSE script(s) to run (e.g., 'vuln', 'default', 'http-*')"),
aggressive: z
.boolean()
.default(false)
.describe("Enable aggressive scan (-A: OS, version, script, traceroute)"),
output_format: z
.enum(["text", "xml", "json", "grepable"])
.default("text")
.describe("Output format"),
timeout: z
.number()
.int()
.min(10)
.max(3600)
.default(300)
.describe("Scan timeout in seconds"),
});
export type NmapScanInput = z.infer<typeof NmapScanSchema>;
/**
* Nmap host discovery schema
*/
export const NmapDiscoverSchema = z.object({
network: z
.string()
.describe("Network range in CIDR notation (e.g., '192.168.1.0/24')"),
method: z
.enum(["ping", "arp", "tcp", "udp", "icmp"])
.default("ping")
.describe("Discovery method (arp requires root and local network)"),
timeout: z
.number()
.int()
.min(10)
.max(600)
.default(120)
.describe("Discovery timeout in seconds"),
});
export type NmapDiscoverInput = z.infer<typeof NmapDiscoverSchema>;
/**
* Masscan schema
*/
export const MasscanSchema = z.object({
target: z
.string()
.describe("Target IP, range, or CIDR (e.g., '192.168.1.0/24', '10.0.0.1-10.0.0.255')"),
ports: z
.string()
.describe("Port range (e.g., '1-1000', '22,80,443', '0-65535')"),
rate: z
.number()
.int()
.min(1)
.max(100000)
.default(1000)
.describe("Packet transmission rate (packets/second, default: 1000)"),
banners: z
.boolean()
.default(false)
.describe("Grab banners from services"),
timeout: z
.number()
.int()
.min(10)
.max(600)
.default(300)
.describe("Scan timeout in seconds"),
});
export type MasscanInput = z.infer<typeof MasscanSchema>;
/**
* Netdiscover schema
*/
export const NetdiscoverSchema = z.object({
interface: z
.string()
.optional()
.describe("Network interface to use (e.g., 'eth0', 'wlan0')"),
range: z
.string()
.optional()
.describe("IP range to scan (e.g., '192.168.1.0/24')"),
passive: z
.boolean()
.default(false)
.describe("Passive mode (sniff packets without sending ARP requests)"),
timeout: z
.number()
.int()
.min(10)
.max(300)
.default(60)
.describe("Scan timeout in seconds"),
});
export type NetdiscoverInput = z.infer<typeof NetdiscoverSchema>;
/**
* Tcpdump capture schema
*/
export const TcpdumpSchema = z.object({
interface: z
.string()
.describe("Network interface to capture on (e.g., 'eth0', 'wlan0', 'any')"),
filter: z
.string()
.optional()
.describe("BPF filter expression (e.g., 'port 80', 'host 192.168.1.1')"),
count: z
.number()
.int()
.min(1)
.max(10000)
.optional()
.describe("Number of packets to capture (default: unlimited)"),
duration: z
.number()
.int()
.min(1)
.max(300)
.optional()
.describe("Capture duration in seconds"),
output_file: z
.string()
.optional()
.describe("Output file path (.pcap format)"),
verbose: z
.boolean()
.default(false)
.describe("Verbose output"),
});
export type TcpdumpInput = z.infer<typeof TcpdumpSchema>;
/**
* Tshark capture schema
*/
export const TsharkSchema = z.object({
interface: z
.string()
.describe("Network interface to capture on"),
filter: z
.string()
.optional()
.describe("Display filter (e.g., 'http', 'tcp.port == 80')"),
count: z
.number()
.int()
.min(1)
.max(10000)
.optional()
.describe("Number of packets to capture"),
duration: z
.number()
.int()
.min(1)
.max(300)
.optional()
.describe("Capture duration in seconds"),
fields: z
.array(z.string())
.optional()
.describe("Fields to display (e.g., ['ip.src', 'ip.dst', 'tcp.port'])"),
output_format: z
.enum(["text", "json", "xml"])
.default("text")
.describe("Output format"),
});
export type TsharkInput = z.infer<typeof TsharkSchema>;