一月一次(冏)的成都Linux用户组聚会于7月9号下午2点在嘉联咖啡(四川省成都市青羊区双清南路6号)开始,有网络请自带笔记本。
欢迎大家踊跃参与 
原则:Topic不限,最好和Linux、开源有关
======= update =======
6月9号下午2点,Shawn在嘉联咖啡分享了hacking netfilter。
那边环境不错,虽然,没怎么看到传说中的留学mm
文章猛击这里。
$ uudecode hacking_the_wholism_of_linux_net.txt
$ ls
hacking_the_wholism_of_linux_net.txt netfilter_hacks.tar.gz
$ tar zxf netfilter_hacks.tar.gz
就可以看到实例代码了。
filter_if_ip 是一个包过滤程序,有三个功能,根据:网络接口、ip地址及端口丢弃包。
分别有下面三个函数完成:
filter_by_if
filter_by_ipaddr
check_tcp_packet
init_filter_if中只调用了check_tcp_packet,所以,程序默然的功能是丢弃到22端口的包。
$ cd netfilter_hacks/filter_if_ip
Ubuntu 用户修改Makefile如下:
KERNEL_DIR=/usr/src/linux-headers-`uname -r`
编译、加载kernel module
$ make
$ sudo insmod filter_if.ko
$ dmesg | tail
应该可以看到initializing the hooks!,说明module已经加载成功。
$ ssh 127.0.0.1 # drop package from 127.0.0.1
[87008.420541] droped tcp packet from…IP:127.0.0.1 Port:22 Application:ssh
[87011.430109] droped tcp packet from…IP:127.0.0.1 Port:22 Application:ssh
[87017.440144] droped tcp packet from…IP:127.0.0.1 Port:22 Application:ssh
$ ssh 192.168.0.103 # drop package which port is 22
[87609.800502] droped tcp packet from…IP:192.168.0.103 Port:22 Application:ssh
[87612.810098] droped tcp packet from…IP:192.168.0.103 Port:22 Application:ssh
[87618.820105] droped tcp packet from…IP:192.168.0.103 Port:22 Application:ssh
[87630.840044] droped tcp packet from…IP:192.168.0.103 Port:22 Application:ssh
卸载module
$ sudo rmmod filter_if
$ dmesg | tail
可以看到 bye hooks
现在ssh 127.0.0.1 应该可以正常工作,如果你安装ssh server并启动的话。
文章中讲了很多,这个实例比较简单,可以继续测试下其他两个功能。
Enjoy it!