能ping别人,但别人ping 不到
来源:互联网 发布:靠谱的无印良品淘宝店 编辑:程序博客网 时间:2024/04/29 08:42
/*
* File : li_filter.c writen by kunlong
* Kernel : 2.2.16 or 2.2.14 or 2.4.2
* Complie : gcc -O3 -c li_filter.c
* Usage : insmod li_filter.o -f
* Date : 2001-06-28
*/
#ifndef __KERNEL__
#define __KERNEL__
#endif
#ifndef MODULE
#define MODULE
#endif
#include <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/version.h>
#include <linux/netdevice.h>
#include <linux/if_ether.h>
#include <linux/if_packet.h>
#include <linux/skbuff.h>
#include <linux/ip.h>
#include <linux/icmp.h>
#include <linux/in.h>
#ifndef KERNEL_VERSION
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
#endif
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,2,0)
#include <asm/uaccess.h>
#endif
static struct device * filter_dev = NULL;
static char * dev = NULL;
/* 定义insmod命令行参数 */
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,2,0)
MODULE_PARM( dev, "s" );
#endif
int filter_rcv ( struct sk_buff * skb, struct device * dv, struct packet_type * pt )
{
/* 注意pkt_type是什么 */
if ( ( skb->pkt_type == PACKET_HOST ) && ( skb->protocol == __constant_htons( ETH_P_IP) ) )
{
if ( ( skb->nh.iph->version == 4 ) && ( skb->nh.iph->protocol == IPPROTO_ICMP ) ) /* 不考虑ipv6 */
{
skb->h.raw = skb->nh.raw + ( skb->nh.iph->ihl << 2 );
if ( skb->h.icmph->type == 8 )
{
unsigned char *saddr = &(skb->nh.iph->saddr);
printk("<1>--- ping from: %d.%d.%d.%d ---/n", *saddr,*(saddr+1),*(saddr+2),*(saddr+3));
skb->h.icmph->checksum += 1; // Change the checksum, then this IP packet will be Ignored.
}
}
}
kfree_skb( skb );
return( 0 );
} /* end of filter_rcv */
static struct packet_type filter_packet_type =
{
__constant_htons( ETH_P_ALL ), /* 此时可以接收到来自lo的回送报文,比如本机发送出去的 */
NULL, /* All devices */
filter_rcv,
NULL, /* 如果是2.4内核,这里可以考虑设置成非零,但是filter_rcv需要改变 */
NULL,
};
int init_module ( void ) /* 模块初始化 */
{
if ( dev != NULL )
{
filter_dev = dev_get( dev );
if ( filter_dev != NULL )
{
filter_packet_type.dev = filter_dev;
}
}
dev_add_pack( &filter_packet_type );
EXPORT_NO_SYMBOLS;
return( 0 );
} /* end of init_module */
void cleanup_module ( void ) /* 模块卸载 */
{
dev_remove_pack( &filter_packet_type );
return;
} /* end of cleanup_module */
* File : li_filter.c writen by kunlong
* Kernel : 2.2.16 or 2.2.14 or 2.4.2
* Complie : gcc -O3 -c li_filter.c
* Usage : insmod li_filter.o -f
* Date : 2001-06-28
*/
#ifndef __KERNEL__
#define __KERNEL__
#endif
#ifndef MODULE
#define MODULE
#endif
#include <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/version.h>
#include <linux/netdevice.h>
#include <linux/if_ether.h>
#include <linux/if_packet.h>
#include <linux/skbuff.h>
#include <linux/ip.h>
#include <linux/icmp.h>
#include <linux/in.h>
#ifndef KERNEL_VERSION
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
#endif
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,2,0)
#include <asm/uaccess.h>
#endif
static struct device * filter_dev = NULL;
static char * dev = NULL;
/* 定义insmod命令行参数 */
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,2,0)
MODULE_PARM( dev, "s" );
#endif
int filter_rcv ( struct sk_buff * skb, struct device * dv, struct packet_type * pt )
{
/* 注意pkt_type是什么 */
if ( ( skb->pkt_type == PACKET_HOST ) && ( skb->protocol == __constant_htons( ETH_P_IP) ) )
{
if ( ( skb->nh.iph->version == 4 ) && ( skb->nh.iph->protocol == IPPROTO_ICMP ) ) /* 不考虑ipv6 */
{
skb->h.raw = skb->nh.raw + ( skb->nh.iph->ihl << 2 );
if ( skb->h.icmph->type == 8 )
{
unsigned char *saddr = &(skb->nh.iph->saddr);
printk("<1>--- ping from: %d.%d.%d.%d ---/n", *saddr,*(saddr+1),*(saddr+2),*(saddr+3));
skb->h.icmph->checksum += 1; // Change the checksum, then this IP packet will be Ignored.
}
}
}
kfree_skb( skb );
return( 0 );
} /* end of filter_rcv */
static struct packet_type filter_packet_type =
{
__constant_htons( ETH_P_ALL ), /* 此时可以接收到来自lo的回送报文,比如本机发送出去的 */
NULL, /* All devices */
filter_rcv,
NULL, /* 如果是2.4内核,这里可以考虑设置成非零,但是filter_rcv需要改变 */
NULL,
};
int init_module ( void ) /* 模块初始化 */
{
if ( dev != NULL )
{
filter_dev = dev_get( dev );
if ( filter_dev != NULL )
{
filter_packet_type.dev = filter_dev;
}
}
dev_add_pack( &filter_packet_type );
EXPORT_NO_SYMBOLS;
return( 0 );
} /* end of init_module */
void cleanup_module ( void ) /* 模块卸载 */
{
dev_remove_pack( &filter_packet_type );
return;
} /* end of cleanup_module */
- 能ping别人,但别人ping 不到
- 如何对付别人的PING
- 阻止别人ping你的主机[附图]
- 如何防止别人PING你的计算机?
- 禁止别人ping你的Linux主机
- 防止别人PING你的计算机
- 局域网内ping不通别人的主机
- 能ping通ip地址,但不能ping通域名
- ping不通hostName,但能ping通ip
- 局域网内我能ping通所有的机器,也能正常上网,但是别人就是ping不通我的机器的解决方法
- window能远程,但不能ping通
- 有些IP可以ping通,有些IP ping不通,别人无法ping通你的IP
- 如果不让别人ping通自己的计算机。
- 防止别人ping通你的linux主机
- 用大量ping命令回敬别人的探测
- Linux禁止别人PING通你的服务器
- 如何让别人PING不通你的机器
- Windows7 32bit 别人ping不通我的计算机
- [连载]好心收留他,但他却抢了我老婆?(三)
- C# 控件命名规范
- ON_COMMAND_RANGE用法
- 繁简体(GBBig5)字符串转化的JAVA方式实现
- [连载]好心收留他,但他却抢了我老婆?(四)
- 能ping别人,但别人ping 不到
- 文件关联从入门到精通
- [连载]好心收留他,但他却抢了我老婆?(五)
- 开通我的博客了
- 好心收留他,但他却抢了我老婆?(六)
- IIS站点发生意外假死情况处理
- JBOSS SESSION集群配置过程
- 好心收留他,但他却抢了我老婆?(七)
- 好心收留他,但他却抢了我老婆?(八)