@@ -9,7 +9,7 @@
|
||||
CC= clang
|
||||
AR=/usr/bin/ar
|
||||
RANLIB=/usr/bin/ranlib
|
||||
CCOPT= -O2 -Wall
|
||||
CCOPT= -O2 -Wall -Wno-implicit-function-declaration
|
||||
#uncomment the following if you need libpcap based build under linux
|
||||
#(not raccomanded)
|
||||
COMPILE_TIME=
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/*
|
||||
* $smu-mark$
|
||||
/* * $smu-mark$
|
||||
* $name: usage.c$
|
||||
* $author: Salvatore Sanfilippo <antirez@invece.org>$
|
||||
* $copyright: Copyright (C) 1999 by Salvatore Sanfilippo$
|
||||
@@ -17,91 +16,91 @@
|
||||
void show_usage(void)
|
||||
{
|
||||
printf(
|
||||
"usage: hping3 host [options]\n"
|
||||
" -h --help show this help\n"
|
||||
" -v --version show version\n"
|
||||
" -c --count packet count\n"
|
||||
" -i --interval wait (uX for X microseconds, for example -i u1000)\n"
|
||||
" --fast alias for -i u10000 (10 packets for second)\n"
|
||||
" --flood sent packets as fast as possible. Don't show replies.\n"
|
||||
" -n --numeric numeric output\n"
|
||||
" -q --quiet quiet\n"
|
||||
" -I --interface interface name (otherwise default routing interface)\n"
|
||||
" -V --verbose verbose mode\n"
|
||||
" -D --debug debugging info\n"
|
||||
" -z --bind bind ctrl+z to ttl (default to dst port)\n"
|
||||
" -Z --unbind unbind ctrl+z\n"
|
||||
"Mode\n"
|
||||
" default mode TCP\n"
|
||||
" -0 --rawip RAW IP mode\n"
|
||||
" -1 --icmp ICMP mode\n"
|
||||
" -2 --udp UDP mode\n"
|
||||
" -6 --ipv6 IPv6 mode\n"
|
||||
" -8 --scan SCAN mode.\n"
|
||||
" Example: hping --scan 1-30,70-90 -S www.target.host\n"
|
||||
" -9 --listen listen mode\n"
|
||||
"用法: hping3 host [选项]\n"
|
||||
" -h --help 显示此帮助信息\n"
|
||||
" -v --version 显示版本\n"
|
||||
" -c --count 数据包数量\n"
|
||||
" -i --interval 等待间隔 (uX 表示 X 微秒, 例如 -i u1000)\n"
|
||||
" --fast -i u10000 的别名 (每秒 10 个数据包)\n"
|
||||
" --flood 以最快速度发送数据包。不显示回复。\n"
|
||||
" -n --numeric 数字输出\n"
|
||||
" -q --quiet 安静模式\n"
|
||||
" -I --interface 接口名称 (否则使用默认路由接口)\n"
|
||||
" -V --verbose 详细模式\n"
|
||||
" -D --debug 调试信息\n"
|
||||
" -z --bind 将 ctrl+z 绑定到 ttl (默认绑定到目标端口)\n"
|
||||
" -Z --unbind 解除 ctrl+z 绑定\n"
|
||||
"模式\n"
|
||||
" 默认模式 TCP\n"
|
||||
" -0 --rawip RAW IP 模式\n"
|
||||
" -1 --icmp ICMP 模式\n"
|
||||
" -2 --udp UDP 模式\n"
|
||||
" -6 --ipv6 IPv6 模式\n"
|
||||
" -8 --scan 扫描模式。\n"
|
||||
" 示例: hping --scan 1-30,70-90 -S www.target.host\n"
|
||||
" -9 --listen 监听模式\n"
|
||||
"IP\n"
|
||||
" -a --spoof spoof source address\n"
|
||||
" --rand-dest random destionation address mode. see the man.\n"
|
||||
" --rand-source random source address mode. see the man.\n"
|
||||
" -t --ttl ttl (default 64)\n"
|
||||
" -N --id id (default random)\n"
|
||||
" -W --winid use win* id byte ordering\n"
|
||||
" -r --rel relativize id field (to estimate host traffic)\n"
|
||||
" -f --frag split packets in more frag. (may pass weak acl)\n"
|
||||
" -x --morefrag set more fragments flag\n"
|
||||
" -y --dontfrag set dont fragment flag\n"
|
||||
" -g --fragoff set the fragment offset\n"
|
||||
" -m --mtu set virtual mtu, implies --frag if packet size > mtu\n"
|
||||
" -o --tos type of service (default 0x00), try --tos help\n"
|
||||
" -G --rroute includes RECORD_ROUTE option and display the route buffer\n"
|
||||
" --lsrr loose source routing and record route\n"
|
||||
" --ssrr strict source routing and record route\n"
|
||||
" -H --ipproto set the IP protocol field, only in RAW IP mode\n"
|
||||
" -a --spoof 伪造源地址\n"
|
||||
" --rand-dest 随机目标地址模式。详见手册。\n"
|
||||
" --rand-source 随机源地址模式。详见手册。\n"
|
||||
" -t --ttl ttl (默认 64)\n"
|
||||
" -N --id id (默认随机)\n"
|
||||
" -W --winid 使用 win* id 字节序\n"
|
||||
" -r --rel 相对化 id 字段 (用于估算主机流量)\n"
|
||||
" -f --frag 将数据包分割成更多片段。 (可能绕过弱 ACL)\n"
|
||||
" -x --morefrag 设置更多片段标志 (more fragments flag)\n"
|
||||
" -y --dontfrag 设置禁止分片标志 (dont fragment flag)\n"
|
||||
" -g --fragoff 设置分片偏移\n"
|
||||
" -m --mtu 设置虚拟 mtu, 如果数据包大小 > mtu 则隐含 --frag\n"
|
||||
" -o --tos 服务类型 (默认 0x00), 尝试 --tos help\n"
|
||||
" -G --rroute 包含 RECORD_ROUTE 选项并显示路由缓冲区\n"
|
||||
" --lsrr 宽松源路由和记录路由 (loose source routing and record route)\n"
|
||||
" --ssrr 严格源路由和记录路由 (strict source routing and record route)\n"
|
||||
" -H --ipproto 设置 IP 协议字段, 仅在 RAW IP 模式下可用\n"
|
||||
"ICMP\n"
|
||||
" -C --icmptype icmp type (default echo request)\n"
|
||||
" -K --icmpcode icmp code (default 0)\n"
|
||||
" --force-icmp send all icmp types (default send only supported types)\n"
|
||||
" --icmp-gw set gateway address for ICMP redirect (default 0.0.0.0)\n"
|
||||
" --icmp-ts Alias for --icmp --icmptype 13 (ICMP timestamp)\n"
|
||||
" --icmp-addr Alias for --icmp --icmptype 17 (ICMP address subnet mask)\n"
|
||||
" --icmp-help display help for others icmp options\n"
|
||||
" -C --icmptype icmp 类型 (默认 echo request, 回显请求)\n"
|
||||
" -K --icmpcode icmp 代码 (默认 0)\n"
|
||||
" --force-icmp 发送所有 icmp 类型 (默认只发送支持的类型)\n"
|
||||
" --icmp-gw 为 ICMP 重定向设置网关地址 (默认 0.0.0.0)\n"
|
||||
" --icmp-ts --icmp --icmptype 13 的别名 (ICMP 时间戳)\n"
|
||||
" --icmp-addr --icmp --icmptype 17 的别名 (ICMP 地址子网掩码)\n"
|
||||
" --icmp-help 显示其他 icmp 选项的帮助\n"
|
||||
"UDP/TCP\n"
|
||||
" -s --baseport base source port (default random)\n"
|
||||
" -p --destport [+][+]<port> destination port(default 0) ctrl+z inc/dec\n"
|
||||
" -k --keep keep still source port\n"
|
||||
" -w --win winsize (default 64)\n"
|
||||
" -O --tcpoff set fake tcp data offset (instead of tcphdrlen / 4)\n"
|
||||
" -Q --seqnum shows only tcp sequence number\n"
|
||||
" -b --badcksum (try to) send packets with a bad IP checksum\n"
|
||||
" many systems will fix the IP checksum sending the packet\n"
|
||||
" so you'll get bad UDP/TCP checksum instead.\n"
|
||||
" -M --setseq set TCP sequence number\n"
|
||||
" -L --setack set TCP ack\n"
|
||||
" -F --fin set FIN flag\n"
|
||||
" -S --syn set SYN flag\n"
|
||||
" -R --rst set RST flag\n"
|
||||
" -P --push set PUSH flag\n"
|
||||
" -A --ack set ACK flag\n"
|
||||
" -U --urg set URG flag\n"
|
||||
" -X --xmas set X unused flag (0x40)\n"
|
||||
" -Y --ymas set Y unused flag (0x80)\n"
|
||||
" --tcpexitcode use last tcp->th_flags as exit code\n"
|
||||
" --tcp-timestamp enable the TCP timestamp option to guess the HZ/uptime\n"
|
||||
"Common\n"
|
||||
" -d --data data size (default is 0)\n"
|
||||
" -E --file data from file\n"
|
||||
" -e --sign add 'signature'\n"
|
||||
" -j --dump dump packets in hex\n"
|
||||
" -J --print dump printable characters\n"
|
||||
" -B --safe enable 'safe' protocol\n"
|
||||
" -u --end tell you when --file reached EOF and prevent rewind\n"
|
||||
" -T --traceroute traceroute mode (implies --bind and --ttl 1)\n"
|
||||
" --tr-stop Exit when receive the first not ICMP in traceroute mode\n"
|
||||
" --tr-keep-ttl Keep the source TTL fixed, useful to monitor just one hop\n"
|
||||
" --tr-no-rtt Don't calculate/show RTT information in traceroute mode\n"
|
||||
"ARS packet description (new, unstable)\n"
|
||||
" --apd-send Send the packet described with APD (see docs/APD.txt)\n"
|
||||
" -s --baseport 基本源端口 (默认随机)\n"
|
||||
" -p --destport [+][+]<端口> 目标端口(默认 0) ctrl+z 增/减\n"
|
||||
" -k --keep 保持源端口不变\n"
|
||||
" -w --win 窗口大小 (默认 64)\n"
|
||||
" -O --tcpoff 设置假的 tcp 数据偏移 (而不是 tcphdrlen / 4)\n"
|
||||
" -Q --seqnum 仅显示 tcp 序列号\n"
|
||||
" -b --badcksum (尝试) 发送带有错误 IP 校验和的数据包\n"
|
||||
" 许多系统在发送数据包时会修复 IP 校验和\n"
|
||||
" 因此您将改为得到错误的 UDP/TCP 校验和。\n"
|
||||
" -M --setseq 设置 TCP 序列号\n"
|
||||
" -L --setack 设置 TCP 确认号 (ack)\n"
|
||||
" -F --fin 设置 FIN 标志\n"
|
||||
" -S --syn 设置 SYN 标志\n"
|
||||
" -R --rst 设置 RST 标志\n"
|
||||
" -P --push 设置 PUSH 标志\n"
|
||||
" -A --ack 设置 ACK 标志\n"
|
||||
" -U --urg 设置 URG 标志\n"
|
||||
" -X --xmas 设置 X 未使用标志 (0x40)\n"
|
||||
" -Y --ymas 设置 Y 未使用标志 (0x80)\n"
|
||||
" --tcpexitcode 使用最后的 tcp->th_flags 作为退出代码\n"
|
||||
" --tcp-timestamp 启用 TCP 时间戳选项以猜测 HZ/系统运行时间\n"
|
||||
"通用\n"
|
||||
" -d --data 数据大小 (默认 0)\n"
|
||||
" -E --file 来自文件的数据\n"
|
||||
" -e --sign 添加 '签名'\n"
|
||||
" -j --dump 以十六进制转储数据包\n"
|
||||
" -J --print 转储可打印字符\n"
|
||||
" -B --safe 启用 '安全' 协议\n"
|
||||
" -u --end 当 --file 到达 EOF 时通知您并防止倒带\n"
|
||||
" -T --traceroute 路由跟踪模式 (隐含 --bind 和 --ttl 1)\n"
|
||||
" --tr-stop 在路由跟踪模式下接收到第一个非 ICMP 报文时退出\n"
|
||||
" --tr-keep-ttl 保持源 TTL 固定, 有助于只监控一个跳点\n"
|
||||
" --tr-no-rtt 在路由跟踪模式下不计算/显示 RTT 信息\n"
|
||||
"ARS 数据包描述 (新功能, 不稳定)\n"
|
||||
" --apd-send 发送由 APD 描述的数据包 (详见 docs/APD.txt)\n"
|
||||
);
|
||||
exit(0);
|
||||
};
|
||||
@@ -109,13 +108,13 @@ void show_usage(void)
|
||||
void tos_help(void)
|
||||
{
|
||||
printf(
|
||||
"tos help:\n"
|
||||
" TOS Name Hex Value Typical Uses\n"
|
||||
"TOS 帮助:\n"
|
||||
" TOS 名称 十六进制值 典型用途\n"
|
||||
"\n"
|
||||
" Minimum Delay 10 ftp, telnet\n"
|
||||
" Maximum Throughput 08 ftp-data\n"
|
||||
" Maximum Reliability 04 snmp\n"
|
||||
" Minimum Cost 02 nntp\n"
|
||||
" 最小延迟 (Minimum Delay) 10 ftp, telnet\n"
|
||||
" 最大吞吐量 (Maximum Throughput) 08 ftp-data\n"
|
||||
" 最大可靠性 (Maximum Reliability) 04 snmp\n"
|
||||
" 最小成本 (Minimum Cost) 02 nntp\n"
|
||||
);
|
||||
exit(0);
|
||||
}
|
||||
@@ -123,18 +122,18 @@ void tos_help(void)
|
||||
void icmp_help(void)
|
||||
{
|
||||
printf(
|
||||
"ICMP help:\n"
|
||||
" ICMP concerned packet options:\n"
|
||||
" --icmp-ipver set ip version ( default 4 )\n"
|
||||
" --icmp-iphlen set ip header lenght ( default IPHDR_SIZE >> 2)\n"
|
||||
" --icmp-iplen set ip total lengtht ( default real lenght )\n"
|
||||
" --icmp-ipid set ip id ( default random )\n"
|
||||
" --icmp-ipproto set ip protocol ( default IPPROTO_TCP )\n"
|
||||
" --icmp-ipsrc set ip source ( default 0.0.0.0 )\n"
|
||||
" --icmp-ipdst set ip destination ( default 0.0.0.0 )\n"
|
||||
" --icmp-srcport set tcp/udp source port ( default random )\n"
|
||||
" --icmp-dstport set tcp/udp destination port ( default random )\n"
|
||||
" --icmp-cksum set icmp checksum ( default the right cksum)\n"
|
||||
"ICMP 帮助:\n"
|
||||
" ICMP 关注的数据包选项:\n"
|
||||
" --icmp-ipver 设置 ip 版本 ( 默认 4 )\n"
|
||||
" --icmp-iphlen 设置 ip 头部长度 ( 默认 IPHDR_SIZE >> 2)\n"
|
||||
" --icmp-iplen 设置 ip 总长度 ( 默认实际长度 )\n"
|
||||
" --icmp-ipid 设置 ip id ( 默认随机 )\n"
|
||||
" --icmp-ipproto 设置 ip 协议 ( 默认 IPPROTO_TCP )\n"
|
||||
" --icmp-ipsrc 设置 ip 源地址 ( 默认 0.0.0.0 )\n"
|
||||
" --icmp-ipdst 设置 ip 目标地址 ( 默认 0.0.0.0 )\n"
|
||||
" --icmp-srcport 设置 tcp/udp 源端口 ( 默认随机 )\n"
|
||||
" --icmp-dstport 设置 tcp/udp 目标端口 ( 默认随机 )\n"
|
||||
" --icmp-cksum 设置 icmp 校验和 ( 默认正确的校验和)\n"
|
||||
);
|
||||
exit(0);
|
||||
}
|
||||
@@ -142,10 +141,9 @@ void icmp_help(void)
|
||||
void route_help(void)
|
||||
{
|
||||
printf(
|
||||
"route help:\n"
|
||||
" A route has the following format: [ptr:]IP1[/IP2[/IP3...]]\n"
|
||||
" where ptr is the exact value of the pointer that will be used for the IP\n"
|
||||
" option (be careful, no check is performed on this pointer), and defaults\n"
|
||||
" to 8, or 4 if provided route is too short for 8;\n"
|
||||
" and each IPx field is an IP address to include in the source route.\n");
|
||||
"路由帮助:\n"
|
||||
" 路由具有以下格式: [ptr:]IP1[/IP2[/IP3...]]\n"
|
||||
" 其中 ptr 是将用于 IP 选项的指针的确切值 (请注意, 对此指针不执行任何检查),\n"
|
||||
" 默认为 8, 或者如果提供的路由太短则为 4;\n"
|
||||
" 每个 IPx 字段是要包含在源路由中的 IP 地址。\n");
|
||||
}
|
||||
|
||||
+4
-3
@@ -220,7 +220,7 @@ log_ipv4(int status, int sequence)
|
||||
rel_id = relativize_id(sequence, &ip_id);
|
||||
else
|
||||
rel_id = 0;
|
||||
printf("len=%d ttl=%d %sid%s%d ", ip_size,
|
||||
printf("len=%d ip=%s ttl=%d %sid%s%d ", ip_size, inet_ntoa(src),
|
||||
ip->ttl,
|
||||
(ntohs(ip->frag_off) ? "DF " : ""),
|
||||
(rel_id ? "=+" : "="), ip_id);
|
||||
@@ -233,8 +233,9 @@ log_ipv6(int status, int sequence)
|
||||
{
|
||||
char tmp[1024];
|
||||
|
||||
printf("len=%d ttl=%d ", ip_size,
|
||||
printf("len=%d ip=%s ttl=%d ", ip_size, inet_ntop(opt_af, &src6, tmp, sizeof(tmp)),
|
||||
ip6->hoplimit);
|
||||
|
||||
if (opt_verbose && !opt_quiet)
|
||||
printf("tc=%x flowlabel=%u\n", (ip6->tc1 << 4) | ip6->tc2, (ip6->flowlabel1 << 16) | ip6->flowlabel2);
|
||||
}
|
||||
@@ -243,7 +244,7 @@ static void
|
||||
log_ip(int status, int sequence)
|
||||
{
|
||||
if(status == S_RECV){
|
||||
printf("[重复]DUP! ");
|
||||
printf("[DUP!] ");
|
||||
dup_count++;
|
||||
}
|
||||
if(ip->version == 4)
|
||||
|
||||
Reference in New Issue
Block a user