用IPTables实现字符串模式匹配

http://tech.ddvip.com   2006年04月03日    社区交流 收藏本文

本文详细介绍用IPTables实现字符串模式匹配

  make install KERNEL_DIR=/usr/src/linux-2.4.16

  紧接着我们配置和编译核心:

  Now we are ready to compile the user-space code and the libraries:

  make KERNEL_DIR=/usr/src/linux-2.4.16

  and then install them (iptables program goes in /usr/local/user/sbin and libraries go into /usr/local/lib/iptables). As root:

  cd /usr/src/linux-2.4.16

  可以使用任何的核心配置方法。有关详细的配置核心的方法,可以查阅Internet资源,Internet上有大量的这方面的文档,比如kernel HOWTO等。以下简要介绍一下:

  make xconfig

  在GUI界面下,选择Netfilter配置选项,然后在Strings match support前选择m(模块支持)

  然后执行通常的操作:

  make dep;make bzImage;make modules;make modules_install

  现在按照你喜欢的方式安装核心,并重新启动。重新启动系统以后,测试一下iptables是否支持模式匹配功能,在root身份下执行:

  /usr/local/sbin/iptables -m string -help

  该命令将显示如下标准的iptables帮助信息:

  STRING match v1.2.4 options:

  --string [!] string Match a string in a packet

  该功能允许你对匹配数据包的内容,我们可以通过netcat或者telnet来测试这一功能,从而确定我们确实可以获得数据包的内容。

  运行:

  iptables -A INPUT -m string --string "test" -j LOG --log-level

  info --log-prefix "TEST"

  然后启动一个netcat的服务器:

  nc -l -p 3456

  然后连接该netcat服务器:

  telnet localhost 3456

责编:豆豆技术应用

正在加载评论...