2019-05-19 13:51:43 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2009-06-08 15:01:51 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2003+ Evgeniy Polyakov <zbr@ioremap.net>
|
|
|
|
*/
|
2010-03-17 15:04:40 +00:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
2009-06-08 15:01:51 +00:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
|
2017-12-05 23:42:41 +00:00
|
|
|
#include <linux/capability.h>
|
2009-06-08 15:01:51 +00:00
|
|
|
#include <linux/if.h>
|
|
|
|
#include <linux/inetdevice.h>
|
|
|
|
#include <linux/ip.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/rculist.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/tcp.h>
|
|
|
|
|
|
|
|
#include <net/ip.h>
|
|
|
|
#include <net/tcp.h>
|
|
|
|
|
|
|
|
#include <linux/netfilter/nfnetlink.h>
|
|
|
|
#include <linux/netfilter/x_tables.h>
|
|
|
|
#include <net/netfilter/nf_log.h>
|
|
|
|
#include <linux/netfilter/xt_osf.h>
|
|
|
|
|
2009-07-05 17:43:26 +00:00
|
|
|
static bool
|
2009-07-07 18:42:08 +00:00
|
|
|
xt_osf_match_packet(const struct sk_buff *skb, struct xt_action_param *p)
|
2009-06-08 15:01:51 +00:00
|
|
|
{
|
2018-05-03 12:05:40 +00:00
|
|
|
return nf_osf_match(skb, xt_family(p), xt_hooknum(p), xt_in(p),
|
2018-10-11 08:58:26 +00:00
|
|
|
xt_out(p), p->matchinfo, xt_net(p), nf_osf_fingers);
|
2009-06-08 15:01:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct xt_match xt_osf_match = {
|
|
|
|
.name = "osf",
|
|
|
|
.revision = 0,
|
|
|
|
.family = NFPROTO_IPV4,
|
|
|
|
.proto = IPPROTO_TCP,
|
|
|
|
.hooks = (1 << NF_INET_LOCAL_IN) |
|
|
|
|
(1 << NF_INET_PRE_ROUTING) |
|
|
|
|
(1 << NF_INET_FORWARD),
|
|
|
|
.match = xt_osf_match_packet,
|
|
|
|
.matchsize = sizeof(struct xt_osf_info),
|
|
|
|
.me = THIS_MODULE,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init xt_osf_init(void)
|
|
|
|
{
|
2018-07-24 23:32:45 +00:00
|
|
|
int err;
|
2009-06-08 15:01:51 +00:00
|
|
|
|
|
|
|
err = xt_register_match(&xt_osf_match);
|
|
|
|
if (err) {
|
2010-03-17 15:04:40 +00:00
|
|
|
pr_err("Failed to register OS fingerprint "
|
|
|
|
"matching module (%d)\n", err);
|
2018-07-24 23:32:45 +00:00
|
|
|
return err;
|
2009-06-08 15:01:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit xt_osf_fini(void)
|
|
|
|
{
|
|
|
|
xt_unregister_match(&xt_osf_match);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(xt_osf_init);
|
|
|
|
module_exit(xt_osf_fini);
|
|
|
|
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>");
|
|
|
|
MODULE_DESCRIPTION("Passive OS fingerprint matching.");
|
2014-03-26 10:37:59 +00:00
|
|
|
MODULE_ALIAS("ipt_osf");
|
|
|
|
MODULE_ALIAS("ip6t_osf");
|
2009-06-08 15:01:51 +00:00
|
|
|
MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_OSF);
|