summaryrefslogtreecommitdiff
path: root/package/iptables/patches/008-chaostables.patch
blob: 60b077942a8a9fe57bb4a29843fe920e7ef89e21 (plain)
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
Index: iptables-1.3.8/extensions/.CHAOS-test
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ iptables-1.3.8/extensions/.CHAOS-test	2007-07-31 15:27:57.000000000 -0500
@@ -0,0 +1,2 @@
+#!/bin/sh
+[ -f "$KERNEL_DIR/include/linux/netfilter/xt_CHAOS.h" ] && echo "CHAOS";
Index: iptables-1.3.8/extensions/.DELUDE-test
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ iptables-1.3.8/extensions/.DELUDE-test	2007-07-31 15:27:57.000000000 -0500
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo "DELUDE";
Index: iptables-1.3.8/extensions/libipt_CHAOS.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ iptables-1.3.8/extensions/libipt_CHAOS.c	2007-07-31 15:27:57.000000000 -0500
@@ -0,0 +1,111 @@
+/*
+    CHAOS target for iptables
+
+    Copyright © Jan Engelhardt <jengelh [at] gmx de>, 2006 - 2007
+    released under the terms of the GNU General Public
+    License version 2.x and only versions 2.x.
+*/
+#include <getopt.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <iptables.h>
+#include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter/xt_CHAOS.h>
+
+static void libipt_chaos_help(void)
+{
+	printf(
+		"CHAOS target v%s options:\n"
+		"  --delude     Enable DELUDE processing for TCP\n"
+		"  --tarpit     Enable TARPIT processing for TCP\n",
+		IPTABLES_VERSION);
+	return;
+}
+
+static int libipt_chaos_parse(int c, char **argv, int invert,
+    unsigned int *flags, const struct ipt_entry *entry,
+    struct ipt_entry_target **target)
+{
+	struct xt_chaos_info *info = (void *)((*target)->data);
+	switch(c) {
+		case 'd':
+			info->variant = XTCHAOS_DELUDE;
+			*flags |= 0x02;
+			return 1;
+		case 't':
+			info->variant = XTCHAOS_TARPIT;
+			*flags |= 0x01;
+			return 1;
+	}
+	return 0;
+}
+
+static void libipt_chaos_check(unsigned int flags)
+{
+	if(flags != 0x03)
+		return;
+	/* If flags == 0x03, both were specified, which should not be. */
+	exit_error(PARAMETER_PROBLEM,
+	           "CHAOS: only one of --tarpit or --delude may be specified");
+	return;
+}
+
+static void libipt_chaos_print(const struct ipt_ip *ip,
+    const struct ipt_entry_target *target, int numeric)
+{
+	const struct xt_chaos_info *info = (const void *)target->data;
+	switch(info->variant) {
+		case XTCHAOS_DELUDE:
+			printf("DELUDE ");
+			break;
+		case XTCHAOS_TARPIT:
+			printf("TARPIT ");
+			break;
+		default:
+			break;
+	}
+	return;
+}
+
+static void libipt_chaos_save(const struct ipt_ip *ip,
+    const struct ipt_entry_target *target)
+{
+	const struct xt_chaos_info *info = (const void *)target->data;
+	switch(info->variant) {
+		case XTCHAOS_DELUDE:
+			printf("--delude ");
+			break;
+		case XTCHAOS_TARPIT:
+			printf("--tarpit ");
+			break;
+		default:
+			break;
+	}
+	return;
+}
+
+static struct option libipt_chaos_opts[] = {
+	{"delude", 0, NULL, 'd'},
+	{"tarpit", 0, NULL, 't'},
+	{NULL},
+};
+
+static struct iptables_target libipt_chaos_info = {
+	.name          = "CHAOS",
+	.version       = IPTABLES_VERSION,
+	.size          = IPT_ALIGN(sizeof(struct xt_chaos_info)),
+	.userspacesize = IPT_ALIGN(sizeof(struct xt_chaos_info)),
+	.help          = libipt_chaos_help,
+	.parse         = libipt_chaos_parse,
+	.final_check   = libipt_chaos_check,
+	.print         = libipt_chaos_print,
+	.save          = libipt_chaos_save,
+	.extra_opts    = libipt_chaos_opts,
+};
+
+static __attribute__((constructor)) void libipt_chaos_init(void)
+{
+	register_target(&libipt_chaos_info);
+	return;
+}
Index: iptables-1.3.8/extensions/libipt_DELUDE.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ iptables-1.3.8/extensions/libipt_DELUDE.c	2007-07-31 15:27:57.000000000 -0500
@@ -0,0 +1,66 @@
+/*
+    DELUDE target for iptables
+
+    Copyright © Jan Engelhardt <jengelh [at] gmx de>, 2006 - 2007
+    released under the terms of the GNU General Public
+    License version 2.x and only versions 2.x.
+*/
+#include <getopt.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <iptables.h>
+#include <linux/netfilter_ipv4/ip_tables.h>
+
+static void libipt_delude_help(void)
+{
+	printf("DELUDE takes no options\n");
+	return;
+}
+
+static int libipt_delude_parse(int c, char **argv, int invert,
+    unsigned int *flags, const struct ipt_entry *entry,
+    struct ipt_entry_target **target)
+{
+	return 0;
+}
+
+static void libipt_delude_check(unsigned int flags)
+{
+	return;
+}
+
+static void libipt_delude_print(const struct ipt_ip *ip,
+    const struct ipt_entry_target *target, int numeric)
+{
+	return;
+}
+
+static void libipt_delude_save(const struct ipt_ip *ip,
+    const struct ipt_entry_target *target)
+{
+	return;
+}
+
+static struct option libipt_delude_opts[] = {
+	{NULL},
+};
+
+static struct iptables_target libipt_delude_info = {
+	.name          = "DELUDE",
+	.version       = IPTABLES_VERSION,
+	.size          = IPT_ALIGN(0),
+	.userspacesize = IPT_ALIGN(0),
+	.help          = libipt_delude_help,
+	.parse         = libipt_delude_parse,
+	.final_check   = libipt_delude_check,
+	.print         = libipt_delude_print,
+	.save          = libipt_delude_save,
+	.extra_opts    = libipt_delude_opts,
+};
+
+static __attribute__((constructor)) void libipt_delude_init(void)
+{
+	register_target(&libipt_delude_info);
+	return;
+}
Index: iptables-1.3.8/extensions/libipt_portscan.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ iptables-1.3.8/extensions/libipt_portscan.c	2007-07-31 15:27:57.000000000 -0500
@@ -0,0 +1,129 @@
+/*
+    portscan match for iptables
+
+    Copyright © Jan Engelhardt <jengelh [at] gmx de>, 2006 - 2007
+    released under the terms of the GNU General Public
+    License version 2.x and only versions 2.x.
+*/
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <getopt.h>
+
+#include <iptables.h>
+#include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter/xt_portscan.h>
+
+static void libipt_portscan_help(void)
+{
+	printf(
+		"portscan match v%s options:\n"
+		"(Combining them will make them match by OR-logic)\n"
+		"  --stealth    Match TCP Stealth packets\n"
+		"  --synscan    Match TCP SYN scans\n"
+		"  --cnscan     Match TCP Connect scans\n"
+		"  --grscan     Match Banner Grabbing scans\n",
+		IPTABLES_VERSION);
+	return;
+}
+
+static void libipt_portscan_mtinit(struct ipt_entry_match *match,
+    unsigned int *nfcache)
+{
+	/* Cannot cache this */
+	*nfcache |= NFC_UNKNOWN;
+	return;
+}
+
+static int libipt_portscan_parse(int c, char **argv, int invert,
+    unsigned int *flags, const struct ipt_entry *entry, unsigned int *nfc,
+    struct ipt_entry_match **match)
+{
+	struct xt_portscan_info *info = (void *)((*match)->data);
+
+	switch(c) {
+		case 'c':
+			info->match_cn = 1;
+			return 1;
+		case 'g':
+			info->match_gr = 1;
+			return 1;
+		case 's':
+			info->match_syn = 1;
+			return 1;
+		case 'x':
+			info->match_stealth = 1;
+			return 1;
+		default:
+			return 0;
+	}
+}
+
+static void libipt_portscan_check(unsigned int flags)
+{
+	return;
+}
+
+static void libipt_portscan_print(const struct ipt_ip *ip,
+    const struct ipt_entry_match *match, int numeric)
+{
+	const struct xt_portscan_info *info = (const void *)(match->data);
+	const char *s = "";
+
+	printf("portscan ");
+	if(info->match_stealth) {
+		printf("STEALTH");
+		s = ",";
+	}
+	if(info->match_syn) {
+		printf("%sSYNSCAN", s);
+		s = ",";
+	}
+	if(info->match_cn) {
+		printf("%sCNSCAN", s);
+		s = ",";
+	}
+	if(info->match_gr)
+		printf("%sGRSCAN", s);
+	printf(" ");
+	return;
+}
+
+static void libipt_portscan_save(const struct ipt_ip *ip,
+    const struct ipt_entry_match *match)
+{
+	const struct xt_portscan_info *info = (const void *)(match->data);
+	if(info->match_stealth)	printf("--stealth ");
+	if(info->match_syn)	printf("--synscan ");
+	if(info->match_cn)	printf("--cnscan ");
+	if(info->match_gr)	printf("--grscan ");
+	return;
+}
+
+static struct option libipt_portscan_opts[] = {
+	{"stealth", 0, NULL, 'x'},
+	{"synscan", 0, NULL, 's'},
+	{"cnscan",  0, NULL, 'c'},
+	{"grscan",  0, NULL, 'g'},
+	{NULL},
+};
+
+static struct iptables_match libipt_portscan_info = {
+	.name          = "portscan",
+	.version       = IPTABLES_VERSION,
+	.size          = IPT_ALIGN(sizeof(struct xt_portscan_info)),
+	.userspacesize = IPT_ALIGN(sizeof(struct xt_portscan_info)),
+	.help          = libipt_portscan_help,
+	.init          = libipt_portscan_mtinit,
+	.parse         = libipt_portscan_parse,
+	.final_check   = libipt_portscan_check,
+	.print         = libipt_portscan_print,
+	.save          = libipt_portscan_save,
+	.extra_opts    = libipt_portscan_opts,
+};
+
+static __attribute__((constructor)) void libipt_portscan_init(void)
+{
+	register_match(&libipt_portscan_info);
+	return;
+}
Index: iptables-1.3.8/extensions/.portscan-test
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ iptables-1.3.8/extensions/.portscan-test	2007-07-31 15:27:57.000000000 -0500
@@ -0,0 +1,2 @@
+#!/bin/sh
+[ -f "$KERNEL_DIR/include/linux/netfilter/xt_portscan.h" ] && echo "portscan";