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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
Add tcp-mss support.
--- a/main.c
+++ b/main.c
@@ -44,7 +44,8 @@
signlen,
lsr_length = 0,
ssr_length = 0,
- tcp_ack;
+ tcp_ack,
+ tcp_mss;
unsigned short int
@@ -95,6 +96,7 @@
opt_tcpexitcode = FALSE,
opt_badcksum = FALSE,
opt_tr_keep_ttl = FALSE,
+ opt_tcp_mss = FALSE,
opt_tcp_timestamp = FALSE,
opt_tr_stop = FALSE,
opt_tr_no_rtt = FALSE,
--- a/globals.h
+++ b/globals.h
@@ -32,7 +32,8 @@
tcp_seqnum,
set_ack,
ip_header_length,
- tcp_ack;
+ tcp_ack,
+ tcp_mss;
extern unsigned short int
data_size;
@@ -77,6 +78,7 @@
opt_tcpexitcode,
opt_badcksum,
opt_tr_keep_ttl,
+ opt_tcp_mss,
opt_tcp_timestamp,
opt_tr_stop,
opt_tr_no_rtt,
--- a/parseoptions.c
+++ b/parseoptions.c
@@ -31,7 +31,7 @@
OPT_RROUTE, OPT_IPPROTO, OPT_ICMP_IPVER, OPT_ICMP_IPHLEN,
OPT_ICMP_IPLEN, OPT_ICMP_IPID, OPT_ICMP_IPPROTO, OPT_ICMP_CKSUM,
OPT_ICMP_TS, OPT_ICMP_ADDR, OPT_TCPEXITCODE, OPT_FAST, OPT_TR_KEEP_TTL,
- OPT_TCP_TIMESTAMP, OPT_TR_STOP, OPT_TR_NO_RTT, OPT_ICMP_HELP,
+ OPT_TCP_TIMESTAMP, OPT_TCP_MSS, OPT_TR_STOP, OPT_TR_NO_RTT, OPT_ICMP_HELP,
OPT_RAND_DEST, OPT_RAND_SOURCE, OPT_LSRR, OPT_SSRR, OPT_ROUTE_HELP,
OPT_ICMP_IPSRC, OPT_ICMP_IPDST, OPT_ICMP_SRCPORT, OPT_ICMP_DSTPORT,
OPT_ICMP_GW, OPT_FORCE_ICMP, OPT_APD_SEND, OPT_SCAN, OPT_FASTER,
@@ -124,6 +124,7 @@
{ '\0', "force-icmp", OPT_FORCE_ICMP, AGO_NOARG },
{ '\0', "beep", OPT_BEEP, AGO_NOARG },
{ '\0', "flood", OPT_FLOOD, AGO_NOARG },
+ { '\0', "tcp-mss", OPT_TCP_MSS, AGO_NEEDARG|AGO_EXCEPT0 },
AGO_LIST_TERM
};
@@ -556,6 +557,10 @@
case OPT_FLOOD:
opt_flood = TRUE;
break;
+ case OPT_TCP_MSS:
+ opt_tcp_mss = TRUE;
+ tcp_mss = strtoul(ago_optarg, NULL, 0);
+ break;
}
}
--- a/usage.c
+++ b/usage.c
@@ -87,6 +87,7 @@
" -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-mss enable the TCP MSS option with the given value\n"
" --tcp-timestamp enable the TCP timestamp option to guess the HZ/uptime\n"
"Common\n"
" -d --data data size (default is 0)\n"
--- a/sendtcp.c
+++ b/sendtcp.c
@@ -28,10 +28,12 @@
char *packet, *data;
struct mytcphdr *tcp;
struct pseudohdr *pseudoheader;
- unsigned char *tstamp;
+ unsigned char *opts;
+ if (opt_tcp_mss)
+ tcp_opt_size += 4;
if (opt_tcp_timestamp)
- tcp_opt_size = 12;
+ tcp_opt_size += 12;
packet_size = TCPHDR_SIZE + tcp_opt_size + data_size;
packet = malloc(PSEUDOHDR_SIZE + packet_size);
@@ -41,7 +43,7 @@
}
pseudoheader = (struct pseudohdr*) packet;
tcp = (struct mytcphdr*) (packet+PSEUDOHDR_SIZE);
- tstamp = (unsigned char*) (packet+PSEUDOHDR_SIZE+TCPHDR_SIZE);
+ opts = (unsigned char*) (packet+PSEUDOHDR_SIZE+TCPHDR_SIZE);
data = (char*) (packet+PSEUDOHDR_SIZE+TCPHDR_SIZE+tcp_opt_size);
memset(packet, 0, PSEUDOHDR_SIZE+packet_size);
@@ -64,14 +66,24 @@
tcp->th_win = htons(src_winsize);
tcp->th_flags = tcp_th_flags;
+ /* tcp MSS option */
+ if (opt_tcp_mss) {
+ opts[0] = 2;
+ opts[1] = 4; /* 4 bytes, kind+len+MSS */
+ opts[2] = tcp_mss >> 8;
+ opts[3] = tcp_mss & 0xff;
+ opts += 4;
+ }
+
/* tcp timestamp option */
if (opt_tcp_timestamp) {
__u32 randts = rand() ^ (rand() << 16);
- tstamp[0] = tstamp[1] = 1; /* NOOP */
- tstamp[2] = 8;
- tstamp[3] = 10; /* 10 bytes, kind+len+T1+T2 */
- memcpy(tstamp+4, &randts, 4); /* random */
- memset(tstamp+8, 0, 4); /* zero */
+ opts[0] = opts[1] = 1; /* NOOP */
+ opts[2] = 8;
+ opts[3] = 10; /* 10 bytes, kind+len+T1+T2 */
+ memcpy(opts+4, &randts, 4); /* random */
+ memset(opts+8, 0, 4); /* zero */
+ opts += 12;
}
/* data */
--- a/docs/hping3.8
+++ b/docs/hping3.8
@@ -98,6 +98,8 @@
] [
.B \-\-tcpexitcode
] [
+.B \-\-tcp-mss
+] [
.B \-\-tcp-timestamp
] [
.B \-\-tr-stop
@@ -510,6 +512,9 @@
.I -b --badcksum
Send packets with a bad UDP/TCP checksum.
.TP
+.I --tcp-mss
+Enable the TCP MSS option and set it to the given value.
+.TP
.I --tcp-timestamp
Enable the TCP timestamp option, and try to guess the timestamp update
frequency and the remote system uptime.
--- a/docs/french/hping2-fr.8
+++ b/docs/french/hping2-fr.8
@@ -99,6 +99,8 @@
] [
.B \-\-tcpexitcode
] [
+.B \-\-tcp-mss
+] [
.B \-\-tcp-timestamp
] [
.B \-\-tr-stop
@@ -549,6 +551,9 @@
.I -b --badcksum
Envoie des paquets avec une mauvaise somme de contrôle UDP/TCP
.TP
+.I --tcp-mss
+Active l'option TCP MSS et la fixe avec la valeur donnée.
+.TP
.I --tcp-timestamp
Active l'option TCP timestamp, et essaye de deviner la fréquence de mise à
jour du timestamp et l'uptime du système distant.
|