diff --git a/nmap.cc b/nmap.cc index 5664461ad..4ab5bf10b 100644 --- a/nmap.cc +++ b/nmap.cc @@ -116,7 +116,7 @@ #ifndef NOLUA #include "nse_main.h" -#endif +#endif #ifdef WIN32 #include "winfix.h" @@ -143,7 +143,7 @@ extern int optind; extern NmapOps o; /* option structure */ static bool target_needs_new_hostgroup(std::vector &targets, - const Target *target); + const Target *target); static void display_nmap_version(); /* A mechanism to save argv[0] for code that requires that. */ @@ -164,45 +164,36 @@ static int parse_scanflags(char *arg) { if (isdigit((int) (unsigned char) arg[0])) { flagval = strtol(arg, &end, 0); - if (*end || flagval < 0 || flagval > 255) return -1; + if (*end || flagval < 0 || flagval > 255) + return -1; } else { - if (strcasestr(arg, "FIN")) { + if (strcasestr(arg, "FIN")) flagval |= TH_FIN; - } - if (strcasestr(arg, "SYN")) { + if (strcasestr(arg, "SYN")) flagval |= TH_SYN; - } - if (strcasestr(arg, "RST") || strcasestr(arg, "RESET")) { + if (strcasestr(arg, "RST") || strcasestr(arg, "RESET")) flagval |= TH_RST; - } - if (strcasestr(arg, "PSH") || strcasestr(arg, "PUSH")) { + if (strcasestr(arg, "PSH") || strcasestr(arg, "PUSH")) flagval |= TH_PUSH; - } - if (strcasestr(arg, "ACK")) { + if (strcasestr(arg, "ACK")) flagval |= TH_ACK; - } - if (strcasestr(arg, "URG")) { + if (strcasestr(arg, "URG")) flagval |= TH_URG; - } - if (strcasestr(arg, "ECE")) { + if (strcasestr(arg, "ECE")) flagval |= TH_ECE; - } - if (strcasestr(arg, "CWR")) { + if (strcasestr(arg, "CWR")) flagval |= TH_CWR; - } - if (strcasestr(arg, "ALL")) { + if (strcasestr(arg, "ALL")) flagval = 255; - } - if (strcasestr(arg, "NONE")) { + if (strcasestr(arg, "NONE")) flagval = 0; - } } return flagval; } /* parse a URL stype ftp string of the form user:pass@server:portno */ static int parse_bounce_argument(struct ftpinfo *ftp, char *url) { - char *p = url,*q, *s; + char *p = url, *q, *s; if ((q = strrchr(url, '@'))) { /* we have user and/or pass */ *q++ = '\0'; @@ -212,7 +203,7 @@ static int parse_bounce_argument(struct ftpinfo *ftp, char *url) { strncpy(ftp->pass, s, 255); } else { /* we ONLY have user */ log_write(LOG_STDOUT, "Assuming %s is a username, and using the default password: %s\n", - p, ftp->pass); + p, ftp->pass); } strncpy(ftp->user, p, 63); @@ -235,119 +226,119 @@ static int parse_bounce_argument(struct ftpinfo *ftp, char *url) { static void printusage(int rc) { -printf("%s %s ( %s )\n" - "Usage: nmap [Scan Type(s)] [Options] {target specification}\n" - "TARGET SPECIFICATION:\n" - " Can pass hostnames, IP addresses, networks, etc.\n" - " Ex: scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0.0-255.1-254\n" - " -iL : Input from list of hosts/networks\n" - " -iR : Choose random targets\n" - " --exclude : Exclude hosts/networks\n" - " --excludefile : Exclude list from file\n" - "HOST DISCOVERY:\n" - " -sL: List Scan - simply list targets to scan\n" - " -sn: Ping Scan - disable port scan\n" - " -Pn: Treat all hosts as online -- skip host discovery\n" - " -PS/PA/PU/PY[portlist]: TCP SYN/ACK, UDP or SCTP discovery to given ports\n" - " -PE/PP/PM: ICMP echo, timestamp, and netmask request discovery probes\n" - " -PO[protocol list]: IP Protocol Ping\n" - " -n/-R: Never do DNS resolution/Always resolve [default: sometimes]\n" - " --dns-servers : Specify custom DNS servers\n" - " --system-dns: Use OS's DNS resolver\n" - " --traceroute: Trace hop path to each host\n" - "SCAN TECHNIQUES:\n" - " -sS/sT/sA/sW/sM: TCP SYN/Connect()/ACK/Window/Maimon scans\n" - " -sU: UDP Scan\n" - " -sN/sF/sX: TCP Null, FIN, and Xmas scans\n" - " --scanflags : Customize TCP scan flags\n" - " -sI : Idle scan\n" - " -sY/sZ: SCTP INIT/COOKIE-ECHO scans\n" - " -sO: IP protocol scan\n" - " -b : FTP bounce scan\n" - "PORT SPECIFICATION AND SCAN ORDER:\n" - " -p : Only scan specified ports\n" - " Ex: -p22; -p1-65535; -p U:53,111,137,T:21-25,80,139,8080,S:9\n" - " -F: Fast mode - Scan fewer ports than the default scan\n" - " -r: Scan ports consecutively - don't randomize\n" - " --top-ports : Scan most common ports\n" - " --port-ratio : Scan ports more common than \n" - "SERVICE/VERSION DETECTION:\n" - " -sV: Probe open ports to determine service/version info\n" - " --version-intensity : Set from 0 (light) to 9 (try all probes)\n" - " --version-light: Limit to most likely probes (intensity 2)\n" - " --version-all: Try every single probe (intensity 9)\n" - " --version-trace: Show detailed version scan activity (for debugging)\n" + printf("%s %s ( %s )\n" + "Usage: nmap [Scan Type(s)] [Options] {target specification}\n" + "TARGET SPECIFICATION:\n" + " Can pass hostnames, IP addresses, networks, etc.\n" + " Ex: scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0.0-255.1-254\n" + " -iL : Input from list of hosts/networks\n" + " -iR : Choose random targets\n" + " --exclude : Exclude hosts/networks\n" + " --excludefile : Exclude list from file\n" + "HOST DISCOVERY:\n" + " -sL: List Scan - simply list targets to scan\n" + " -sn: Ping Scan - disable port scan\n" + " -Pn: Treat all hosts as online -- skip host discovery\n" + " -PS/PA/PU/PY[portlist]: TCP SYN/ACK, UDP or SCTP discovery to given ports\n" + " -PE/PP/PM: ICMP echo, timestamp, and netmask request discovery probes\n" + " -PO[protocol list]: IP Protocol Ping\n" + " -n/-R: Never do DNS resolution/Always resolve [default: sometimes]\n" + " --dns-servers : Specify custom DNS servers\n" + " --system-dns: Use OS's DNS resolver\n" + " --traceroute: Trace hop path to each host\n" + "SCAN TECHNIQUES:\n" + " -sS/sT/sA/sW/sM: TCP SYN/Connect()/ACK/Window/Maimon scans\n" + " -sU: UDP Scan\n" + " -sN/sF/sX: TCP Null, FIN, and Xmas scans\n" + " --scanflags : Customize TCP scan flags\n" + " -sI : Idle scan\n" + " -sY/sZ: SCTP INIT/COOKIE-ECHO scans\n" + " -sO: IP protocol scan\n" + " -b : FTP bounce scan\n" + "PORT SPECIFICATION AND SCAN ORDER:\n" + " -p : Only scan specified ports\n" + " Ex: -p22; -p1-65535; -p U:53,111,137,T:21-25,80,139,8080,S:9\n" + " -F: Fast mode - Scan fewer ports than the default scan\n" + " -r: Scan ports consecutively - don't randomize\n" + " --top-ports : Scan most common ports\n" + " --port-ratio : Scan ports more common than \n" + "SERVICE/VERSION DETECTION:\n" + " -sV: Probe open ports to determine service/version info\n" + " --version-intensity : Set from 0 (light) to 9 (try all probes)\n" + " --version-light: Limit to most likely probes (intensity 2)\n" + " --version-all: Try every single probe (intensity 9)\n" + " --version-trace: Show detailed version scan activity (for debugging)\n" #ifndef NOLUA - "SCRIPT SCAN:\n" - " -sC: equivalent to --script=default\n" - " --script=: is a comma separated list of \n" - " directories, script-files or script-categories\n" - " --script-args=: provide arguments to scripts\n" - " --script-args-file=filename: provide NSE script args in a file\n" - " --script-trace: Show all data sent and received\n" - " --script-updatedb: Update the script database.\n" - " --script-help=: Show help about scripts.\n" - " is a comma separted list of script-files or\n" - " script-categories.\n" + "SCRIPT SCAN:\n" + " -sC: equivalent to --script=default\n" + " --script=: is a comma separated list of \n" + " directories, script-files or script-categories\n" + " --script-args=: provide arguments to scripts\n" + " --script-args-file=filename: provide NSE script args in a file\n" + " --script-trace: Show all data sent and received\n" + " --script-updatedb: Update the script database.\n" + " --script-help=: Show help about scripts.\n" + " is a comma separted list of script-files or\n" + " script-categories.\n" #endif - "OS DETECTION:\n" - " -O: Enable OS detection\n" - " --osscan-limit: Limit OS detection to promising targets\n" - " --osscan-guess: Guess OS more aggressively\n" - "TIMING AND PERFORMANCE:\n" - " Options which take