全部博文(408)
分类: LINUX
2006-07-13 11:24:12
系统平台:Debian 3.0 r2
软件版本:portsentry 1.1-3
概述:
防火墙能保护我们的网络以防入侵,使用防火墙我们可以选择被保护的网络主机对外开放的端口。这些对外开放的端口可能常常就会成为黑客攻击的目标,一 般情况下我们并不希望对外公布这些信息。但是黑客们会使用工具对目标主机进行端口扫描以获取这些信息,从而对存在漏洞的网络服务进行攻击。
Portsentry是一个用来检测各种类型端口扫描,实时响应的工具。当它发现可疑的扫描会实时产生以下动作(可选):
* 通过syslog产生事件日志
* 目标主机自动加入hosts.deny中
* 本地主机自动产生一条指向目标主机的路由空洞
* 本地主机通过本地包过滤软件(IPTABLES)生成一条drop所有前往目标主机的数据包
安装:
Portsentry的安排很简单,在此以debian系统二进制文件安装为例。
Apt-get install portsentry
就一条命令,是不是很简单,J。
Portsentry文件如下:
―――――――――――――――――――
/.
/usr
/usr/sbin
/usr/sbin/portsentry
/usr/lib
/usr/lib/portsentry
/usr/lib/portsentry/portsentry-add-ip
/usr/lib/portsentry/portsentry-build-ignore-file
/usr/lib/portsentry/portsentry-rm-ip
/usr/share
/usr/share/doc
/usr/share/doc/portsentry
/usr/share/doc/portsentry/README.COMPAT
/usr/share/doc/portsentry/README.stealth.gz
/usr/share/doc/portsentry/CREDITS.gz
/usr/share/doc/portsentry/changelog.Debian.gz
/usr/share/doc/portsentry/README.Debian
/usr/share/doc/portsentry/TODO.Debian
/usr/share/doc/portsentry/copyright
/usr/share/doc/portsentry/examples
/usr/share/doc/portsentry/examples/ignore.csh
/usr/share/doc/portsentry/examples/kill_cmd
/usr/share/doc/portsentry/examples/scan-detect
/usr/share/doc/portsentry/CHANGES.gz
/usr/share/doc/portsentry/README.install.gz
/usr/share/doc/portsentry/README.methods.gz
/usr/share/man
/usr/share/man/man8
/usr/share/man/man8/portsentry.8.gz
/usr/share/man/man5
/usr/share/man/man5/portsentry.conf.5.gz
/var
/var/lib
/var/lib/portsentry
/etc
/etc/portsentry
/etc/portsentry/portsentry.ignore.static
/etc/portsentry/portsentry.conf
/etc/default
/etc/ppp
/etc/ppp/ip-up.d
/etc/ppp/ip-up.d/portsentry
/etc/ppp/ip-down.d
/etc/ppp/ip-down.d/portsentry
/etc/init.d
/etc/init.d/portsentry
/usr/share/doc/portsentry/changelog.gz
―――――――――――――――――――
配置:
示例:
使用Advanced Stealth Scan Detection方式,推荐只监测小于1024的tcp,udp端口,使用iptables做为监测到扫描后的动作。
配置文件:
/etc/portsentry/portsentry.conf
修改以下内容:
=============================
ADVANCED_PORTS_TCP="1024"
ADVANCED_PORTS_UDP="1024"
# Default TCP ident and NetBIOS service
ADVANCED_EXCLUDE_TCP="113,139"
# Default UDP route (RIP), NetBIOS, bootp broadcasts.
ADVANCED_EXCLUDE_UDP="520,138,137,67"
# 0 = Do not block UDP/TCP scans.
# 1 = Block UDP/TCP scans.
# 2 = Run external command only (KILL_RUN_CMD)
BLOCK_UDP="1"
BLOCK_TCP="1"
# iptables support for Linux
KILL_ROUTE="/usr/bin/iptables -I INPUT -s $TARGET$ -j DROP"
=============================
注:
将 Dropping Routes栏中的除KILL_ROUTE="/usr/bin/iptables -I INPUT -s $TARGET$ -j DROP"的其它KILL_ROUTE全部用#注释掉,并将TCP Wrappers中的内容也全部注释掉。
/etc/portsentry/portsentry.ignore.static
在此配置文件内加入需要忽略的网段,一般是内网或其它安全的网段。
/etc/default/portsentry
TCP_MODE=”atcp”
UDP_MODE=’audp”
至此portsentry基本已配置完成了。
用/etc/init.d/portsentry start启动portsentry
测试工具:
Superscan
Nmap