mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2025-04-21 12:27:27 +03:00
upgrade iptables to 1.4.1.1, needed for proper 2.6.27 support
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@13458 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
481
package/iptables/patches/1.4.1.1/001-ipp2p-0.8.1rc1.patch
Normal file
481
package/iptables/patches/1.4.1.1/001-ipp2p-0.8.1rc1.patch
Normal file
@@ -0,0 +1,481 @@
|
||||
diff -Nur iptables-1.4.1.1/extensions/.ipp2p-test iptables-1.4.1.1-owrt/extensions/.ipp2p-test
|
||||
--- iptables-1.4.1.1/extensions/.ipp2p-test 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ iptables-1.4.1.1-owrt/extensions/.ipp2p-test 2008-10-10 00:10:50.000000000 +0200
|
||||
@@ -0,0 +1,2 @@
|
||||
+#! /bin/sh
|
||||
+[ -f $KERNEL_DIR/include/linux/netfilter_ipv4/ipt_ipp2p.h ] && echo ipp2p
|
||||
diff -Nur iptables-1.4.1.1/extensions/libipt_ipp2p.c iptables-1.4.1.1-owrt/extensions/libipt_ipp2p.c
|
||||
--- iptables-1.4.1.1/extensions/libipt_ipp2p.c 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ iptables-1.4.1.1-owrt/extensions/libipt_ipp2p.c 2008-10-10 00:10:50.000000000 +0200
|
||||
@@ -0,0 +1,424 @@
|
||||
+#include <stdio.h>
|
||||
+#include <netdb.h>
|
||||
+#include <string.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <getopt.h>
|
||||
+#include <ctype.h>
|
||||
+
|
||||
+#include <iptables.h>
|
||||
+
|
||||
+#include <linux/netfilter_ipv4/ipt_ipp2p.h>
|
||||
+
|
||||
+#ifndef XTABLES_VERSION
|
||||
+#define XTABLES_VERSION IPTABLES_VERSION
|
||||
+#endif
|
||||
+
|
||||
+#ifdef IPT_LIB_DIR
|
||||
+#define xtables_target iptables_target
|
||||
+#define xtables_register_target register_target
|
||||
+#endif
|
||||
+
|
||||
+static void
|
||||
+help(void)
|
||||
+{
|
||||
+ printf(
|
||||
+ "IPP2P v%s options:\n"
|
||||
+ " --ipp2p Grab all known p2p packets\n"
|
||||
+ " --edk [TCP&UDP] All known eDonkey/eMule/Overnet packets\n"
|
||||
+ " --dc [TCP] All known Direct Connect packets\n"
|
||||
+ " --kazaa [TCP&UDP] All known KaZaA packets\n"
|
||||
+ " --gnu [TCP&UDP] All known Gnutella packets\n"
|
||||
+ " --bit [TCP&UDP] All known BitTorrent packets\n"
|
||||
+ " --apple [TCP] All known AppleJuice packets\n"
|
||||
+ " --winmx [TCP] All known WinMX\n"
|
||||
+ " --soul [TCP] All known SoulSeek\n"
|
||||
+ " --ares [TCP] All known Ares\n\n"
|
||||
+ " EXPERIMENTAL protocols (please send feedback to: ipp2p@ipp2p.org) :\n"
|
||||
+ " --mute [TCP] All known Mute packets\n"
|
||||
+ " --waste [TCP] All known Waste packets\n"
|
||||
+ " --xdcc [TCP] All known XDCC packets (only xdcc login)\n\n"
|
||||
+ " DEBUG SUPPPORT, use only if you know why\n"
|
||||
+ " --debug Generate kernel debug output, THIS WILL SLOW DOWN THE FILTER\n"
|
||||
+ "\nNote that the follwing options will have the same meaning:\n"
|
||||
+ " '--ipp2p' is equal to '--edk --dc --kazaa --gnu --bit --apple --winmx --soul --ares'\n"
|
||||
+ "\nIPP2P was intended for TCP only. Due to increasing usage of UDP we needed to change this.\n"
|
||||
+ "You can now use -p udp to search UDP packets only or without -p switch to search UDP and TCP packets.\n"
|
||||
+ "\nSee README included with this package for more details or visit http://www.ipp2p.org\n"
|
||||
+ "\nExamples:\n"
|
||||
+ " iptables -A FORWARD -m ipp2p --ipp2p -j MARK --set-mark 0x01\n"
|
||||
+ " iptables -A FORWARD -p udp -m ipp2p --kazaa --bit -j DROP\n"
|
||||
+ " iptables -A FORWARD -p tcp -m ipp2p --edk --soul -j DROP\n\n"
|
||||
+ , IPP2P_VERSION);
|
||||
+}
|
||||
+
|
||||
+static struct option opts[] = {
|
||||
+ { "ipp2p", 0, 0, '1' },
|
||||
+ { "edk", 0, 0, '2' },
|
||||
+ { "dc", 0, 0, '7' },
|
||||
+ { "gnu", 0, 0, '9' },
|
||||
+ { "kazaa", 0, 0, 'a' },
|
||||
+ { "bit", 0, 0, 'b' },
|
||||
+ { "apple", 0, 0, 'c' },
|
||||
+ { "soul", 0, 0, 'd' },
|
||||
+ { "winmx", 0, 0, 'e' },
|
||||
+ { "ares", 0, 0, 'f' },
|
||||
+ { "mute", 0, 0, 'g' },
|
||||
+ { "waste", 0, 0, 'h' },
|
||||
+ { "xdcc", 0, 0, 'i' },
|
||||
+ { "debug", 0, 0, 'j' },
|
||||
+ {0}
|
||||
+};
|
||||
+
|
||||
+
|
||||
+static void
|
||||
+#ifdef _XTABLES_H
|
||||
+init(struct xt_entry_match *m)
|
||||
+#else
|
||||
+init(struct ipt_entry_match *t, unsigned int *nfcache)
|
||||
+#endif
|
||||
+{
|
||||
+ struct ipt_p2p_info *info = (struct ipt_p2p_info *)m->data;
|
||||
+
|
||||
+#ifndef _XTABLES_H
|
||||
+ *nfcache |= NFC_UNKNOWN;
|
||||
+#endif
|
||||
+
|
||||
+ /*init the module with default values*/
|
||||
+ info->cmd = 0;
|
||||
+ info->debug = 0;
|
||||
+
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static int
|
||||
+parse(int c, char **argv, int invert, unsigned int *flags,
|
||||
+#ifdef _XTABLES_H
|
||||
+ const void *entry, struct xt_entry_match **match)
|
||||
+#else
|
||||
+ const struct ipt_entry *entry, unsigned int *nfcache, struct ipt_entry_match **match)
|
||||
+#endif
|
||||
+{
|
||||
+ struct ipt_p2p_info *info = (struct ipt_p2p_info *)(*match)->data;
|
||||
+
|
||||
+ switch (c) {
|
||||
+ case '1': /*cmd: ipp2p*/
|
||||
+ if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: `--ipp2p' may only be "
|
||||
+ "specified once!");
|
||||
+
|
||||
+/* if ((*flags & SHORT_HAND_DATA) == SHORT_HAND_DATA)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: `--ipp2p-data' may only be "
|
||||
+ "specified alone!");
|
||||
+*/
|
||||
+
|
||||
+ if ((*flags) != 0)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: `--ipp2p' may only be "
|
||||
+ "specified alone!");
|
||||
+ if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
|
||||
+ *flags += SHORT_HAND_IPP2P;
|
||||
+ info->cmd = *flags;
|
||||
+ break;
|
||||
+
|
||||
+ case '2': /*cmd: edk*/
|
||||
+ if ((*flags & IPP2P_EDK) == IPP2P_EDK)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: `--edk' may only be "
|
||||
+ "specified once");
|
||||
+ if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: `--ipp2p' may only be "
|
||||
+ "specified alone!");
|
||||
+/* if ((*flags & SHORT_HAND_DATA) == SHORT_HAND_DATA)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: `--ipp2p-data' may only be "
|
||||
+ "specified alone!");*/
|
||||
+ if ((*flags & IPP2P_DATA_EDK) == IPP2P_DATA_EDK)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: use `--edk' OR `--edk-data' but not both of them!");
|
||||
+ if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
|
||||
+ *flags += IPP2P_EDK;
|
||||
+ info->cmd = *flags;
|
||||
+ break;
|
||||
+
|
||||
+
|
||||
+ case '7': /*cmd: dc*/
|
||||
+ if ((*flags & IPP2P_DC) == IPP2P_DC)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: `--dc' may only be "
|
||||
+ "specified once!");
|
||||
+ if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: `--ipp2p' may only be "
|
||||
+ "specified alone!");
|
||||
+/* if ((*flags & SHORT_HAND_DATA) == SHORT_HAND_DATA)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: `--ipp2p-data' may only be "
|
||||
+ "specified alone!");*/
|
||||
+ if ((*flags & IPP2P_DATA_DC) == IPP2P_DATA_DC)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: use `--dc' OR `--dc-data' but not both of them!");
|
||||
+ if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
|
||||
+ *flags += IPP2P_DC;
|
||||
+ info->cmd = *flags;
|
||||
+ break;
|
||||
+
|
||||
+
|
||||
+ case '9': /*cmd: gnu*/
|
||||
+ if ((*flags & IPP2P_GNU) == IPP2P_GNU)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: `--gnu' may only be "
|
||||
+ "specified once!");
|
||||
+/* if ((*flags & SHORT_HAND_DATA) == SHORT_HAND_DATA)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: `--ipp2p-data' may only be "
|
||||
+ "specified alone!");*/
|
||||
+ if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: `--ipp2p' may only be "
|
||||
+ "specified alone!");
|
||||
+ if ((*flags & IPP2P_DATA_GNU) == IPP2P_DATA_GNU)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: use `--gnu' OR `--gnu-data' but not both of them!");
|
||||
+ if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
|
||||
+ *flags += IPP2P_GNU;
|
||||
+ info->cmd = *flags;
|
||||
+ break;
|
||||
+
|
||||
+ case 'a': /*cmd: kazaa*/
|
||||
+ if ((*flags & IPP2P_KAZAA) == IPP2P_KAZAA)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: `--kazaa' may only be "
|
||||
+ "specified once!");
|
||||
+/* if ((*flags & SHORT_HAND_DATA) == SHORT_HAND_DATA)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: `--ipp2p-data' may only be "
|
||||
+ "specified alone!");*/
|
||||
+ if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: `--ipp2p' may only be "
|
||||
+ "specified alone!");
|
||||
+ if ((*flags & IPP2P_DATA_KAZAA) == IPP2P_DATA_KAZAA)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: use `--kazaa' OR `--kazaa-data' but not both of them!");
|
||||
+ if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
|
||||
+ *flags += IPP2P_KAZAA;
|
||||
+ info->cmd = *flags;
|
||||
+ break;
|
||||
+
|
||||
+ case 'b': /*cmd: bit*/
|
||||
+ if ((*flags & IPP2P_BIT) == IPP2P_BIT)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: `--bit' may only be "
|
||||
+ "specified once!");
|
||||
+ if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: `--ipp2p' may only be "
|
||||
+ "specified alone!");
|
||||
+ if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
|
||||
+ *flags += IPP2P_BIT;
|
||||
+ info->cmd = *flags;
|
||||
+ break;
|
||||
+
|
||||
+ case 'c': /*cmd: apple*/
|
||||
+ if ((*flags & IPP2P_APPLE) == IPP2P_APPLE)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: `--apple' may only be "
|
||||
+ "specified once!");
|
||||
+ if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: `--ipp2p' may only be "
|
||||
+ "specified alone!");
|
||||
+ if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
|
||||
+ *flags += IPP2P_APPLE;
|
||||
+ info->cmd = *flags;
|
||||
+ break;
|
||||
+
|
||||
+
|
||||
+ case 'd': /*cmd: soul*/
|
||||
+ if ((*flags & IPP2P_SOUL) == IPP2P_SOUL)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: `--soul' may only be "
|
||||
+ "specified once!");
|
||||
+ if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: `--ipp2p' may only be "
|
||||
+ "specified alone!");
|
||||
+ if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
|
||||
+ *flags += IPP2P_SOUL;
|
||||
+ info->cmd = *flags;
|
||||
+ break;
|
||||
+
|
||||
+
|
||||
+ case 'e': /*cmd: winmx*/
|
||||
+ if ((*flags & IPP2P_WINMX) == IPP2P_WINMX)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: `--winmx' may only be "
|
||||
+ "specified once!");
|
||||
+ if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: `--ipp2p' may only be "
|
||||
+ "specified alone!");
|
||||
+ if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
|
||||
+ *flags += IPP2P_WINMX;
|
||||
+ info->cmd = *flags;
|
||||
+ break;
|
||||
+
|
||||
+ case 'f': /*cmd: ares*/
|
||||
+ if ((*flags & IPP2P_ARES) == IPP2P_ARES)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: `--ares' may only be "
|
||||
+ "specified once!");
|
||||
+ if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: `--ipp2p' may only be "
|
||||
+ "specified alone!");
|
||||
+ if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
|
||||
+ *flags += IPP2P_ARES;
|
||||
+ info->cmd = *flags;
|
||||
+ break;
|
||||
+
|
||||
+ case 'g': /*cmd: mute*/
|
||||
+ if ((*flags & IPP2P_MUTE) == IPP2P_MUTE)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: `--mute' may only be "
|
||||
+ "specified once!");
|
||||
+ if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
|
||||
+ *flags += IPP2P_MUTE;
|
||||
+ info->cmd = *flags;
|
||||
+ break;
|
||||
+ case 'h': /*cmd: waste*/
|
||||
+ if ((*flags & IPP2P_WASTE) == IPP2P_WASTE)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: `--waste' may only be "
|
||||
+ "specified once!");
|
||||
+ if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
|
||||
+ *flags += IPP2P_WASTE;
|
||||
+ info->cmd = *flags;
|
||||
+ break;
|
||||
+ case 'i': /*cmd: xdcc*/
|
||||
+ if ((*flags & IPP2P_XDCC) == IPP2P_XDCC)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "ipp2p: `--ares' may only be "
|
||||
+ "specified once!");
|
||||
+ if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
|
||||
+ *flags += IPP2P_XDCC;
|
||||
+ info->cmd = *flags;
|
||||
+ break;
|
||||
+
|
||||
+ case 'j': /*cmd: debug*/
|
||||
+ if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
|
||||
+ info->debug = 1;
|
||||
+ break;
|
||||
+
|
||||
+ default:
|
||||
+// exit_error(PARAMETER_PROBLEM,
|
||||
+// "\nipp2p-parameter problem: for ipp2p usage type: iptables -m ipp2p --help\n");
|
||||
+ return 0;
|
||||
+ }
|
||||
+ return 1;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static void
|
||||
+final_check(unsigned int flags)
|
||||
+{
|
||||
+ if (!flags)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "\nipp2p-parameter problem: for ipp2p usage type: iptables -m ipp2p --help\n");
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+#ifdef _XTABLES_H
|
||||
+print(const void *ip,
|
||||
+ const struct xt_entry_match *match,
|
||||
+#else
|
||||
+print(const struct ipt_ip *ip,
|
||||
+ const struct ipt_entry_match *match,
|
||||
+#endif
|
||||
+ int numeric)
|
||||
+{
|
||||
+ struct ipt_p2p_info *info = (struct ipt_p2p_info *)match->data;
|
||||
+
|
||||
+ printf("ipp2p v%s", IPP2P_VERSION);
|
||||
+ if ((info->cmd & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P) printf(" --ipp2p");
|
||||
+// if ((info->cmd & SHORT_HAND_DATA) == SHORT_HAND_DATA) printf(" --ipp2p-data");
|
||||
+ if ((info->cmd & IPP2P_KAZAA) == IPP2P_KAZAA) printf(" --kazaa");
|
||||
+// if ((info->cmd & IPP2P_DATA_KAZAA) == IPP2P_DATA_KAZAA) printf(" --kazaa-data");
|
||||
+// if ((info->cmd & IPP2P_DATA_GNU) == IPP2P_DATA_GNU) printf(" --gnu-data");
|
||||
+ if ((info->cmd & IPP2P_GNU) == IPP2P_GNU) printf(" --gnu");
|
||||
+ if ((info->cmd & IPP2P_EDK) == IPP2P_EDK) printf(" --edk");
|
||||
+// if ((info->cmd & IPP2P_DATA_EDK) == IPP2P_DATA_EDK) printf(" --edk-data");
|
||||
+// if ((info->cmd & IPP2P_DATA_DC) == IPP2P_DATA_DC) printf(" --dc-data");
|
||||
+ if ((info->cmd & IPP2P_DC) == IPP2P_DC) printf(" --dc");
|
||||
+ if ((info->cmd & IPP2P_BIT) == IPP2P_BIT) printf(" --bit");
|
||||
+ if ((info->cmd & IPP2P_APPLE) == IPP2P_APPLE) printf(" --apple");
|
||||
+ if ((info->cmd & IPP2P_SOUL) == IPP2P_SOUL) printf(" --soul");
|
||||
+ if ((info->cmd & IPP2P_WINMX) == IPP2P_WINMX) printf(" --winmx");
|
||||
+ if ((info->cmd & IPP2P_ARES) == IPP2P_ARES) printf(" --ares");
|
||||
+ if ((info->cmd & IPP2P_MUTE) == IPP2P_MUTE) printf(" --mute");
|
||||
+ if ((info->cmd & IPP2P_WASTE) == IPP2P_WASTE) printf(" --waste");
|
||||
+ if ((info->cmd & IPP2P_XDCC) == IPP2P_XDCC) printf(" --xdcc");
|
||||
+ if (info->debug != 0) printf(" --debug");
|
||||
+ printf(" ");
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+#ifdef _XTABLES_H
|
||||
+save(const void *ip,
|
||||
+ const struct xt_entry_match *match)
|
||||
+#else
|
||||
+save(const struct ipt_ip *ip,
|
||||
+ const struct ipt_entry_match *match)
|
||||
+#endif
|
||||
+{
|
||||
+ struct ipt_p2p_info *info = (struct ipt_p2p_info *)match->data;
|
||||
+
|
||||
+ if ((info->cmd & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P) printf("--ipp2p ");
|
||||
+// if ((info->cmd & SHORT_HAND_DATA) == SHORT_HAND_DATA) printf("--ipp2p-data ");
|
||||
+ if ((info->cmd & IPP2P_KAZAA) == IPP2P_KAZAA) printf("--kazaa ");
|
||||
+// if ((info->cmd & IPP2P_DATA_KAZAA) == IPP2P_DATA_KAZAA) printf("--kazaa-data ");
|
||||
+// if ((info->cmd & IPP2P_DATA_GNU) == IPP2P_DATA_GNU) printf("--gnu-data ");
|
||||
+ if ((info->cmd & IPP2P_GNU) == IPP2P_GNU) printf("--gnu ");
|
||||
+ if ((info->cmd & IPP2P_EDK) == IPP2P_EDK) printf("--edk ");
|
||||
+// if ((info->cmd & IPP2P_DATA_EDK) == IPP2P_DATA_EDK) printf("--edk-data ");
|
||||
+// if ((info->cmd & IPP2P_DATA_DC) == IPP2P_DATA_DC) printf("--dc-data ");
|
||||
+ if ((info->cmd & IPP2P_DC) == IPP2P_DC) printf("--dc ");
|
||||
+ if ((info->cmd & IPP2P_BIT) == IPP2P_BIT) printf("--bit ");
|
||||
+ if ((info->cmd & IPP2P_APPLE) == IPP2P_APPLE) printf("--apple ");
|
||||
+ if ((info->cmd & IPP2P_SOUL) == IPP2P_SOUL) printf("--soul ");
|
||||
+ if ((info->cmd & IPP2P_WINMX) == IPP2P_WINMX) printf("--winmx ");
|
||||
+ if ((info->cmd & IPP2P_ARES) == IPP2P_ARES) printf("--ares ");
|
||||
+ if ((info->cmd & IPP2P_MUTE) == IPP2P_MUTE) printf(" --mute");
|
||||
+ if ((info->cmd & IPP2P_WASTE) == IPP2P_WASTE) printf(" --waste");
|
||||
+ if ((info->cmd & IPP2P_XDCC) == IPP2P_XDCC) printf(" --xdcc");
|
||||
+ if (info->debug != 0) printf("--debug ");
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static
|
||||
+struct xtables_match ipp2p=
|
||||
+{
|
||||
+ .next = NULL,
|
||||
+ .name = "ipp2p",
|
||||
+ .version = XTABLES_VERSION,
|
||||
+ .size = IPT_ALIGN(sizeof(struct ipt_p2p_info)),
|
||||
+ .userspacesize = IPT_ALIGN(sizeof(struct ipt_p2p_info)),
|
||||
+ .help = &help,
|
||||
+ .init = &init,
|
||||
+ .parse = &parse,
|
||||
+ .final_check = &final_check,
|
||||
+ .print = &print,
|
||||
+ .save = &save,
|
||||
+ .extra_opts = opts
|
||||
+};
|
||||
+
|
||||
+
|
||||
+
|
||||
+void _init(void)
|
||||
+{
|
||||
+ xtables_register_match(&ipp2p);
|
||||
+}
|
||||
+
|
||||
diff -Nur iptables-1.4.1.1/extensions/libipt_ipp2p.man iptables-1.4.1.1-owrt/extensions/libipt_ipp2p.man
|
||||
--- iptables-1.4.1.1/extensions/libipt_ipp2p.man 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ iptables-1.4.1.1-owrt/extensions/libipt_ipp2p.man 2008-10-10 00:10:50.000000000 +0200
|
||||
@@ -0,0 +1,43 @@
|
||||
+This module matches certain packets in P2P flows. It is not
|
||||
+designed to match all packets belonging to a P2P connection -
|
||||
+use IPP2P together with CONNMARK for this purpose. Also visit
|
||||
+http://www.ipp2p.org for detailed information.
|
||||
+
|
||||
+Use it together with -p tcp or -p udp to search these protocols
|
||||
+only or without -p switch to search packets of both protocols.
|
||||
+
|
||||
+IPP2P provides the following options:
|
||||
+.TP
|
||||
+.B "--edk "
|
||||
+Matches as many eDonkey/eMule packets as possible.
|
||||
+.TP
|
||||
+.B "--kazaa "
|
||||
+Matches as many KaZaA packets as possible.
|
||||
+.TP
|
||||
+.B "--gnu "
|
||||
+Matches as many Gnutella packets as possible.
|
||||
+.TP
|
||||
+.B "--dc "
|
||||
+Matches as many Direct Connect packets as possible.
|
||||
+.TP
|
||||
+.B "--bit "
|
||||
+Matches BitTorrent packets.
|
||||
+.TP
|
||||
+.B "--apple "
|
||||
+Matches AppleJuice packets.
|
||||
+.TP
|
||||
+.B "--soul "
|
||||
+Matches some SoulSeek packets. Considered as beta, use careful!
|
||||
+.TP
|
||||
+.B "--winmx "
|
||||
+Matches some WinMX packets. Considered as beta, use careful!
|
||||
+.TP
|
||||
+.B "--ares "
|
||||
+Matches Ares and AresLite packets. Use together with -j DROP only.
|
||||
+.TP
|
||||
+.B "--ipp2p "
|
||||
+Short hand for: --edk --kazaa --gnu --dc
|
||||
+.TP
|
||||
+.B "--debug "
|
||||
+Prints some information about each hit into kernel logfile. May
|
||||
+produce huge logfiles so beware!
|
||||
390
package/iptables/patches/1.4.1.1/002-layer7_2.17.patch
Normal file
390
package/iptables/patches/1.4.1.1/002-layer7_2.17.patch
Normal file
@@ -0,0 +1,390 @@
|
||||
diff -Nur iptables.old/extensions/libxt_layer7.c iptables.new/extensions/libxt_layer7.c
|
||||
--- iptables.old/extensions/libxt_layer7.c 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ iptables.new/extensions/libxt_layer7.c 2008-08-22 16:00:52.000000000 +0200
|
||||
@@ -0,0 +1,368 @@
|
||||
+/*
|
||||
+ Shared library add-on to iptables for layer 7 matching support.
|
||||
+
|
||||
+ By Matthew Strait <quadong@users.sf.net>, Oct 2003-Aug 2008.
|
||||
+
|
||||
+ http://l7-filter.sf.net
|
||||
+
|
||||
+ This program is free software; you can redistribute it and/or
|
||||
+ modify it under the terms of the GNU General Public License
|
||||
+ as published by the Free Software Foundation; either version
|
||||
+ 2 of the License, or (at your option) any later version.
|
||||
+ http://www.gnu.org/licenses/gpl.txt
|
||||
+*/
|
||||
+
|
||||
+#define _GNU_SOURCE
|
||||
+#include <stdio.h>
|
||||
+#include <netdb.h>
|
||||
+#include <string.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <getopt.h>
|
||||
+#include <ctype.h>
|
||||
+#include <dirent.h>
|
||||
+
|
||||
+#include <xtables.h>
|
||||
+#include <linux/netfilter/xt_layer7.h>
|
||||
+
|
||||
+#define MAX_FN_LEN 256
|
||||
+
|
||||
+static char l7dir[MAX_FN_LEN] = "\0";
|
||||
+
|
||||
+/* Function which prints out usage message. */
|
||||
+static void help(void)
|
||||
+{
|
||||
+ printf(
|
||||
+ "layer7 match options:\n"
|
||||
+ " --l7dir <directory> : Look for patterns here instead of /etc/l7-protocols/\n"
|
||||
+ " (--l7dir must be specified before --l7proto if used)\n"
|
||||
+ "[!] --l7proto <name>: Match named protocol using /etc/l7-protocols/.../name.pat\n");
|
||||
+}
|
||||
+
|
||||
+static const struct option opts[] = {
|
||||
+ { .name = "l7proto", .has_arg = 1, .val = 'p' },
|
||||
+ { .name = "l7dir", .has_arg = 1, .val = 'd' },
|
||||
+ { .name = NULL }
|
||||
+};
|
||||
+
|
||||
+/* reads filename, puts protocol info into layer7_protocol_info, number of protocols to numprotos */
|
||||
+static int parse_protocol_file(char * filename, const char * protoname, struct xt_layer7_info *info)
|
||||
+{
|
||||
+ FILE * f;
|
||||
+ char * line = NULL;
|
||||
+ size_t len = 0;
|
||||
+
|
||||
+ enum { protocol, pattern, done } datatype = protocol;
|
||||
+
|
||||
+ f = fopen(filename, "r");
|
||||
+
|
||||
+ if(!f)
|
||||
+ return 0;
|
||||
+
|
||||
+ while(getline(&line, &len, f) != -1)
|
||||
+ {
|
||||
+ if(strlen(line) < 2 || line[0] == '#')
|
||||
+ continue;
|
||||
+
|
||||
+ /* strip the pesky newline... */
|
||||
+ if(line[strlen(line) - 1] == '\n')
|
||||
+ line[strlen(line) - 1] = '\0';
|
||||
+
|
||||
+ if(datatype == protocol)
|
||||
+ {
|
||||
+ /* Ignore everything on the line beginning with the
|
||||
+ first space or tab . For instance, this allows the
|
||||
+ protocol line in http.pat to be "http " (or
|
||||
+ "http I am so cool") instead of just "http". */
|
||||
+ if(strchr(line, ' ')){
|
||||
+ char * space = strchr(line, ' ');
|
||||
+ space[0] = '\0';
|
||||
+ }
|
||||
+ if(strchr(line, '\t')){
|
||||
+ char * space = strchr(line, '\t');
|
||||
+ space[0] = '\0';
|
||||
+ }
|
||||
+
|
||||
+ /* sanity check. First non-comment non-blank
|
||||
+ line must be the same as the file name. */
|
||||
+ if(strcmp(line, protoname))
|
||||
+ exit_error(OTHER_PROBLEM,
|
||||
+ "Protocol name (%s) doesn't match file name (%s). Bailing out\n",
|
||||
+ line, filename);
|
||||
+
|
||||
+ if(strlen(line) >= MAX_PROTOCOL_LEN)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "Protocol name in %s too long!", filename);
|
||||
+ strncpy(info->protocol, line, MAX_PROTOCOL_LEN);
|
||||
+
|
||||
+ datatype = pattern;
|
||||
+ }
|
||||
+ else if(datatype == pattern)
|
||||
+ {
|
||||
+ if(strlen(line) >= MAX_PATTERN_LEN)
|
||||
+ exit_error(PARAMETER_PROBLEM, "Pattern in %s too long!", filename);
|
||||
+ strncpy(info->pattern, line, MAX_PATTERN_LEN);
|
||||
+
|
||||
+ datatype = done;
|
||||
+ break;
|
||||
+ }
|
||||
+ else
|
||||
+ exit_error(OTHER_PROBLEM, "Internal error");
|
||||
+ }
|
||||
+
|
||||
+ if(datatype != done)
|
||||
+ exit_error(OTHER_PROBLEM, "Failed to get all needed data from %s", filename);
|
||||
+
|
||||
+ if(line) free(line);
|
||||
+ fclose(f);
|
||||
+
|
||||
+ return 1;
|
||||
+}
|
||||
+
|
||||
+static int hex2dec(char c)
|
||||
+{
|
||||
+ switch (c)
|
||||
+ {
|
||||
+ case '0' ... '9':
|
||||
+ return c - '0';
|
||||
+ case 'a' ... 'f':
|
||||
+ return c - 'a' + 10;
|
||||
+ case 'A' ... 'F':
|
||||
+ return c - 'A' + 10;
|
||||
+ default:
|
||||
+ exit_error(OTHER_PROBLEM, "hex2dec: bad value!\n");
|
||||
+ return 0;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+/* takes a string with \xHH escapes and returns one with the characters
|
||||
+they stand for */
|
||||
+static char * pre_process(char * s)
|
||||
+{
|
||||
+ char * result = malloc(strlen(s) + 1);
|
||||
+ int sindex = 0, rrindex = 0;
|
||||
+ while( sindex < strlen(s) )
|
||||
+ {
|
||||
+ if( sindex + 3 < strlen(s) &&
|
||||
+ s[sindex] == '\\' && s[sindex+1] == 'x' &&
|
||||
+ isxdigit(s[sindex + 2]) && isxdigit(s[sindex + 3]) )
|
||||
+ {
|
||||
+ /* carefully remember to call tolower here... */
|
||||
+ result[rrindex] = tolower( hex2dec(s[sindex + 2])*16 +
|
||||
+ hex2dec(s[sindex + 3] ) );
|
||||
+
|
||||
+ switch ( result[rrindex] )
|
||||
+ {
|
||||
+ case 0x24:
|
||||
+ case 0x28:
|
||||
+ case 0x29:
|
||||
+ case 0x2a:
|
||||
+ case 0x2b:
|
||||
+ case 0x2e:
|
||||
+ case 0x3f:
|
||||
+ case 0x5b:
|
||||
+ case 0x5c:
|
||||
+ case 0x5d:
|
||||
+ case 0x5e:
|
||||
+ case 0x7c:
|
||||
+ fprintf(stderr,
|
||||
+ "Warning: layer7 regexp contains a control character, %c, in hex (\\x%c%c).\n"
|
||||
+ "I recommend that you write this as %c or \\%c, depending on what you meant.\n",
|
||||
+ result[rrindex], s[sindex + 2], s[sindex + 3], result[rrindex], result[rrindex]);
|
||||
+ break;
|
||||
+ case 0x00:
|
||||
+ fprintf(stderr,
|
||||
+ "Warning: null (\\x00) in layer7 regexp. A null terminates the regexp string!\n");
|
||||
+ break;
|
||||
+ default:
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ sindex += 3; /* 4 total */
|
||||
+ }
|
||||
+ else
|
||||
+ result[rrindex] = tolower(s[sindex]);
|
||||
+
|
||||
+ sindex++;
|
||||
+ rrindex++;
|
||||
+ }
|
||||
+ result[rrindex] = '\0';
|
||||
+
|
||||
+ return result;
|
||||
+}
|
||||
+
|
||||
+#define MAX_SUBDIRS 128
|
||||
+static char ** readl7dir(char * dirname)
|
||||
+{
|
||||
+ DIR * scratchdir;
|
||||
+ struct dirent ** namelist;
|
||||
+ char ** subdirs = malloc(MAX_SUBDIRS * sizeof(char *));
|
||||
+
|
||||
+ int n, d = 1;
|
||||
+ subdirs[0] = "";
|
||||
+
|
||||
+ n = scandir(dirname, &namelist, 0, alphasort);
|
||||
+
|
||||
+ if (n < 0)
|
||||
+ {
|
||||
+ perror("scandir");
|
||||
+ exit_error(OTHER_PROBLEM, "Couldn't open %s\n", dirname);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ while(n--)
|
||||
+ {
|
||||
+ char fulldirname[MAX_FN_LEN];
|
||||
+
|
||||
+ snprintf(fulldirname, MAX_FN_LEN, "%s/%s", dirname, namelist[n]->d_name);
|
||||
+
|
||||
+ if((scratchdir = opendir(fulldirname)) != NULL)
|
||||
+ {
|
||||
+ closedir(scratchdir);
|
||||
+
|
||||
+ if(!strcmp(namelist[n]->d_name, ".") ||
|
||||
+ !strcmp(namelist[n]->d_name, ".."))
|
||||
+ /* do nothing */ ;
|
||||
+ else
|
||||
+ {
|
||||
+ subdirs[d] = malloc(strlen(namelist[n]->d_name) + 1);
|
||||
+ strcpy(subdirs[d], namelist[n]->d_name);
|
||||
+ d++;
|
||||
+ if(d >= MAX_SUBDIRS - 1)
|
||||
+ {
|
||||
+ fprintf(stderr,
|
||||
+ "Too many subdirectories, skipping the rest!\n");
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ free(namelist[n]);
|
||||
+ }
|
||||
+ free(namelist);
|
||||
+ }
|
||||
+
|
||||
+ subdirs[d] = NULL;
|
||||
+
|
||||
+ return subdirs;
|
||||
+}
|
||||
+
|
||||
+static void parse_layer7_protocol(const char *s, struct xt_layer7_info *info)
|
||||
+{
|
||||
+ char filename[MAX_FN_LEN];
|
||||
+ char * dir = NULL;
|
||||
+ char ** subdirs;
|
||||
+ int n = 0, done = 0;
|
||||
+
|
||||
+ if(strlen(l7dir) > 0) dir = l7dir;
|
||||
+ else dir = "/etc/l7-protocols";
|
||||
+
|
||||
+ subdirs = readl7dir(dir);
|
||||
+
|
||||
+ while(subdirs[n] != NULL)
|
||||
+ {
|
||||
+ int c = snprintf(filename, MAX_FN_LEN, "%s/%s/%s.pat", dir, subdirs[n], s);
|
||||
+
|
||||
+ if(c > MAX_FN_LEN)
|
||||
+ exit_error(OTHER_PROBLEM,
|
||||
+ "Filename beginning with %s is too long!\n", filename);
|
||||
+
|
||||
+ /* read in the pattern from the file */
|
||||
+ if(parse_protocol_file(filename, s, info)){
|
||||
+ done = 1;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ n++;
|
||||
+ }
|
||||
+
|
||||
+ if(!done)
|
||||
+ exit_error(OTHER_PROBLEM,
|
||||
+ "Couldn't find a pattern definition file for %s.\n", s);
|
||||
+
|
||||
+ /* process \xHH escapes and tolower everything. (our regex lib has no
|
||||
+ case insensitivity option.) */
|
||||
+ strncpy(info->pattern, pre_process(info->pattern), MAX_PATTERN_LEN);
|
||||
+}
|
||||
+
|
||||
+/* Function which parses command options; returns true if it ate an option */
|
||||
+static int parse(int c, char **argv, int invert, unsigned int *flags,
|
||||
+ const void *entry, struct xt_entry_match **match)
|
||||
+{
|
||||
+ struct xt_layer7_info *layer7info =
|
||||
+ (struct xt_layer7_info *)(*match)->data;
|
||||
+
|
||||
+ switch (c) {
|
||||
+ case 'p':
|
||||
+ parse_layer7_protocol(argv[optind-1], layer7info);
|
||||
+ if (invert)
|
||||
+ layer7info->invert = true;
|
||||
+ *flags = 1;
|
||||
+ break;
|
||||
+
|
||||
+ case 'd':
|
||||
+ if(strlen(argv[optind-1]) >= MAX_FN_LEN)
|
||||
+ exit_error(PARAMETER_PROBLEM, "directory name too long\n");
|
||||
+
|
||||
+ strncpy(l7dir, argv[optind-1], MAX_FN_LEN);
|
||||
+
|
||||
+ *flags = 1;
|
||||
+ break;
|
||||
+
|
||||
+ default:
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ return 1;
|
||||
+}
|
||||
+
|
||||
+/* Final check; must have specified --l7proto */
|
||||
+static void final_check(unsigned int flags)
|
||||
+{
|
||||
+ if (!flags)
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "LAYER7 match: You must specify `--l7proto'");
|
||||
+}
|
||||
+
|
||||
+static void print_protocol(char s[], int invert, int numeric)
|
||||
+{
|
||||
+ fputs("l7proto ", stdout);
|
||||
+ if (invert) fputc('!', stdout);
|
||||
+ printf("%s ", s);
|
||||
+}
|
||||
+
|
||||
+/* Prints out the matchinfo. */
|
||||
+static void print(const void *ip,
|
||||
+ const struct xt_entry_match *match,
|
||||
+ int numeric)
|
||||
+{
|
||||
+ printf("LAYER7 ");
|
||||
+ print_protocol(((struct xt_layer7_info *)match->data)->protocol,
|
||||
+ ((struct xt_layer7_info *)match->data)->invert, numeric);
|
||||
+}
|
||||
+/* Saves the union ipt_matchinfo in parsable form to stdout. */
|
||||
+static void save(const void *ip, const struct xt_entry_match *match)
|
||||
+{
|
||||
+ const struct xt_layer7_info *info =
|
||||
+ (const struct xt_layer7_info*) match->data;
|
||||
+
|
||||
+ printf("--l7proto %s%s ", (info->invert)? "! ":"", info->protocol);
|
||||
+}
|
||||
+
|
||||
+static struct xtables_match layer7 = {
|
||||
+ .family = AF_INET,
|
||||
+ .name = "layer7",
|
||||
+ .version = XTABLES_VERSION,
|
||||
+ .size = XT_ALIGN(sizeof(struct xt_layer7_info)),
|
||||
+ .userspacesize = XT_ALIGN(sizeof(struct xt_layer7_info)),
|
||||
+ .help = &help,
|
||||
+ .parse = &parse,
|
||||
+ .final_check = &final_check,
|
||||
+ .print = &print,
|
||||
+ .save = &save,
|
||||
+ .extra_opts = opts
|
||||
+};
|
||||
+
|
||||
+void _init(void)
|
||||
+{
|
||||
+ xtables_register_match(&layer7);
|
||||
+}
|
||||
diff -Nur iptables.old/extensions/libxt_layer7.man iptables.new/extensions/libxt_layer7.man
|
||||
--- iptables.old/extensions/libxt_layer7.man 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ iptables.new/extensions/libxt_layer7.man 2008-08-22 16:00:52.000000000 +0200
|
||||
@@ -0,0 +1,14 @@
|
||||
+This module matches packets based on the application layer data of
|
||||
+their connections. It uses regular expression matching to compare
|
||||
+the application layer data to regular expressions found it the layer7
|
||||
+configuration files. This is an experimental module which can be found at
|
||||
+http://l7-filter.sf.net. It takes two options.
|
||||
+.TP
|
||||
+.BI "--l7proto " "\fIprotocol\fP"
|
||||
+Match the specified protocol. The protocol name must match a file
|
||||
+name in /etc/l7-protocols/ or one of its first-level child directories.
|
||||
+.TP
|
||||
+.BI "--l7dir " "\fIdirectory\fP"
|
||||
+Use \fIdirectory\fP instead of /etc/l7-protocols/. This option must be
|
||||
+specified before --l7proto.
|
||||
+
|
||||
198
package/iptables/patches/1.4.1.1/005-imq1.patch
Normal file
198
package/iptables/patches/1.4.1.1/005-imq1.patch
Normal file
@@ -0,0 +1,198 @@
|
||||
--- iptables-1.4.1-rc3.orig/extensions/.IMQ-test 1970-01-01 10:00:00.000000000 +1000
|
||||
+++ iptables-1.4.1-rc3/extensions/.IMQ-test 2008-06-08 22:41:49.000000000 +1000
|
||||
@@ -0,0 +1,3 @@
|
||||
+#!/bin/sh
|
||||
+# True if IMQ target patch is applied.
|
||||
+[ -f $KERNEL_DIR/include/linux/netfilter_ipv4/ipt_IMQ.h ] && echo IMQ
|
||||
diff -pruN iptables-1.4.1-rc3.orig/extensions/.IMQ-test6 iptables-1.4.1-rc3/extensions/.IMQ-test6
|
||||
--- iptables-1.4.1-rc3.orig/extensions/.IMQ-test6 1970-01-01 10:00:00.000000000 +1000
|
||||
+++ iptables-1.4.1-rc3/extensions/.IMQ-test6 2008-06-08 22:41:49.000000000 +1000
|
||||
@@ -0,0 +1,3 @@
|
||||
+#!/bin/sh
|
||||
+# True if IMQ target patch is applied.
|
||||
+[ -f $KERNEL_DIR/include/linux/netfilter_ipv6/ip6t_IMQ.h ] && echo IMQ
|
||||
diff -pruN iptables-1.4.1-rc3.orig/extensions/libip6t_IMQ.c iptables-1.4.1-rc3/extensions/libip6t_IMQ.c
|
||||
--- iptables-1.4.1-rc3.orig/extensions/libip6t_IMQ.c 1970-01-01 10:00:00.000000000 +1000
|
||||
+++ iptables-1.4.1-rc3/extensions/libip6t_IMQ.c 2008-06-08 22:46:57.000000000 +1000
|
||||
@@ -0,0 +1,89 @@
|
||||
+/* Shared library add-on to iptables to add IMQ target support. */
|
||||
+#include <stdio.h>
|
||||
+#include <string.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <getopt.h>
|
||||
+
|
||||
+#include <ip6tables.h>
|
||||
+#include <linux/netfilter_ipv6/ip6_tables.h>
|
||||
+#include <linux/netfilter_ipv6/ip6t_IMQ.h>
|
||||
+
|
||||
+/* Function which prints out usage message. */
|
||||
+static void IMQ_help(void)
|
||||
+{
|
||||
+ printf(
|
||||
+"IMQ target v%s options:\n"
|
||||
+" --todev <N> enqueue to imq<N>, defaults to 0\n",
|
||||
+XTABLES_VERSION);
|
||||
+}
|
||||
+
|
||||
+static struct option IMQ_opts[] = {
|
||||
+ { "todev", 1, 0, '1' },
|
||||
+ { 0 }
|
||||
+};
|
||||
+
|
||||
+/* Initialize the target. */
|
||||
+static void IMQ_init(struct xt_entry_target *t)
|
||||
+{
|
||||
+ struct ip6t_imq_info *mr = (struct ip6t_imq_info*)t->data;
|
||||
+
|
||||
+ mr->todev = 0;
|
||||
+}
|
||||
+
|
||||
+/* Function which parses command options; returns true if it
|
||||
+ ate an option */
|
||||
+static int IMQ_parse(int c, char **argv, int invert, unsigned int *flags,
|
||||
+ const void *entry,
|
||||
+ struct xt_entry_target **target)
|
||||
+{
|
||||
+ struct ip6t_imq_info *mr = (struct ip6t_imq_info*)(*target)->data;
|
||||
+
|
||||
+ switch(c) {
|
||||
+ case '1':
|
||||
+ if (check_inverse(optarg, &invert, NULL, 0))
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "Unexpected `!' after --todev");
|
||||
+ mr->todev=atoi(optarg);
|
||||
+ break;
|
||||
+ default:
|
||||
+ return 0;
|
||||
+ }
|
||||
+ return 1;
|
||||
+}
|
||||
+
|
||||
+/* Prints out the targinfo. */
|
||||
+static void IMQ_print(const void *ip,
|
||||
+ const struct xt_entry_target *target,
|
||||
+ int numeric)
|
||||
+{
|
||||
+ struct ip6t_imq_info *mr = (struct ip6t_imq_info*)target->data;
|
||||
+
|
||||
+ printf("IMQ: todev %u ", mr->todev);
|
||||
+}
|
||||
+
|
||||
+/* Saves the union ipt_targinfo in parsable form to stdout. */
|
||||
+static void IMQ_save(const void *ip, const struct xt_entry_target *target)
|
||||
+{
|
||||
+ struct ip6t_imq_info *mr = (struct ip6t_imq_info*)target->data;
|
||||
+
|
||||
+ printf("--todev %u", mr->todev);
|
||||
+}
|
||||
+
|
||||
+static struct xtables_target imq = {
|
||||
+ .name = "IMQ",
|
||||
+ .version = XTABLES_VERSION,
|
||||
+ .family = PF_INET6,
|
||||
+ .size = XT_ALIGN(sizeof(struct ip6t_imq_info)),
|
||||
+ .userspacesize = XT_ALIGN(sizeof(struct ip6t_imq_info)),
|
||||
+ .help = IMQ_help,
|
||||
+ .init = IMQ_init,
|
||||
+ .parse = IMQ_parse,
|
||||
+ .print = IMQ_print,
|
||||
+ .save = IMQ_save,
|
||||
+ .extra_opts = IMQ_opts,
|
||||
+};
|
||||
+
|
||||
+void _init(void)
|
||||
+{
|
||||
+ xtables_register_target(&imq);
|
||||
+}
|
||||
diff -pruN iptables-1.4.1-rc3.orig/extensions/libipt_IMQ.c iptables-1.4.1-rc3/extensions/libipt_IMQ.c
|
||||
--- iptables-1.4.1-rc3.orig/extensions/libipt_IMQ.c 1970-01-01 10:00:00.000000000 +1000
|
||||
+++ iptables-1.4.1-rc3/extensions/libipt_IMQ.c 2008-06-08 22:46:25.000000000 +1000
|
||||
@@ -0,0 +1,88 @@
|
||||
+/* Shared library add-on to iptables to add IMQ target support. */
|
||||
+#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_ipv4/ipt_IMQ.h>
|
||||
+
|
||||
+/* Function which prints out usage message. */
|
||||
+static void IMQ_help(void)
|
||||
+{
|
||||
+ printf(
|
||||
+"IMQ target v%s options:\n"
|
||||
+" --todev <N> enqueue to imq<N>, defaults to 0\n",
|
||||
+XTABLES_VERSION);
|
||||
+}
|
||||
+
|
||||
+static struct option IMQ_opts[] = {
|
||||
+ { "todev", 1, 0, '1' },
|
||||
+ { 0 }
|
||||
+};
|
||||
+
|
||||
+/* Initialize the target. */
|
||||
+static void IMQ_init(struct xt_entry_target *t)
|
||||
+{
|
||||
+ struct ipt_imq_info *mr = (struct ipt_imq_info*)t->data;
|
||||
+
|
||||
+ mr->todev = 0;
|
||||
+}
|
||||
+
|
||||
+/* Function which parses command options; returns true if it
|
||||
+ ate an option */
|
||||
+static int IMQ_parse(int c, char **argv, int invert, unsigned int *flags,
|
||||
+ const void *entry, struct xt_entry_target **target)
|
||||
+{
|
||||
+ struct ipt_imq_info *mr = (struct ipt_imq_info*)(*target)->data;
|
||||
+
|
||||
+ switch(c) {
|
||||
+ case '1':
|
||||
+ if (check_inverse(optarg, &invert, NULL, 0))
|
||||
+ exit_error(PARAMETER_PROBLEM,
|
||||
+ "Unexpected `!' after --todev");
|
||||
+ mr->todev=atoi(optarg);
|
||||
+ break;
|
||||
+ default:
|
||||
+ return 0;
|
||||
+ }
|
||||
+ return 1;
|
||||
+}
|
||||
+
|
||||
+/* Prints out the targinfo. */
|
||||
+static void IMQ_print(const void *ip,
|
||||
+ const struct xt_entry_target *target,
|
||||
+ int numeric)
|
||||
+{
|
||||
+ struct ipt_imq_info *mr = (struct ipt_imq_info*)target->data;
|
||||
+
|
||||
+ printf("IMQ: todev %u ", mr->todev);
|
||||
+}
|
||||
+
|
||||
+/* Saves the union ipt_targinfo in parsable form to stdout. */
|
||||
+static void IMQ_save(const void *ip, const struct xt_entry_target *target)
|
||||
+{
|
||||
+ struct ipt_imq_info *mr = (struct ipt_imq_info*)target->data;
|
||||
+
|
||||
+ printf("--todev %u", mr->todev);
|
||||
+}
|
||||
+
|
||||
+static struct xtables_target imq = {
|
||||
+ .name = "IMQ",
|
||||
+ .version = XTABLES_VERSION,
|
||||
+ .family = PF_INET,
|
||||
+ .size = XT_ALIGN(sizeof(struct ipt_imq_info)),
|
||||
+ .userspacesize = XT_ALIGN(sizeof(struct ipt_imq_info)),
|
||||
+ .help = IMQ_help,
|
||||
+ .init = IMQ_init,
|
||||
+ .parse = IMQ_parse,
|
||||
+ .print = IMQ_print,
|
||||
+ .save = IMQ_save,
|
||||
+ .extra_opts = IMQ_opts,
|
||||
+};
|
||||
+
|
||||
+void _init(void)
|
||||
+{
|
||||
+ xtables_register_target(&imq);
|
||||
+}
|
||||
393
package/iptables/patches/1.4.1.1/006-chaostables_0.8.patch
Normal file
393
package/iptables/patches/1.4.1.1/006-chaostables_0.8.patch
Normal file
@@ -0,0 +1,393 @@
|
||||
Index: iptables-1.4.0/extensions/.CHAOS-testx
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ iptables-1.4.0/extensions/.CHAOS-testx
|
||||
@@ -0,0 +1,3 @@
|
||||
+#! /bin/sh
|
||||
+
|
||||
+[ -f "$KERNEL_DIR/include/linux/netfilter/xt_CHAOS.h" ] && echo "CHAOS"
|
||||
Index: iptables-1.4.0/extensions/libxt_CHAOS.c
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ iptables-1.4.0/extensions/libxt_CHAOS.c
|
||||
@@ -0,0 +1,114 @@
|
||||
+/*
|
||||
+ * CHAOS target for iptables
|
||||
+ * Copyright © CC Computer Consultants GmbH, 2006 - 2007
|
||||
+ * Contact: Jan Engelhardt <jengelh@computergmbh.de>
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify
|
||||
+ * it under the terms of the GNU General Public License; either version
|
||||
+ * 2 or 3 as published by the Free Software Foundation.
|
||||
+ */
|
||||
+#include <getopt.h>
|
||||
+#include <stdbool.h>
|
||||
+#include <stdio.h>
|
||||
+#include <string.h>
|
||||
+
|
||||
+#include <xtables.h>
|
||||
+#include <linux/netfilter/x_tables.h>
|
||||
+#include <linux/netfilter/xt_CHAOS.h>
|
||||
+
|
||||
+enum {
|
||||
+ F_DELUDE = 1 << 0,
|
||||
+ F_TARPIT = 1 << 1,
|
||||
+};
|
||||
+
|
||||
+static const struct option chaos_tg_opts[] = {
|
||||
+ {.name = "delude", .has_arg = false, .val = 'd'},
|
||||
+ {.name = "tarpit", .has_arg = false, .val = 't'},
|
||||
+ {},
|
||||
+};
|
||||
+
|
||||
+static void chaos_tg_help(void)
|
||||
+{
|
||||
+ printf(
|
||||
+ "CHAOS target v%s options:\n"
|
||||
+ " --delude Enable DELUDE processing for TCP\n"
|
||||
+ " --tarpit Enable TARPIT processing for TCP\n",
|
||||
+ XTABLES_VERSION);
|
||||
+ return;
|
||||
+}
|
||||
+
|
||||
+static int chaos_tg_parse(int c, char **argv, int invert, unsigned int *flags,
|
||||
+ const void *entry, struct xt_entry_target **target)
|
||||
+{
|
||||
+ struct xt_chaos_target_info *info = (void *)((*target)->data);
|
||||
+ switch (c) {
|
||||
+ case 'd':
|
||||
+ info->variant = XTCHAOS_DELUDE;
|
||||
+ *flags |= F_DELUDE;
|
||||
+ return true;
|
||||
+ case 't':
|
||||
+ info->variant = XTCHAOS_TARPIT;
|
||||
+ *flags |= F_TARPIT;
|
||||
+ return true;
|
||||
+ }
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+static void chaos_tg_check(unsigned int flags)
|
||||
+{
|
||||
+ if ((flags & (F_DELUDE | F_TARPIT)) == (F_DELUDE | F_TARPIT))
|
||||
+ /* 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 chaos_tg_print(const void *ip,
|
||||
+ const struct xt_entry_target *target, int numeric)
|
||||
+{
|
||||
+ const struct xt_chaos_target_info *info = (const void *)target->data;
|
||||
+ switch (info->variant) {
|
||||
+ case XTCHAOS_DELUDE:
|
||||
+ printf("DELUDE ");
|
||||
+ break;
|
||||
+ case XTCHAOS_TARPIT:
|
||||
+ printf("TARPIT ");
|
||||
+ break;
|
||||
+ }
|
||||
+ return;
|
||||
+}
|
||||
+
|
||||
+static void chaos_tg_save(const void *ip, const struct xt_entry_target *target)
|
||||
+{
|
||||
+ const struct xt_chaos_target_info *info = (const void *)target->data;
|
||||
+ switch (info->variant) {
|
||||
+ case XTCHAOS_DELUDE:
|
||||
+ printf("--delude ");
|
||||
+ break;
|
||||
+ case XTCHAOS_TARPIT:
|
||||
+ printf("--tarpit ");
|
||||
+ break;
|
||||
+ }
|
||||
+ return;
|
||||
+}
|
||||
+
|
||||
+static struct xtables_target chaos_tg_reg = {
|
||||
+ .version = XTABLES_VERSION,
|
||||
+ .name = "CHAOS",
|
||||
+ .family = AF_INET,
|
||||
+ .size = XT_ALIGN(sizeof(struct xt_chaos_target_info)),
|
||||
+ .userspacesize = XT_ALIGN(sizeof(struct xt_chaos_target_info)),
|
||||
+ .help = chaos_tg_help,
|
||||
+ .parse = chaos_tg_parse,
|
||||
+ .final_check = chaos_tg_check,
|
||||
+ .print = chaos_tg_print,
|
||||
+ .save = chaos_tg_save,
|
||||
+ .extra_opts = chaos_tg_opts,
|
||||
+};
|
||||
+
|
||||
+void _init(void)
|
||||
+{
|
||||
+ xtables_register_target(&chaos_tg_reg);
|
||||
+ return;
|
||||
+}
|
||||
Index: iptables-1.4.0/extensions/libxt_CHAOS.man
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ iptables-1.4.0/extensions/libxt_CHAOS.man
|
||||
@@ -0,0 +1,18 @@
|
||||
+Causes confusion on the other end by doing odd things with incoming packets.
|
||||
+CHAOS will randomly reply (or not) with one of its configurable subtargets:
|
||||
+.TP
|
||||
+\fB--delude\fR
|
||||
+Use the REJECT and DELUDE targets as a base to do a sudden or deferred
|
||||
+connection reset, fooling some network scanners to return non-deterministic
|
||||
+(randomly open/closed) results, and in case it is deemed open, it is actually
|
||||
+closed/filtered.
|
||||
+.TP
|
||||
+\fB--tarpit\fR
|
||||
+Use the REJECT and TARPIT target as a base to hold the connection until it
|
||||
+times out. This consumes conntrack entries when connection tracking is loaded
|
||||
+(which usually is on most machines), and routers inbetween you and the Internet
|
||||
+may fail to do their connection tracking if they have to handle more
|
||||
+connections than they can.
|
||||
+.PP
|
||||
+The randomness factor of not replying vs. replying can be set during load-time
|
||||
+of the xt_CHAOS module or during runtime in /sys/modules/xt_CHAOS/parameters.
|
||||
Index: iptables-1.4.0/extensions/.DELUDE-testx
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ iptables-1.4.0/extensions/.DELUDE-testx
|
||||
@@ -0,0 +1,3 @@
|
||||
+#! /bin/sh
|
||||
+
|
||||
+[ -f "$KERNEL_DIR/net/netfilter/xt_DELUDE.c" ] && echo "DELUDE"
|
||||
Index: iptables-1.4.0/extensions/libxt_DELUDE.c
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ iptables-1.4.0/extensions/libxt_DELUDE.c
|
||||
@@ -0,0 +1,49 @@
|
||||
+/*
|
||||
+ * DELUDE target for iptables
|
||||
+ * Copyright © CC Computer Consultants GmbH, 2006 - 2007
|
||||
+ * Contact: Jan Engelhardt <jengelh@computergmbh.de>
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify
|
||||
+ * it under the terms of the GNU General Public License; either version
|
||||
+ * 2 or 3 as published by the Free Software Foundation.
|
||||
+ */
|
||||
+#include <getopt.h>
|
||||
+#include <stdio.h>
|
||||
+#include <string.h>
|
||||
+
|
||||
+#include <xtables.h>
|
||||
+#include <linux/netfilter/x_tables.h>
|
||||
+
|
||||
+static void delude_tg_help(void)
|
||||
+{
|
||||
+ printf("DELUDE takes no options\n");
|
||||
+ return;
|
||||
+}
|
||||
+
|
||||
+static int delude_tg_parse(int c, char **argv, int invert, unsigned int *flags,
|
||||
+ const void *entry, struct xt_entry_target **target)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void delude_tg_check(unsigned int flags)
|
||||
+{
|
||||
+ return;
|
||||
+}
|
||||
+
|
||||
+static struct xtables_target delude_tg_reg = {
|
||||
+ .version = XTABLES_VERSION,
|
||||
+ .name = "DELUDE",
|
||||
+ .family = AF_INET,
|
||||
+ .size = XT_ALIGN(0),
|
||||
+ .userspacesize = XT_ALIGN(0),
|
||||
+ .help = delude_tg_help,
|
||||
+ .parse = delude_tg_parse,
|
||||
+ .final_check = delude_tg_check,
|
||||
+};
|
||||
+
|
||||
+void _init(void)
|
||||
+{
|
||||
+ xtables_register_target(&delude_tg_reg);
|
||||
+ return;
|
||||
+}
|
||||
Index: iptables-1.4.0/extensions/libxt_DELUDE.man
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ iptables-1.4.0/extensions/libxt_DELUDE.man
|
||||
@@ -0,0 +1,4 @@
|
||||
+The DELUDE target will reply to a SYN packet with SYN-ACK, and to all other
|
||||
+packets with an RST. This will terminate the connection much like REJECT, but
|
||||
+network scanners doing TCP half-open discovery can be spoofed to make them
|
||||
+belive the port is open rather than closed/filtered.
|
||||
Index: iptables-1.4.0/extensions/.portscan-testx
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ iptables-1.4.0/extensions/.portscan-testx
|
||||
@@ -0,0 +1,3 @@
|
||||
+#! /bin/sh
|
||||
+
|
||||
+[ -f "$KERNEL_DIR/include/linux/netfilter/xt_portscan.h" ] && echo "portscan"
|
||||
Index: iptables-1.4.0/extensions/libxt_portscan.c
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ iptables-1.4.0/extensions/libxt_portscan.c
|
||||
@@ -0,0 +1,127 @@
|
||||
+/*
|
||||
+ * portscan match for iptables
|
||||
+ * Copyright © CC Computer Consultants GmbH, 2006 - 2007
|
||||
+ * Contact: Jan Engelhardt <jengelh@computergmbh.de>
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify
|
||||
+ * it under the terms of the GNU General Public License; either version
|
||||
+ * 2 or 3 as published by the Free Software Foundation.
|
||||
+ */
|
||||
+#include <stdbool.h>
|
||||
+#include <stdio.h>
|
||||
+#include <string.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <getopt.h>
|
||||
+
|
||||
+#include <xtables.h>
|
||||
+#include <iptables.h>
|
||||
+#include <linux/netfilter/x_tables.h>
|
||||
+#include <linux/netfilter/xt_portscan.h>
|
||||
+
|
||||
+static const struct option portscan_mt_opts[] = {
|
||||
+ {.name = "stealth", .has_arg = false, .val = 'x'},
|
||||
+ {.name = "synscan", .has_arg = false, .val = 's'},
|
||||
+ {.name = "cnscan", .has_arg = false, .val = 'c'},
|
||||
+ {.name = "grscan", .has_arg = false, .val = 'g'},
|
||||
+ {},
|
||||
+};
|
||||
+
|
||||
+static void portscan_mt_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",
|
||||
+ XTABLES_VERSION);
|
||||
+ return;
|
||||
+}
|
||||
+
|
||||
+static int portscan_mt_parse(int c, char **argv, int invert,
|
||||
+ unsigned int *flags, const void *entry, struct xt_entry_match **match)
|
||||
+{
|
||||
+ struct xt_portscan_match_info *info = (void *)((*match)->data);
|
||||
+
|
||||
+ switch (c) {
|
||||
+ case 'c':
|
||||
+ info->match_cn = true;
|
||||
+ return true;
|
||||
+ case 'g':
|
||||
+ info->match_gr = true;
|
||||
+ return true;
|
||||
+ case 's':
|
||||
+ info->match_syn = true;
|
||||
+ return true;
|
||||
+ case 'x':
|
||||
+ info->match_stealth = true;
|
||||
+ return true;
|
||||
+ }
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+static void portscan_mt_check(unsigned int flags)
|
||||
+{
|
||||
+ return;
|
||||
+}
|
||||
+
|
||||
+static void portscan_mt_print(const void *ip,
|
||||
+ const struct xt_entry_match *match, int numeric)
|
||||
+{
|
||||
+ const struct xt_portscan_match_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 portscan_mt_save(const void *ip, const struct xt_entry_match *match)
|
||||
+{
|
||||
+ const struct xt_portscan_match_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 xtables_match portscan_mt_reg = {
|
||||
+ .version = XTABLES_VERSION,
|
||||
+ .name = "portscan",
|
||||
+ .family = AF_INET,
|
||||
+ .size = XT_ALIGN(sizeof(struct xt_portscan_match_info)),
|
||||
+ .userspacesize = XT_ALIGN(sizeof(struct xt_portscan_match_info)),
|
||||
+ .help = portscan_mt_help,
|
||||
+ .parse = portscan_mt_parse,
|
||||
+ .final_check = portscan_mt_check,
|
||||
+ .print = portscan_mt_print,
|
||||
+ .save = portscan_mt_save,
|
||||
+ .extra_opts = portscan_mt_opts,
|
||||
+};
|
||||
+
|
||||
+void _init(void)
|
||||
+{
|
||||
+ xtables_register_match(&portscan_mt_reg);
|
||||
+ return;
|
||||
+}
|
||||
Index: iptables-1.4.0/extensions/libxt_portscan.man
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ iptables-1.4.0/extensions/libxt_portscan.man
|
||||
@@ -0,0 +1,27 @@
|
||||
+Detects simple port scan attemps based upon the packet's contents. (This is
|
||||
+different from other implementations, which also try to match the rate of new
|
||||
+connections.) Note that an attempt is only discovered after it has been carried
|
||||
+out, but this information can be used in conjunction with other rules to block
|
||||
+the remote host's future connections. So this match module will match on the
|
||||
+(probably) last packet the remote side will send to your machine.
|
||||
+.TP
|
||||
+\fB--stealth\fR
|
||||
+Match if the packet did not belong to any known TCP connection
|
||||
+(Stealth/FIN/XMAS/NULL scan).
|
||||
+.TP
|
||||
+\fB--synscan\fR
|
||||
+Match if the connection was a TCP half-open discovery (SYN scan), i.e. the
|
||||
+connection was torn down after the 2nd packet in the 3-way handshake.
|
||||
+.TP
|
||||
+\fB--cnscan\fR
|
||||
+Match if the connection was a TCP full open discovery (connect scan), i.e. the
|
||||
+connection was torn down after completion of the 3-way handshake.
|
||||
+.TP
|
||||
+\fB--grscan\fR
|
||||
+Match if data in the connection only flew in the direction of the remote side,
|
||||
+e.g. if the connection was terminated after a locally running daemon sent its
|
||||
+identification. (e.g. openssh)
|
||||
+.PP
|
||||
+NOTE: Some clients (Windows XP for example) may do what looks like a SYN scan,
|
||||
+so be advised to carefully use xt_portscan in conjunction with blocking rules,
|
||||
+as it may lock out your very own internal network.
|
||||
106
package/iptables/patches/1.4.1.1/007-tarpit_support.patch
Normal file
106
package/iptables/patches/1.4.1.1/007-tarpit_support.patch
Normal file
@@ -0,0 +1,106 @@
|
||||
Index: iptables-1.4.0/extensions/libxt_TARPIT.c
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ iptables-1.4.0/extensions/libxt_TARPIT.c
|
||||
@@ -0,0 +1,55 @@
|
||||
+/* Shared library add-on to iptables to add TARPIT target support */
|
||||
+#include <stdio.h>
|
||||
+#include <getopt.h>
|
||||
+
|
||||
+#include <xtables.h>
|
||||
+#include <linux/netfilter/x_tables.h>
|
||||
+
|
||||
+static void TARPIT_help(void)
|
||||
+{
|
||||
+ fputs(
|
||||
+"TARPIT takes no options\n"
|
||||
+"\n", stdout);
|
||||
+}
|
||||
+
|
||||
+static struct option TARPIT_opts[] = {
|
||||
+ { 0 }
|
||||
+};
|
||||
+
|
||||
+static int TARPIT_parse(int c, char **argv, int invert, unsigned int *flags,
|
||||
+ const void *entry, struct xt_entry_target **target)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void TARPIT_final_check(unsigned int flags)
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+static void TARPIT_print(const void *ip, const struct xt_entry_target *target,
|
||||
+ int numeric)
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+static void TARPIT_save(const void *ip, const struct xt_entry_target *target)
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+static struct xtables_target tarpit_target = {
|
||||
+ .family = AF_INET,
|
||||
+ .name = "TARPIT",
|
||||
+ .version = XTABLES_VERSION,
|
||||
+ .size = XT_ALIGN(0),
|
||||
+ .userspacesize = XT_ALIGN(0),
|
||||
+ .help = TARPIT_help,
|
||||
+ .parse = TARPIT_parse,
|
||||
+ .final_check = TARPIT_final_check,
|
||||
+ .print = TARPIT_print,
|
||||
+ .save = TARPIT_save,
|
||||
+ .extra_opts = TARPIT_opts
|
||||
+};
|
||||
+
|
||||
+void _init(void)
|
||||
+{
|
||||
+ xtables_register_target(&tarpit_target);
|
||||
+}
|
||||
Index: iptables-1.4.0/extensions/libxt_TARPIT.man
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ iptables-1.4.0/extensions/libxt_TARPIT.man
|
||||
@@ -0,0 +1,34 @@
|
||||
+Captures and holds incoming TCP connections using no local
|
||||
+per-connection resources. Connections are accepted, but immediately
|
||||
+switched to the persist state (0 byte window), in which the remote
|
||||
+side stops sending data and asks to continue every 60-240 seconds.
|
||||
+Attempts to close the connection are ignored, forcing the remote side
|
||||
+to time out the connection in 12-24 minutes.
|
||||
+
|
||||
+This offers similar functionality to LaBrea
|
||||
+<http://www.hackbusters.net/LaBrea/> but doesn't require dedicated
|
||||
+hardware or IPs. Any TCP port that you would normally DROP or REJECT
|
||||
+can instead become a tarpit.
|
||||
+
|
||||
+To tarpit connections to TCP port 80 destined for the current machine:
|
||||
+.IP
|
||||
+iptables -A INPUT -p tcp -m tcp --dport 80 -j TARPIT
|
||||
+.P
|
||||
+To significantly slow down Code Red/Nimda-style scans of unused address
|
||||
+space, forward unused ip addresses to a Linux box not acting as a router
|
||||
+(e.g. "ip route 10.0.0.0 255.0.0.0 ip.of.linux.box" on a Cisco), enable IP
|
||||
+forwarding on the Linux box, and add:
|
||||
+.IP
|
||||
+iptables -A FORWARD -p tcp -j TARPIT
|
||||
+.IP
|
||||
+iptables -A FORWARD -j DROP
|
||||
+.TP
|
||||
+NOTE:
|
||||
+If you use the conntrack module while you are using TARPIT, you should
|
||||
+also use the NOTRACK target, or the kernel will unnecessarily allocate
|
||||
+resources for each TARPITted connection. To TARPIT incoming
|
||||
+connections to the standard IRC port while using conntrack, you could:
|
||||
+.IP
|
||||
+iptables -t raw -A PREROUTING -p tcp --dport 6667 -j NOTRACK
|
||||
+.IP
|
||||
+iptables -A INPUT -p tcp --dport 6667 -j TARPIT
|
||||
Index: iptables-1.4.0/extensions/.TARPIT-testx
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ iptables-1.4.0/extensions/.TARPIT-testx
|
||||
@@ -0,0 +1,2 @@
|
||||
+#! /bin/sh
|
||||
+[ -f "$KERNEL_DIR/net/netfilter/xt_TARPIT.c" ] && echo "TARPIT"
|
||||
Reference in New Issue
Block a user