nmap.cc

来自「Ubuntu packages of security software。 相」· CC 代码 · 共 1,556 行 · 第 1/5 页

CC
1,556
字号
	l = tval2msecs(optarg);	if (l <= 0) fatal("Bogus --initial-rtt-timeout argument specified.  Must be positive");        pre_init_rtt_timeout = l;      } else if (strcmp(long_options[option_index].name, "excludefile") == 0) {	if (exclude_spec)	  fatal("--excludefile and --exclude options are mutually exclusive.");        excludefd = fopen(optarg, "r");        if (!excludefd) {          fatal("Failed to open exclude file %s for reading", optarg);        }      } else if (strcmp(long_options[option_index].name, "exclude") == 0) {	if (excludefd)	  fatal("--excludefile and --exclude options are mutually exclusive.");	exclude_spec = strdup(optarg);      } else if (optcmp(long_options[option_index].name, "max-hostgroup") == 0) {	o.setMaxHostGroupSz(atoi(optarg));      } else if (optcmp(long_options[option_index].name, "min-hostgroup") == 0) {	o.setMinHostGroupSz(atoi(optarg));	if (atoi(optarg) > 100)	  error("Warning: You specified a highly aggressive --min-hostgroup.");      } else if (optcmp(long_options[option_index].name, "open") == 0) {	o.setOpenOnly(true);      } else if (strcmp(long_options[option_index].name, "scanflags") == 0) {	o.scanflags = parse_scanflags(optarg);	if (o.scanflags < 0) {	  fatal("--scanflags option must be a number between 0 and 255 (inclusive) or a string like \"URGPSHFIN\".");	}      } else if (strcmp(long_options[option_index].name, "iflist") == 0 ) {	iflist = true;      } else if (strcmp(long_options[option_index].name, "release-memory") == 0 ) {	o.release_memory = true;      } else if (optcmp(long_options[option_index].name, "min-parallelism") == 0 ) {	o.min_parallelism = atoi(optarg); 	if (o.min_parallelism < 1) fatal("Argument to --min-parallelism must be at least 1!");	if (o.min_parallelism > 100) {	  error("Warning: Your --min-parallelism option is pretty high!  This can hurt reliability.");	}      } else if (optcmp(long_options[option_index].name, "host-timeout") == 0) {	l = tval2msecs(optarg);	if (l <= 1500) fatal("--host-timeout is specified in milliseconds unless you qualify it by appending 's', 'm', 'h', or 'd'.  The value must be greater than 1500 milliseconds");	pre_host_timeout = l;	if (l < 15000) {	  error("host-timeout is given in milliseconds, so you specified less than 15 seconds (%lims). This is allowed but not recommended.", o.host_timeout);	}      } else if (strcmp(long_options[option_index].name, "ttl") == 0) {	o.ttl = atoi(optarg);	if (o.ttl < 0 || o.ttl > 255) {	  fatal("ttl option must be a number between 0 and 255 (inclusive)");	}      } else if (strcmp(long_options[option_index].name, "datadir") == 0) {	o.datadir = strdup(optarg);      } else if (optcmp(long_options[option_index].name, "append-output") == 0) {	o.append_output = 1;      } else if (strcmp(long_options[option_index].name, "noninteractive") == 0) {	o.noninteractive = true;      } else if (optcmp(long_options[option_index].name, "spoof-mac") == 0) {	/* I need to deal with this later, once I'm sure that I have output	   files set up, --datadir, etc. */	spoofmac = optarg;      } else if (strcmp(long_options[option_index].name, "allports") == 0) {        o.override_excludeports = 1;      } else if (optcmp(long_options[option_index].name, "version-intensity") == 0) {	o.version_intensity = atoi(optarg);	if (o.version_intensity < 0 || o.version_intensity > 9)		fatal("version-intensity must be between 0 and 9");      } else if (optcmp(long_options[option_index].name, "version-light") == 0) {        o.version_intensity = 2;      } else if (optcmp(long_options[option_index].name, "version-all") == 0) {        o.version_intensity = 9;      } else if (optcmp(long_options[option_index].name, "scan-delay") == 0) {	l = tval2msecs(optarg);	if (l < 0) fatal("Bogus --scan-delay argument specified.");	pre_scan_delay = l;      } else if (optcmp(long_options[option_index].name, "defeat-rst-ratelimit") == 0) {        o.defeat_rst_ratelimit = 1;      } else if (optcmp(long_options[option_index].name, "max-scan-delay") == 0) {	l = tval2msecs(optarg);	if (l < 0) fatal("--max-scan-delay cannot be negative.");	pre_max_scan_delay = l;      } else if (optcmp(long_options[option_index].name, "max-retries") == 0) {        pre_max_retries = atoi(optarg);        if (pre_max_retries < 0)          fatal("max-retries must be positive");      } else if (optcmp(long_options[option_index].name, "randomize-hosts") == 0		 || strcmp(long_options[option_index].name, "rH") == 0) {	o.randomize_hosts = 1;	o.ping_group_sz = PING_GROUP_SZ * 4;      } else if (optcmp(long_options[option_index].name, "osscan-limit")  == 0) {	o.osscan_limit = 1;      } else if (optcmp(long_options[option_index].name, "osscan-guess")  == 0                 || strcmp(long_options[option_index].name, "fuzzy") == 0) {	o.osscan_guess = 1;      } else if (optcmp(long_options[option_index].name, "packet-trace") == 0) {	o.setPacketTrace(true);      } else if (optcmp(long_options[option_index].name, "version-trace") == 0) {	o.setVersionTrace(true);	o.debugging++;      } else if (optcmp(long_options[option_index].name, "data-length") == 0) {	o.extra_payload_length = atoi(optarg);	if (o.extra_payload_length < 0) {	  fatal("data-length must be greater than 0");	} else if (o.extra_payload_length > 0) {	  o.extra_payload = (char *) safe_malloc(o.extra_payload_length);	  get_random_bytes(o.extra_payload, o.extra_payload_length);	}      } else if (optcmp(long_options[option_index].name, "send-eth") == 0) {	o.sendpref = PACKET_SEND_ETH_STRONG;      } else if (optcmp(long_options[option_index].name, "send-ip") == 0) {	o.sendpref = PACKET_SEND_IP_STRONG;      } else if (strcmp(long_options[option_index].name, "stylesheet") == 0) {	o.setXSLStyleSheet(optarg);      } else if (optcmp(long_options[option_index].name, "no-stylesheet") == 0) {	o.setXSLStyleSheet(NULL);      } else if (optcmp(long_options[option_index].name, "system-dns") == 0) {        o.mass_dns = false;      } else if (optcmp(long_options[option_index].name, "dns-servers") == 0) {        o.dns_servers = strdup(optarg);      } else if (optcmp(long_options[option_index].name, "log-errors") == 0) {        o.log_errors = 1;      } else if (strcmp(long_options[option_index].name, "webxml") == 0) {	o.setXSLStyleSheet("http://www.insecure.org/nmap/data/nmap.xsl");      } else if (strcmp(long_options[option_index].name, "oN") == 0) {	normalfilename = optarg;      } else if (strcmp(long_options[option_index].name, "oG") == 0 ||		 strcmp(long_options[option_index].name, "oM") == 0) {	machinefilename = optarg;      } else if (strcmp(long_options[option_index].name, "oS") == 0) {	kiddiefilename = optarg;      } else if (strcmp(long_options[option_index].name, "oH") == 0) {	fatal("HTML output is not directly supported, though Nmap includes an XSL for transforming XML output into HTML.  See the man page.");      } else if (strcmp(long_options[option_index].name, "oX") == 0) {	xmlfilename = optarg;      } else if (strcmp(long_options[option_index].name, "oA") == 0) {	char buf[MAXPATHLEN];	snprintf(buf, sizeof(buf), "%s.nmap", optarg);	normalfilename = strdup(buf);	snprintf(buf, sizeof(buf), "%s.gnmap", optarg);	machinefilename = strdup(buf);	snprintf(buf, sizeof(buf), "%s.xml", optarg);	xmlfilename = strdup(buf);      } else if (strcmp(long_options[option_index].name, "thc") == 0) {	printf("!!Greets to Van Hauser, Plasmoid, Skyper and the rest of THC!!\n");	exit(0);      } else if (strcmp(long_options[option_index].name, "badsum") == 0) {	o.badsum = 1;      } else if (strcmp(long_options[option_index].name, "iR") == 0) {	o.generate_random_ips = 1;	o.max_ips_to_scan = strtoul(optarg, &endptr, 10);	if (*endptr != '\0') {	  fatal("ERROR: -iR argument must be the maximum number of random IPs you wish to scan (use 0 for unlimited)");	}      } else if (strcmp(long_options[option_index].name, "sI") == 0) {	o.idlescan = 1;	idleProxy = optarg;      } else if (strcmp(long_options[option_index].name, "vv") == 0) {	/* Compatability hack ... ugly */	o.verbose += 2;      } else if (strcmp(long_options[option_index].name, "ff") == 0) {	o.fragscan += 16;       } else if (strcmp(long_options[option_index].name, "privileged") == 0) {	o.isr00t = 1;      } else if (strcmp(long_options[option_index].name, "unprivileged") == 0) {	o.isr00t = 0;      } else if (strcmp(long_options[option_index].name, "mtu") == 0) {        o.fragscan = atoi(optarg);        if (o.fragscan <= 0 || o.fragscan % 8 != 0)            fatal("Data payload MTU must be >0 and multiple of 8");      } else if (strcmp(long_options[option_index].name, "ip-options") == 0){        o.ipoptions    = (u8*) safe_malloc(4*10+1);        o.ipoptionslen = parse_ip_options(optarg, o.ipoptions, 4*10+1, &o.ipopt_firsthop, &o.ipopt_lasthop);        if(o.ipoptionslen > 4*10)          fatal("Ip options can't be more than 40 bytes long");        if(o.ipoptionslen %4 != 0)          fatal("Ip options must be multiple of 4 (read length is %i bytes)", o.ipoptionslen);      } else {	fatal("Unknown long option (%s) given@#!$#$", long_options[option_index].name);      }      break;    case '6':#if !HAVE_IPV6      fatal("I am afraid IPv6 is not available because your host doesn't support it or you chose to compile Nmap w/o IPv6 support.");#else      o.setaf(AF_INET6);#endif /* !HAVE_IPV6 */      break;    case 'A':      o.servicescan = true;      if (o.isr00t)		o.osscan = OS_SCAN_DEFAULT;      break;    case 'b':       o.bouncescan++;      if (parse_bounce_argument(&ftp, optarg) < 0 ) {	fprintf(stderr, "Your argument to -b is b0rked. Use the normal url style:  user:pass@server:port or just use server and use default anon login\n  Use -h for help\n");      }      break;    case 'D':      p = optarg;      do {    	q = strchr(p, ',');	if (q) *q = '\0';	if (!strcasecmp(p, "me")) {	  if (o.decoyturn != -1) 	    fatal("Can only use 'ME' as a decoy once.\n");	  o.decoyturn = o.numdecoys++;	} else {      	  if (o.numdecoys >= MAX_DECOYS -1)	    fatal("You are only allowed %d decoys (if you need more redefine MAX_DECOYS in nmap.h)", MAX_DECOYS);	  if (resolve(p, &o.decoys[o.numdecoys])) {	    o.numdecoys++;	  } else {	    fatal("Failed to resolve decoy host: %s (must be hostname or IP address)", p);	  }	}	if (q) {	  *q = ',';	  p = q+1;	}      } while(q);      break;    case 'd':       if (optarg)	o.debugging = o.verbose = atoi(optarg);      else {	o.debugging++; o.verbose++;      }      break;    case 'e':       Strncpy(o.device, optarg, sizeof(o.device)); break;    case 'F': fastscan++; break;    case 'f': o.fragscan += 8; break;    case 'g':       o.magic_port = atoi(optarg);      o.magic_port_set = 1;      if (o.magic_port == 0) error("WARNING: a source port of zero may not work on all systems.");      break;        case 'h': printusage(argv[0], 0); break;    case '?': printusage(argv[0], -1); break;    case 'I':       printf("WARNING: identscan (-I) no longer supported.  Ignoring -I\n");      break;      // o.identscan++; break;    case 'i':       if (inputfd) {	fatal("Only one input filename allowed");      }      if (!strcmp(optarg, "-")) {	inputfd = stdin;      } else {    	inputfd = fopen(optarg, "r");	if (!inputfd) {	  fatal("Failed to open input file %s for reading", optarg);	}        }      break;      case 'M':       pre_max_parallelism = atoi(optarg);       if (pre_max_parallelism < 1) fatal("Argument to -M must be at least 1!");      if (pre_max_parallelism > 900) {	error("Warning: Your max-parallelism (-M) option is extraordinarily high, which can hurt reliability");      }      break;    case 'm':       machinefilename = optarg;      break;    case 'n': o.noresolve++; break;    case 'O':       if (!optarg)		o.osscan = OS_SCAN_DEFAULT;      else if (*optarg == '1')		o.osscan = OS_SCAN_SYS_1_ONLY;	  else if (*optarg == '2')		o.osscan = OS_SCAN_SYS_2_ONLY;      else {	fatal("Use -O for new osscan engine, -O1 for old osscan engine.");      }      break;    case 'o':      normalfilename = optarg;      break;    case 'P':       if (*optarg == '\0' || *optarg == 'I' || *optarg == 'E')	o.pingtype |= PINGTYPE_ICMP_PING;      else if (*optarg == 'M') 	o.pingtype |= PINGTYPE_ICMP_MASK;      else if (*optarg == 'P') 	o.pingtype |= PINGTYPE_ICMP_TS;      else if (*optarg == '0' || *optarg == 'N' || *optarg == 'D')      	o.pingtype = PINGTYPE_NONE;      else if (*optarg == 'R')	o.pingtype |= PINGTYPE_ARP;      else if (*optarg == 'S') {	o.pingtype |= (PINGTYPE_TCP|PINGTYPE_TCP_USE_SYN);	if (isdigit((int) *(optarg+1)))	  {	    o.num_ping_synprobes = numberlist2array(optarg+1, o.ping_synprobes, sizeof(o.ping_synprobes), &proberr);	    if (o.num_ping_synprobes < 0) {	      fatal("Bogus argument to -PS: %s", proberr);	    }	  }	if (o.num_ping_synprobes == 0) {	  o.num_ping_synprobes = 1;	  o.ping_synprobes[0] = DEFAULT_TCP_PROBE_PORT;	}      }      else if (*optarg == 'T' || *optarg == 'A') {	/* NmapOps::ValidateOptions() takes care of changing this	   to SYN if not root or if IPv6 */	o.pingtype |= (PINGTYPE_TCP|PINGTYPE_TCP_USE_ACK);	if (isdigit((int) *(optarg+1))) {	  o.num_ping_ackprobes = numberlist2array(optarg+1, o.ping_ackprobes, sizeof(o.ping_ackprobes), &proberr);	  if (o.num_ping_ackprobes < 0) {	    fatal("Bogus argument to -PB: %s", proberr);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?