📄 parseoptions.c
字号:
opt_df = TRUE; break; case OPT_FRAGOFF: ip_frag_offset = strtol(ago_optarg, NULL, 0); break; case OPT_TCPOFF: src_thoff = strtol(ago_optarg, NULL, 0); break; case OPT_REL: opt_relid = TRUE; break; case OPT_DATA: data_size = strtol(ago_optarg, NULL, 0); break; case OPT_RAWIP: opt_rawipmode = TRUE; break; case OPT_ICMP: opt_icmpmode = TRUE; break; case OPT_ICMP_TS: opt_icmpmode = TRUE; opt_icmptype = 13; break; case OPT_ICMP_ADDR: opt_icmpmode = TRUE; opt_icmptype = 17; break; case OPT_UDP: opt_udpmode = TRUE; break; case OPT_SCAN: opt_scanmode = TRUE; opt_scanports = strdup(ago_optarg); break; case OPT_LISTEN: opt_listenmode = TRUE; strlcpy(sign, ago_optarg, 1024); signlen = strlen(ago_optarg); break; case OPT_IPPROTO: raw_ip_protocol = strtol(ago_optarg, NULL, 0); break; case OPT_ICMPTYPE: opt_icmpmode= TRUE; opt_icmptype = strtol(ago_optarg, NULL, 0); break; case OPT_ICMPCODE: opt_icmpmode= TRUE; opt_icmpcode = strtol(ago_optarg, NULL, 0); break; case OPT_BIND: ctrlzbind = BIND_TTL; break; case OPT_UNBIND: ctrlzbind = BIND_NONE; break; case OPT_DEBUG: opt_debug = TRUE; break; case OPT_VERBOSE: opt_verbose = TRUE; break; case OPT_WINID: opt_winid_order = TRUE; break; case OPT_KEEP: opt_keepstill = TRUE; break; case OPT_FILE: opt_datafromfile = TRUE; strlcpy(datafilename, ago_optarg, 1024); break; case OPT_DUMP: opt_hexdump = TRUE; break; case OPT_PRINT: opt_contdump = TRUE; break; case OPT_SIGN: opt_sign = TRUE; strlcpy(sign, ago_optarg, 1024); signlen = strlen(ago_optarg); break; case OPT_SAFE: opt_safe = TRUE; break; case OPT_END: opt_end = TRUE; break; case OPT_TRACEROUTE: opt_traceroute = TRUE; break; case OPT_TOS: if (!strcmp(ago_optarg, "help")) tos_help(); else { static unsigned int tos_tmp = 0; sscanf(ago_optarg, "%2x", &tos_tmp); ip_tos |= tos_tmp; /* OR tos */ } break; case OPT_MTU: virtual_mtu = strtol(ago_optarg, NULL, 0); opt_fragment = TRUE; if(virtual_mtu > 65535) { virtual_mtu = 65535; printf("Specified MTU too high, " "fixed to 65535.\n"); } break; case OPT_SEQNUM: opt_seqnum = TRUE; break; case OPT_BADCKSUM: opt_badcksum = TRUE; break; case OPT_SETSEQ: set_seqnum = TRUE; tcp_seqnum = strtoul(ago_optarg, NULL, 0); break; case OPT_SETACK: set_ack = TRUE; tcp_ack = strtoul(ago_optarg, NULL, 0); break; case OPT_RROUTE: opt_rroute = TRUE; break; case OPT_ICMP_HELP: icmp_help(); /* ICMP options help */ break; case OPT_ICMP_IPVER: icmp_ip_version = strtol(ago_optarg, NULL, 0); break; case OPT_ICMP_IPHLEN: icmp_ip_ihl = strtol(ago_optarg, NULL, 0); break; case OPT_ICMP_IPLEN: icmp_ip_tot_len = strtol(ago_optarg, NULL, 0); break; case OPT_ICMP_IPID: icmp_ip_id = strtol(ago_optarg, NULL, 0); break; case OPT_ICMP_IPPROTO: icmp_ip_protocol = strtol(ago_optarg, NULL, 0); break; case OPT_ICMP_IPSRC: strlcpy (icmp_ip_srcip, ago_optarg, 1024); break; case OPT_ICMP_IPDST: strlcpy (icmp_ip_dstip, ago_optarg, 1024); break; case OPT_ICMP_GW: strlcpy (icmp_gwip, ago_optarg, 1024); break; case OPT_ICMP_SRCPORT: icmp_ip_srcport = strtol(ago_optarg, NULL, 0); break; case OPT_ICMP_DSTPORT: icmp_ip_dstport = strtol(ago_optarg, NULL, 0); break; case OPT_FORCE_ICMP: opt_force_icmp = TRUE; break; case OPT_ICMP_CKSUM: icmp_cksum = strtol(ago_optarg, NULL, 0); break; case OPT_TCPEXITCODE: opt_tcpexitcode = TRUE; break; case OPT_FAST: delay_changed = 1; opt_waitinusec = TRUE;#ifndef WIN32 usec_delay.it_value.tv_sec = usec_delay.it_interval.tv_sec = 0; usec_delay.it_value.tv_usec = usec_delay.it_interval.tv_usec = 100000;#else msec_delay.millitm = 100;#endif case OPT_FASTER: delay_changed = 1; opt_waitinusec = TRUE;#ifndef WIN32 usec_delay.it_value.tv_sec = usec_delay.it_interval.tv_sec = 0; usec_delay.it_value.tv_usec = usec_delay.it_interval.tv_usec = 1;#else msec_delay.millitm = 1;#endif break; case OPT_TR_KEEP_TTL: opt_tr_keep_ttl = TRUE; break; case OPT_TCP_TIMESTAMP: opt_tcp_timestamp = TRUE; break; case OPT_TR_STOP: opt_tr_stop = TRUE; break; case OPT_TR_NO_RTT: opt_tr_no_rtt = TRUE; break; case OPT_RAND_DEST: opt_rand_dest = TRUE; break; case OPT_RAND_SOURCE: opt_rand_source = TRUE; break; case OPT_LSRR: opt_lsrr = TRUE; parse_route(lsr, &lsr_length, ago_optarg); if (lsr[0]) printf("Warning: erasing previously given loose source route"); lsr[0] = 131; break; case OPT_SSRR: opt_ssrr = TRUE; parse_route(ssr, &ssr_length, ago_optarg); if (ssr[0]) printf("Warning: erasing previously given strong source route"); ssr[0] = 137; break; case OPT_ROUTE_HELP: route_help(); break; case OPT_APD_SEND: hping_ars_send(ago_optarg); break; } } /* missing target host? */ if (targethost_set == 0 && opt_listenmode && opt_safe) { printf( "you must specify a target host if you require safe protocol\n" "because hping needs a target for HCMP packets\n"); exit(1); } if (targethost_set == 0 && !opt_listenmode) return -1; if (opt_numeric == TRUE) opt_gethost = FALSE; /* some error condition */ if (data_size+IPHDR_SIZE+TCPHDR_SIZE > 65535) { printf("Option error: sorry, data size must be <= %lu\n", (unsigned long)(65535-IPHDR_SIZE+TCPHDR_SIZE)); exit(1); } else if (count <= 0 && count != -1) { printf("Option error: count must > 0\n"); exit(1); } else if (sending_wait <= 0) { printf("Option error: bad timing interval\n"); exit(1); }#ifndef WIN32 else if (opt_waitinusec == TRUE && usec_delay.it_value.tv_usec < 0) {#else else if (opt_waitinusec == TRUE && msec_delay.millitm < 0) {#endif printf("Option error: bad timing interval\n"); exit(1); } else if (opt_datafromfile == TRUE && data_size == 0) { printf("Option error: -E option useless without -d\n"); exit(1); } else if (opt_sign && data_size && signlen > data_size) { printf( "Option error: signature (%d bytes) is larger than data size\n" "check -d option, don't specify -d to let hping compute it\n", signlen); exit(1); } else if ((opt_sign || opt_listenmode) && signlen > 1024) { printf("Option error: signature too big\n"); exit(1); } else if (opt_safe == TRUE && src_id != -1) { printf("Option error: sorry, you can't set id and " "use safe protocol at some time\n"); exit(1); } else if (opt_safe == TRUE && opt_datafromfile == FALSE && opt_listenmode == FALSE) { printf("Option error: sorry, safe protocol is useless " "without 'data from file' option\n"); exit(1); } else if (opt_safe == TRUE && opt_sign == FALSE && opt_listenmode == FALSE) { printf("Option error: sorry, safe protocol require you " "sign your packets, see --sign | -e option\n"); exit(1); } else if (opt_rand_dest == TRUE && ifname[0] == '\0') { printf("Option error: you need to specify an interface " "when the --rand-dest option is enabled\n"); exit(1); } /* dependences */ if (opt_safe == TRUE) src_id = 1; if (opt_traceroute == TRUE && ctrlzbind == BIND_DPORT) ctrlzbind = BIND_TTL; if (opt_traceroute == TRUE && src_ttl_set == 0) src_ttl = DEFAULT_TRACEROUTE_TTL; /* set the data size to the signature len if the no data size * was specified */ if (opt_sign && !data_size) data_size = signlen; /* If scan mode is on, and the -i option was not used, * set the default delay to zero, that's send packets * as fast as possible. */ if (opt_scanmode && !delay_changed) { opt_waitinusec = TRUE;#ifndef WIN32 usec_delay.it_value.tv_sec = usec_delay.it_interval.tv_sec = 0; usec_delay.it_value.tv_usec = usec_delay.it_interval.tv_usec = 0;#else msec_delay.millitm = 0;#endif } return 1;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -