new netfilter matching module : passive OS fingerprint
Hola!
First of all thanks for your great netfilter code and it's capabilities :)
The idea of passive OS fingerprint matching exist quite long time, but was created as extension fo OpenBSD pf only some weeks ago. Original idea was lurked in some OpenBSD mailing list (thanx grange@open...) and than adopted for Linux netfilter in form of this mail and code below.
Original table was created by Michal Zalewski <lcamtuf__coredump.cx> for his excellent p0f and than changed a bit for more convenience.
This module comapares some data(WS, MSS, options and it's order, ttl, df and others) from first SYN packet (actually from packets with SYN bit set) with hardcoded in fingers[] table ones.
So, if you are interested in, please see and comment :)
P.S. I'm not a subscriber so please CC: me in your answers.
More power to your elbow!
Evgeniy Polyakov
Hello Evgeniy, folks,
Quoted 2 lines
Hola!
So, if you are interested in, please see and comment :)
I took the privilege and made a patch for netfilter CVS to include this module in patch-o-matic, so it would be easier for people to test this module as a simple patch.
I also wrote an example, added lists of available genres and wrote osf.patch.configure.help and osf.patch.help messages.
I am sending the patch attached for the netfilter CVS.
Also this patch is available at
http://soltysiak.com/linux/osf.patch
Quoted 1 line
Evgeniy Polyakov
Maciej Soltysiak
patch-o-matic/base/osf.patch +519 -0
@@ -0,0 +1,519 @@ +diff -Nru linux-2.4.21/include/linux/netfilter_ipv4/ipt_osf.h linux-2.4.22/include/linux/netfilter_ipv4/ipt_osf.h +--- linux-2.4.21/include/linux/netfilter_ipv4/ipt_osf.h 1970-01-01 01:00:00.000000000 +0100 ++++ linux-2.4.22/include/linux/netfilter_ipv4/ipt_osf.h 2003-09-09 16:09:01.000000000 +0200 +@@ -0,0 +1,67 @@ ++/* ++ * ipt_osf.h ++ * ++ * Copyright (c) 2003 Evgeniy Polyakov <[email protected]> ++ * ++ * ++ * 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. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ */ ++ ++#ifndef _IPT_OSF_H ++#define _IPT_OSF_H ++ ++#define MAXGENRELEN 32 ++#define MAXDETLEN 32 ++ ++struct ipt_osf_info ++{ ++ char genre[MAXGENRELEN]; ++ int len; ++ int invert; ++}; ++ ++struct osf_wc ++{ ++ char wc; ++ unsigned long val; ++}; ++ ++/* This struct represents IANA options ++ * http://www.iana.org/assignments/tcp-parameters ++ */ ++struct osf_opt ++{ ++ unsigned char kind; ++ unsigned char length; ++ struct osf_wc wc; ++}; ++ ++struct osf_finger ++{ ++ struct osf_wc wss; ++ unsigned char ttl; ++ unsigned char df; ++ unsigned long ss; ++ char genre[MAXGENRELEN]; ++ ++ /* Not needed, but for consistency with original table from Michal Zalewski */ ++ char details[MAXDETLEN]; ++ ++ int opt_num; ++ struct osf_opt opt[MAX_IPOPTLEN]; /* In case it is all NOP or EOL */ ++ ++}; ++ ++#endif /* _IPT_OSF_H */ +diff -Nru linux-2.4.21/net/ipv4/netfilter/ipt_osf.c linux-2.4.22/net/ipv4/netfilter/ipt_osf.c +--- linux-2.4.21/net/ipv4/netfilter/ipt_osf.c 1970-01-01 01:00:00.000000000 +0100 ++++ linux-2.4.22/net/ipv4/netfilter/ipt_osf.c 2003-09-09 16:17:31.000000000 +0200 +@@ -0,0 +1,444 @@ ++/* ++ * ipt_osf.c ++ * ++ * Copyright (c) 2003 Evgeniy Polyakov <[email protected]> ++ * ++ * ++ * 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. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ */ ++ ++/* ++ * OS fingerprint matching module. ++ * It simply compares various parameters from SYN packet with ++ * some hardcoded ones. ++ * ++ * Original table was created by Michal Zalewski <[email protected]> ++ * for his p0f. ++ */ ++ ++#include <linux/smp.h> ++#include <linux/module.h> ++#include <linux/skbuff.h> ++#include <linux/file.h> ++#include <linux/ip.h> ++ ++#include <net/sock.h> ++#include <net/ip.h> ++ ++#include <linux/netfilter_ipv4/ip_tables.h> ++ ++#include <linux/netfilter_ipv4/ipt_osf.h> ++ ++#ifdef OSF_DEBUG ++#define log(x...) printk(KERN_ERR "ipt_osf: " x) ++#define loga(x...) printk(x) ++#else ++#define log(x...) ++#define loga(x...) ++#endif ++ ++#define FMATCH_WRONG 0 ++#define FMATCH_OK 1 ++#define FMATCH_OPT_WRONG 2 ++ ++static struct osf_finger fingers[] = ++{ ++/*----------------- Linux ------------------- */ ++ ++ {{0, 512}, 64, 0, 44, "Linux", "2.0.3x", ++ 1, {{2, 4}, } }, ++ {{0, 16384} ,64, 0, 44, "Linux", "2.0.3x", ++ 1, {{2, 4}, } }, ++ {{0, 5440}, 64, 1, 60, "Linux", "(Google crawlbot)", ++ 5, {{2,4,{'W',1360}}, {4, 2}, {8,10}, {1,1}, {3,3}} }, ++ {{'S', 3}, 64, 1, 60, "Linux", "2.4.18 and newer", ++ 5, {{2,4}, {4, 2}, {8,10}, {1,1}, {3,3}} }, ++ {{'S', 4}, 64, 1, 60, "Linux", "2.4", ++ 5, {{2,4}, {4, 2}, {8,10}, {1,1}, {3,3}} }, ++ {{'S', 3}, 64,1,60, "Linux", "2.5 (newer)", ++ 5, {{2,4}, {4, 2}, {8,10}, {1,1}, {3,3}} }, /* W1 - what is it ??? */ ++ {{'S', 4}, 64,1,60, "Linux", "2.5 (sometimes 2.4)", ++ 5, {{2,4}, {4, 2}, {8,10}, {1,1}, {3,3}} }, /* ??? */ ++ ++ {{'S', 20}, 64,1,60, "Linux", "2.2.20 and newer", ++ 5, {{2,4}, {4, 2}, {8,10}, {1,1}, {3,3}} }, ++ {{'S', 22}, 64,1,60, "Linux", "2.2", ++ 5, {{2,4}, {4, 2}, {8,10}, {1,1}, {3,3}} }, ++ ++ /* This needs to be investigated. On some systems, WSS ++ * is selected as a multiple of MTU instead of MSS. I got ++ * many submissions for this for many late versions of 2.4, ++ */ ++ ++ {{'T', 4}, 64,1,60, "Linux", "late 2.4 (uncommon)", ++ 5, {{2,4,{0,1412}}, {4, 2}, {8,10}, {1,1}, {3,3}} }, ++ ++ /* That's quite stupid, but happens. The WSS is a multiplier of ++ * MSS, but not that MSS - the default ethernet MSS instead. It ++ * is believed to be related to having two network cards in certain ++ * configurations, ++ */ ++ ++ /* Maybe PIX? */ ++ {{0, 5840}, 64,1,60, "Linux","2.4 (1) (NAT or snafu)", ++ 5, {{2,4}, {4, 2}, {8,10}, {1,1}, {3,3}} }, ++ {{0, 5840}, 64,1,60, "Linux","2.4 (2) (NAT or snafu)", ++ 5, {{2,4}, {4, 2}, {8,10}, {1,1}, {3,3, {0,1}}} }, ++ ++ /* Opera visitors, */ ++ {{0, 32767}, 64,1,60, "Linux","2.4 (Opera?)", ++ 5, {{2,4}, {4, 2}, {8,10}, {1,1}, {3,3}} }, ++ {{0, 16384}, 64,1,60, "Linux","2.2 (Opera?)", ++ 5, {{2,4}, {4, 2}, {8,10}, {1,1}, {3,3}} }, ++ ++ /* This happens only over loopback, ++ * {{'S', 8}, 64, 1, 60, "Linux", "2.2 (local)", ++ 5, {{2,4}, {4, 2}, {8,10}, {1,1}, {3,3}} }, ++ * Some fairly common mods, ++ * {{'S', 4}, 64, 1, 52, "Linux", "2.4 w/o timestamps", ++ 6, {{2,4}, {1,1}, {1,1}, {4, 2}, {1,1}, {3,3}} }, ++ */ ++ ++/* ----------------- FreeBSD ----------------- */ ++ ++ {{0, 16384}, 64,1,44, "FreeBSD","2.0-4.1 (sometimes AIX 4.3)", ++ 1, {{2,4}} }, ++ {{0, 16384}, 64,1,60, "FreeBSD","4.4", ++ 6, {{2,4}, {1, 1}, {3,3}, {1,1}, {1,1}, {8,10}} }, ++ {{0, 1024}, 64,1,60, "FreeBSD","4.4", ++ 6, {{2,4}, {1, 1}, {3,3}, {1,1}, {1,1}, {8,10}} }, ++ ++ {{'S', 0}, 64,1,60, "FreeBSD","4.6", ++ 6, {{2,4}, {1, 1}, {3,3}, {1,1}, {1,1}, {8,10}} }, ++ ++ {{0, 57344}, 64,1,44, "FreeBSD","4.6-4.8 (no RFC1323)", ++ 1, {{2,4}} }, ++ {{0, 57344}, 64,1,60, "FreeBSD","4.6-4.8", ++ 6, {{2,4}, {1, 1}, {3,3}, {1,1}, {1,1}, {8,10}} }, ++ ++ /* Power of 2 WSS are also shared by MacOS X 10.2 when DF set */ ++ {{0, 32768}, 64,1,60, "FreeBSD","4.8-5.0 (or MacOS X 10.2 w/DF)", ++ 6, {{2,4}, {1, 1}, {3,3}, {1,1}, {1,1}, {8,10}} }, ++ {{0, 65535}, 64,1,60, "FreeBSD","4.7-5.0 (or MacOS X 10.2 w/DF)", ++ 6, {{2,4}, {1, 1}, {3,3}, {1,1}, {1,1}, {8,10}} }, ++ ++ {{0, 65535}, 64,1,60, "FreeBSD","5.1", ++ 6, {{2,4}, {1, 1}, {3,3, {0,1}}, {1,1}, {1,1}, {8,10}} }, ++ ++/* ----------------- NetBSD ------------------ */ ++ ++ {{0, 16384}, 64,0,60, "NetBSD","1.6", ++ 6, {{2,4}, {1, 1}, {3,3}, {1,1}, {1,1}, {8,10}} }, ++ {{0, 16384}, 64,1,60, "NetBSD","1.6 (DF)", ++ 6, {{2,4}, {1, 1}, {3,3}, {1,1}, {1,1}, {8,10}} }, ++ {{0, 16384}, 64,0,60, "NetBSD","1.3 (or OpenBSD 2.6)", ++ 6, {{2,4}, {1, 1}, {3,3}, {1,1}, {1,1}, {8,10}} }, ++ ++/* ----------------- OpenBSD ----------------- */ ++ ++ {{0, 16384}, 64,1,64, "OpenBSD","3.0-3.4", ++ 9, {{2,4}, {1, 1}, {1,1}, {4,2}, {1,1}, {3,3}, {1,1}, {1,1}, {8,10}} }, ++ {{0, 57344}, 64,1,64, "OpenBSD","3.3-3.4", ++ 9, {{2,4}, {1, 1}, {1,1}, {4,2}, {1,1}, {3,3}, {1,1}, {1,1}, {8,10}} }, ++ {{0, 16384}, 64,0,64, "OpenBSD","3.0-3.4 (scrub)", ++ 9, {{2,4}, {1, 1}, {1,1}, {4,2}, {1,1}, {3,3}, {1,1}, {1,1}, {8,10}} }, ++ ++ /* Opera! */ ++ {{0, 65535}, 64,1,64, "OpenBSD","3.0-3.4 (Opera)", ++ 9, {{2,4}, {1, 1}, {1,1}, {4,2}, {1,1}, {3,3}, {1,1}, {1,1}, {8,10}} }, ++ ++ ++/* ----------------- Windows ----------------- */ ++ ++ /* Windows 98 had a plenty of signatures depending on ++ * release, but I don't have all the data. ++ */ ++ ++ {{'S', 44}, 64,1,48, "Windows","98SE ", ++ 4, {{1,1}, {1,1}, {4,2}, {2,4}} }, ++ {{'S', 6}, 128,1,48, "Windows","98 (no sack)", ++ 1, {{2,4}} }, ++ {{0, 8192}, 128,1,48, "Windows","98", ++ 4, {{2,4}, {1,1}, {1,1}, {4,2}} }, ++ {{0, 37300}, 64,1,48, "Windows","98", ++ 4, {{2,4}, {1,1}, {1,1}, {4,2}} }, ++ {{0, 8192}, 128,1,44, "Windows","NT 4.0", ++ 1, {{2,4}} }, ++ ++ {{'%', 8192}, 128,1,48, "Windows","XP/2000", ++ 4, {{2,4}, {1,1}, {1,1}, {4,2}} }, ++ {{'%', 8192}, 128,0,48, "Windows","XP/2000 (firewalled)", ++ 4, {{2,4}, {1,1}, {1,1}, {4,2}} }, ++ {{0, 65535}, 128,1,48, "Windows","2000 SP4", ++ 4, {{2,4}, {1,1}, {1,1}, {4,2}} }, ++ {{0, 65535}, 128,0,48, "Windows","2000 SP4 (firewalled)", ++ 4, {{2,4}, {1,1}, {1,1}, {4,2}} }, ++ {{'S', 44}, 128,1,48, "Windows","XP or 2000 SP3+ (1)", ++ 4, {{2,4}, {1,1}, {1,1}, {4,2}} }, ++ {{'S', 44}, 128,0,48, "Windows","XP or 2000 SP3+ (1) (firewalled)", ++ 4, {{2,4}, {1,1}, {1,1}, {4,2}} }, ++ {{'S', 6}, 128,1,48, "Windows","XP or 2000 SP3 (2)", ++ 4, {{2,4}, {1,1}, {1,1}, {4,2}} }, ++ {{'S', 6}, 128,0,48, "Windows","XP or 2000 SP3 (2) (firewalled)", ++ 4, {{2,4}, {1,1}, {1,1}, {4,2}} }, ++ ++ /* This block yet to be verified, */ ++ {{'S', 45}, 128,1,48, "Windows","XP (3)", ++ 4, {{2,4}, {1,1}, {1,1}, {4,2}} }, ++ {{'S', 45}, 128,0,48, "Windows","XP (3) (firewalled)", ++ 4, {{2,4}, {1,1}, {1,1}, {4,2}} }, ++ {{'S', 46}, 128,1,48, "Windows","XP (4)", ++ 4, {{2,4}, {1,1}, {1,1}, {4,2}} }, ++ {{'S', 46}, 128,0,48, "Windows","XP (4) (firewalled)", ++ 4, {{2,4}, {1,1}, {1,1}, {4,2}} }, ++ {{0, 32767}, 128,1,52, "Windows", "NT4", ++ 6, {{2,4}, {1,1}, {3,3}, {1,1}, {1,1}, {4,2}} }, ++ {{0, 6144}, 128,1,52, "Windows", "NT4", ++ 6, {{2,4}, {1,1}, {3,3}, {1,1}, {1,1}, {4,2}} }, ++ {{'S', 45}, 128,1,52, "Windows" ,"NT4", ++ 6, {{2,4}, {1,1}, {3,3}, {1,1}, {1,1}, {4,2}} }, ++ ++ {{0, 64240}, 128,0,48, "Windows", "2000/XP (NAT or snafu)", ++ 4, {{2,4}, {1,1}, {1,1}, {4,2}} }, ++ ++ /* Odds, ends, mods. Advanced Networking Pack turns out to be ++ * responsible for enabling RFC1323, System Mechanic also messes ++ * with TTLs and timestamps, ++ */ ++ ++ {{'*', 0}, 128,1,64, "Windows", "2000 SP4 (AdvNetPack) or PalmPC", ++ 9, {{2,4}, {1,1}, {3,3, {'W', 2}}, {1,1}, {1,1}, {8,10}, {1,1}, {1,1}, {4,2}} }, ++ {{'S', 44}, 128,1,64, "Windows", "XP (AdvNetPack)", ++ 9, {{2,4, {0,1460}}, {1,1}, {3,3, {'W', 0}}, {1,1}, {1,1}, {8,10}, {1,1}, {1,1}, {4,2}} }, ++ {{0, 58944}, 64,1,52, "Windows","XP (System Mechanic tuned)", ++ 6, {{2,4}, {1,1}, {3,3, {'W', 2}}, {1,1}, {1,1}, {4,2}} }, ++}; ++ ++static int ++match(const struct sk_buff *skb, ++ const struct net_device *in, ++ const struct net_device *out, ++ const void *matchinfo, ++ int offset, ++ const void *hdr, ++ u_int16_t datalen, ++ int *hotdrop) ++{ ++ struct ipt_osf_info *info = (struct ipt_osf_info *)matchinfo; ++ struct iphdr *ip = skb->nh.iph; ++ struct tcphdr *tcp; ++ int fsize = sizeof(fingers)/sizeof(struct osf_finger), i, fmatch = FMATCH_WRONG; ++ unsigned long totlen, optsize = 0, window; ++ unsigned char df, *optp = NULL, *_optp = NULL; ++ char check_WSS = 0; ++ ++ if (!ip || !info) ++ return 0; ++ ++ tcp = (struct tcphdr *)((u_int32_t *)ip + ip->ihl); ++ ++ if (!tcp->syn) ++ return 0; ++ ++ totlen = ntohs(ip->tot_len); ++ df = ((ntohs(ip->frag_off) & IP_DF)?1:0); ++ window = ntohs(tcp->window); ++ ++ if (tcp->doff*4 > sizeof(struct tcphdr)) ++ { ++ _optp = optp = (char *)(tcp+1); ++ optsize = tcp->doff*4 - sizeof(struct tcphdr); ++ } ++ ++ ++ /* Actually we can create hash/table of all genres and search ++ * only in appropriate part, but here is initial variant, ++ * so will use slow path. ++ */ ++ for (i=0; i<fsize; ++i) ++ { ++ if (strcmp(info->genre, fingers[i].genre)) ++ continue; ++ ++ optp = _optp; ++ ++ if ( ip->ttl == fingers[i].ttl && ++ totlen == fingers[i].ss && ++ df == fingers[i].df) ++ { ++ unsigned long foptsize; ++ int optnum; ++ unsigned short mss = 0; ++ ++ check_WSS = 0; ++ ++ switch (fingers[i].wss.wc) ++ { ++ case 0: check_WSS = 0; break; ++ case 'S': check_WSS = 1; break; ++ case 'T': check_WSS = 2; break; ++ case '%': check_WSS = 3; break; ++ default: log("Wrong fingerprint wss.wc=%c, string=%d\n", ++ fingers[i].wss.wc, i); ++ check_WSS = 4; ++ break; ++ } ++ if (check_WSS == 4) ++ continue; ++ ++ /* Check options */ ++ ++ foptsize = 0; ++ for (optnum=0; optnum<fingers[i].opt_num; ++optnum) ++ foptsize += fingers[i].opt[optnum].length; ++ ++ ++ if (foptsize > MAX_IPOPTLEN || optsize > MAX_IPOPTLEN || optsize != foptsize) ++ continue; ++ ++ if (!optp) ++ { ++ fmatch = FMATCH_OK; ++ loga("\tYEP : matching without options.\n"); ++ break; ++ } ++ ++ ++ for (optnum=0; optnum<fingers[i].opt_num; ++optnum) ++ { ++ if (fingers[i].opt[optnum].kind == (*optp)) ++ { ++ unsigned char len = fingers[i].opt[optnum].length; ++ unsigned char *optend = optp + len; ++ ++ fmatch = FMATCH_OK; ++ ++ if (*optp == 2) /* MSS */ ++ mss = ntohs(*(unsigned short *)(optp+2)); ++ ++ if (len != 1) ++ { ++ /* Skip kind and length fields*/ ++ optp += 2; ++ ++ if (fingers[i].opt[optnum].wc.wc != 0) ++ { ++ unsigned long tmp = 0; ++ ++ /* Hmmm... It looks a bit ugly. :) */ ++ memcpy(&tmp, &fingers[i].opt[optnum].wc.val, ++ (len > sizeof(unsigned long)? ++ sizeof(unsigned long):len)); ++ ++ tmp = ntohl(tmp); ++ if (tmp != fingers[i].opt[optnum].wc.val) ++ fmatch = FMATCH_OPT_WRONG; ++ } ++ } ++ ++ optp = optend; ++ } ++ else ++ fmatch = FMATCH_OPT_WRONG; ++ ++ if (fmatch != FMATCH_OK) ++ break; ++ } ++ ++ if (fmatch != FMATCH_OPT_WRONG) ++ { ++ fmatch = FMATCH_WRONG; ++ ++ switch (check_WSS) ++ { ++ case 0: ++ if (window == fingers[i].wss.val) ++ fmatch = FMATCH_OK; ++ break; ++ case 1: /* MSS */ ++ if (window == fingers[i].wss.val*mss) ++ fmatch = FMATCH_OK; ++ break; ++ case 2: /* MTU */ ++ if (window == fingers[i].wss.val*(mss+40)) ++ fmatch = FMATCH_OK; ++ break; ++ case 3: /* MOD */ ++ if (window % fingers[i].wss.val == 0) ++ fmatch = FMATCH_OK; ++ break; ++ } ++ } ++ ++ ++ if (fmatch == FMATCH_OK) ++ { ++ ++ log("genre %s[%25s][%d]: ttl=%d, size=%lu, df=%d, " ++ "check_WSS=%d, win=%lu, optsize=%lu:\n", ++ fingers[i].genre, fingers[i].details, i, ++ ip->ttl, totlen, df, ++ check_WSS, window, optsize); ++ break; ++ } ++ } ++ } ++ ++ return (fmatch == FMATCH_OK)?1:0; ++} ++ ++static int ++checkentry(const char *tablename, ++ const struct ipt_ip *ip, ++ void *matchinfo, ++ unsigned int matchsize, ++ unsigned int hook_mask) ++{ ++ if (matchsize != IPT_ALIGN(sizeof(struct ipt_osf_info))) ++ return 0; ++ if (ip->proto != IPPROTO_TCP) ++ return 0; ++ ++ return 1; ++} ++ ++static struct ipt_match osf_match = ++{ ++ { NULL, NULL }, ++ "osf", ++ &match, ++ &checkentry, ++ NULL, ++ THIS_MODULE ++}; ++ ++static int __init osf_init(void) ++{ ++ log("Startng OS fingerprint matching module.\n"); ++ return ipt_register_match(&osf_match); ++} ++ ++static void __exit osf_fini(void) ++{ ++ ipt_unregister_match(&osf_match); ++ log("OS fingerprint matching module finished.\n"); ++} ++ ++module_init(osf_init); ++module_exit(osf_fini); ++ ++MODULE_LICENSE("GPL"); ++MODULE_AUTHOR("Evgeniy Polyakov <[email protected]>"); ++MODULE_DESCRIPTION("Passive OS fingerprint matching.");
patch-o-matic/base/osf.patch.config.in +4 -0
@@ -0,0 +1,4 @@ + dep_tristate ' TOS match support' CONFIG_IP_NF_MATCH_TOS $CONFIG_IP_NF_IPTABLES + if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then + dep_tristate ' OSF match support (EXPERIMENTAL)' CONFIG_IP_NF_MATCH_OSF $CONFIG_IP_NF_IPTABLES + fi
patch-o-matic/base/osf.patch.configure.help +20 -0
@@ -0,0 +1,20 @@ +CONFIG_IP_NF_MATCH_TOS +OSF match support +CONFIG_IP_NF_MATCH_OSF + + The idea of passive OS fingerprint matching exists for quite a long time, + but was created as extension fo OpenBSD pf only some weeks ago. + Original idea was lurked in some OpenBSD mailing list (thanks + grange@open...) and than adopted for Linux netfilter in form of this code. + + Original table was created by Michal Zalewski <[email protected]> for + his excellent p0f and than changed a bit for more convenience. + + This module compares some data(WS, MSS, options and it's order, ttl, + df and others) from first SYN packet (actually from packets with SYN + bit set) with hardcoded in fingers[] table ones. + + If you say Y here, try iptables -m osf --help for more information. + + If you want to compile it as a module, say M here and read + Documentation/modules.txt. If unsure, say `N'.
patch-o-matic/base/osf.patch.help +31 -0
@@ -0,0 +1,31 @@ +Author: Evgeniy Polyakov <[email protected]> +Status: Works for Evgeniy + + The idea of passive OS fingerprint matching exists for quite a long time, + but was created as extension fo OpenBSD pf only some weeks ago. + Original idea was lurked in some OpenBSD mailing list (thanks + grange@open...) and than adopted for Linux netfilter in form of this code. + + Original table was created by Michal Zalewski <[email protected]> for + his excellent p0f and than changed a bit for more convenience. + + This module compares some data(WS, MSS, options and it's order, ttl, + df and others) from first SYN packet (actually from packets with SYN + bit set) with hardcoded in fingers[] table ones. + + Example: (Of course this only an example, do not get inspired by this) + + # iptables -N LINUX + # iptables -A LINUX -j LOG --log-prefix "Linux" + + # iptables -A INPUT -p tcp -m osf --genre Linux -j LINUX + # iptables -A INPUT -p tcp -m osf --genre FreeBSD -j REJECT + + NOTE: -p tcp is obviously required as it is a TCP match. + + The available genres are: Linux, FreeBSD, NetBSD, OpenBSD, Windows + + If you say Y here, try iptables -m osf --help for more information. + + This module has been written as a standalone kernel module and has been + converted to patch-o-matic by Maciej Soltysiak <[email protected]>
patch-o-matic/base/osf.patch.makefile +4 -0
@@ -0,0 +1,4 @@ +obj-$(CONFIG_IP_NF_MATCH_TOS) += ipt_tos.o + +obj-$(CONFIG_IP_NF_MATCH_OSF) += ipt_osf.o +
userspace/extensions/.osf-test +3 -0
@@ -0,0 +1,3 @@ +#!/bin/sh +# True if osf is applied. +[ -f $KERNEL_DIR/include/linux/netfilter_ipv4/ipt_osf.h ] && echo osf
userspace/extensions/libipt_osf.c +126 -0
126 lines not on this page · raw message
Quoted 1 line · On Wed, 10 Sep 2003 17:00:25 +0200 (CEST) Maciej Soltysiak…
Hello Evgeniy, folks,
Good day.
Quoted 5 lines
Quoted 1 line
So, if you are interested in, please see and comment :)
I took the privilege and made a patch for netfilter CVS to include this module in patch-o-matic, so it would be easier for people to test this module as a simple patch.
Quoted 7 lines
I also wrote an example, added lists of available genres and wrote osf.patch.configure.help and osf.patch.help messages.
I am sending the patch attached for the netfilter CVS.
Also this patch is available at
http://soltysiak.com/linux/osf.patch
Super!
I have an idea to make fingerprint table dynamic and write a little program to parse and load whole Michal's table through ioctl or /proc.
Quoted 1 line
Maciej Soltysiak
Evgeniy Polyakov ( s0mbre )
Quoted 3 lines
I have an idea to make fingerprint table dynamic and write a little program to parse and load whole Michal's table through ioctl or /proc.
That would be great, then fingerprints could be easily added without recompilating the modules.
osf could also be made a target, that would work like LOG, and would log basically things that are with OSF_DEBUG, but maybe showed the IP too.
You could then do simple OS accounting and see if there's more linux or any other traffic.
Quoted 1 line
Evgeniy Polyakov ( s0mbre )
Maciej
Quoted 1 line · Maciej Soltysiak
I am sending the patch attached for the netfilter CVS.
Applying it to CVS right now.
Quoted 2 lines
Quoted 1 line
Evgeniy Polyakov
Maciej Soltysiak
Signature · 5 lines
- Harald Welte <[email protected]> http://www.netfilter.org/ ============================================================================ "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie