免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1609 | 回复: 1
打印 上一主题 下一主题

[学习分享] 使用netfilter过滤滤字符串,参考iptables string, 使用2个函数,都没有识别到 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2015-02-10 17:32 |只看该作者 |倒序浏览
unsigned int checksum(unsigned int hooknum,
                        struct sk_buff *__skb,
                        const struct net_device *in,
                        const struct net_device *out,
                        int (*okfn)(struct sk_buff *))
{
        struct sk_buff *skb;
        struct iphdr *iph;

        struct ts_state state;

        struct ts_config *ts_conf;
        int rst = 0;

        skb = __skb;
        if(skb == NULL)        return NF_ACCEPT;
        iph = ip_hdr(skb);
        if(iph == NULL)        return NF_ACCEPT;

        memset(&state, 0, sizeof(struct ts_state));

        ts_conf = textsearch_prepare("kmp", "taobao", 6, GFP_KERNEL, TS_AUTOLOAD);
        if(IS_ERR(ts_conf))
        {
                printk("limeng,conf err\n");
                return NF_ACCEPT;
        }

        rst = skb_find_text((struct sk_buff *)skb, 0, strlen(__skb), ts_conf, &state);
        if(UINT_MAX != rst)
        {
                printk("limeng,skb_find\n");
                textsearch_destroy(ts_conf);
                return NF_DROP;
        }
       
        rst = textsearch_find_continuous(ts_conf, &state, __skb, strlen(__skb));
        if(UINT_MAX != rst)
        {
                printk("limeng,textsearch\n");
                textsearch_destroy(ts_conf);
                return NF_DROP;
        }
       
        textsearch_destroy(ts_conf);
        return NF_ACCEPT;
}

论坛徽章:
0
2 [报告]
发表于 2015-02-10 17:34 |只看该作者
想请教下大家,为什么这样识别不到呢.我打开了淘宝网页. 一个相关日志都没有, 不知道哪里的问题...
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP