File: usage.c

package info (click to toggle)
hping2 2.rc3-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 756 kB
  • ctags: 951
  • sloc: ansic: 6,706; makefile: 110; sh: 83
file content (149 lines) | stat: -rw-r--r-- 6,411 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/* 
 * $smu-mark$ 
 * $name: usage.c$ 
 * $author: Salvatore Sanfilippo <antirez@invece.org>$ 
 * $copyright: Copyright (C) 1999 by Salvatore Sanfilippo$ 
 * $license: This software is under GPL version 2 of license$ 
 * $date: Fri Nov  5 11:55:50 MET 1999$ 
 * $rev: 8$ 
 */ 

/* $Id: usage.c,v 1.13 2003/08/07 23:55:55 antirez Exp $ */

#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>

void	show_usage(void)
{
	printf(
"usage: hping 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"
"  -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"
"  -8  --scan       SCAN mode.\n"
"                   Example: hping --scan 1-30,70-90 -S www.target.host\n"
"  -9  --listen     listen mode\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"
"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"
"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"
	);
	exit(0);
};

void tos_help(void)
{
	printf(
"tos help:\n"
"          TOS Name                Hex Value           Typical Uses\n"
"\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);
}

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"
	);
	exit(0);
}

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");
}