| 1 | |
| 2 | |
| 3 | * Copyright (c) 2003+ Evgeniy Polyakov <[email protected]>
|
| 4 |
|
| 5 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
| 6 | #include <linux/module.h>
|
| 7 | #include <linux/kernel.h>
|
| 8 |
|
| 9 | #include <linux/capability.h>
|
| 10 | #include <linux/if.h>
|
| 11 | #include <linux/inetdevice.h>
|
| 12 | #include <linux/ip.h>
|
| 13 | #include <linux/list.h>
|
| 14 | #include <linux/rculist.h>
|
| 15 | #include <linux/skbuff.h>
|
| 16 | #include <linux/slab.h>
|
| 17 | #include <linux/tcp.h>
|
| 18 |
|
| 19 | #include <net/ip.h>
|
| 20 | #include <net/tcp.h>
|
| 21 |
|
| 22 | #include <linux/netfilter/nfnetlink.h>
|
| 23 | #include <linux/netfilter/x_tables.h>
|
| 24 | #include <net/netfilter/nf_log.h>
|
| 25 | #include <linux/netfilter/xt_osf.h>
|
| 26 |
|
| 27 | static bool
|
| 28 | xt_osf_match_packet(const struct sk_buff *skb, struct xt_action_param *p)
|
| 29 | {
|
| 30 | if (p->fragoff)
|
| 31 | return false;
|
| 32 |
|
| 33 | return nf_osf_match(skb, xt_family(p), xt_hooknum(p), xt_in(p),
|
| 34 | xt_out(p), p->matchinfo, xt_net(p), nf_osf_fingers);
|
| 35 | }
|
| 36 |
|
| 37 | static struct xt_match xt_osf_match = {
|
| 38 | .name = "osf",
|
| 39 | .revision = 0,
|
| 40 | .family = NFPROTO_IPV4,
|
| 41 | .proto = IPPROTO_TCP,
|
| 42 | .hooks = (1 << NF_INET_LOCAL_IN) |
|
| 43 | (1 << NF_INET_PRE_ROUTING) |
|
| 44 | (1 << NF_INET_FORWARD),
|
| 45 | .match = xt_osf_match_packet,
|
| 46 | .matchsize = sizeof(struct xt_osf_info),
|
| 47 | .me = THIS_MODULE,
|
| 48 | };
|
| 49 |
|
| 50 | static int __init xt_osf_init(void)
|
| 51 | {
|
| 52 | int err;
|
| 53 |
|
| 54 | err = xt_register_match(&xt_osf_match);
|
| 55 | if (err) {
|
| 56 | pr_err("Failed to register OS fingerprint "
|
| 57 | "matching module (%d)\n", err);
|
| 58 | return err;
|
| 59 | }
|
| 60 |
|
| 61 | return 0;
|
| 62 | }
|
| 63 |
|
| 64 | static void __exit xt_osf_fini(void)
|
| 65 | {
|
| 66 | xt_unregister_match(&xt_osf_match);
|
| 67 | }
|
| 68 |
|
| 69 | module_init(xt_osf_init);
|
| 70 | module_exit(xt_osf_fini);
|
| 71 |
|
| 72 | MODULE_LICENSE("GPL");
|
| 73 | MODULE_AUTHOR("Evgeniy Polyakov <[email protected]>");
|
| 74 | MODULE_DESCRIPTION("Passive OS fingerprint matching.");
|
| 75 | MODULE_ALIAS("ipt_osf");
|
| 76 | MODULE_ALIAS("ip6t_osf");
|