LinuxSoft


PortSentry ¤Ë´Ø¤¹¤ëÆüËܸì¾ðÊó †

PortSentry ¤Ã¤Æ²¿¡© †

¡¡IDS ¤È¤·¤Æ¤Ï Snort ¤¬Èó¾ï¤Ëͭ̾¤Ç¤¹¤¬¡¢Snort ¤Ï¤¢¤¯¤Þ¤Ç¥Í¥Ã¥È¥ï¡¼¥¯¤ä¥Û¥¹¥È¤ËÂФ¹¤ë¿¯Æþ¸¡ÃΡ¢¸¡ÃÎ¤Î¥í¥°¤Îµ­Ï¿¤Î¤ß¤Ç¤¹¡£µ¤¤¬¤Ä¤¤¤¿º¢¤Ë¤Ï´û¤ËÉÔÀµ¥¢¥¯¥»¥¹¤ò¼õ¤±¤Æ¤·¤Þ¤Ã¤¿¡¢¤È¤¤¤¦»ö¤â½½Ê¬¤¢¤êÆÀ¤Þ¤¹¡£

¡¡ÂФ·¤Æ PortSentry ¤Ï¿¯Æþ¡Ê¥Ý¡¼¥È¥¹¥­¥ã¥ó¡Ë¤ò"¤¤¤Þ¤½¤³¤Ë¤¢¤ë´íµ¡"¤È¤·¤Æ¡¢Ä¾¤Á¤Ë iptables ¤Ç¥Õ¥£¥ë¥¿¥ê¥ó¥°¤ò¼Â»Ü¤¹¤ëµ¡Ç½¤òÈ÷¤¨¤Æ¤¤¤Þ¤¹¡ÊɬÍפȤ¢¤ì¤ÐÊóÉüÍѤΠDos ¹¶·â¤ò¹Ô¤¦¤è¤¦¤Ê¥³¥Þ¥ó¥É¤â¼Â¹Ô¤Ç¤­¤Þ¤¹¡Ä¡Ä¤¬¿ä¾©¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡¢¤¢¤¿¤êÁ°¤Ç¤¹¤Í¡Ë¡£

¡¡Ä̾ï¤Î¥Ý¡¼¥È¤ËÂФ¹¤ë¥¢¥¿¥Ã¥¯¤ä¥Ý¡¼¥È¥¹¥­¥ã¥ó¡¢¥¹¥Æ¥ë¥¹¡¦¥¹¥­¥ã¥ó¤Ë¤âÂбþ¤·¤Æ¤¤¤Þ¤¹¡£ÌÌÇò¤¤¤Î¤Ï´Æ»ëÂоݤΥݡ¼¥È¤¬°ì¸«³«¤¤¤Æ¤¤¤ë¤è¤¦¤Ë¸«¤¨¤ë¤³¤È¡£¤Á¤ã¤ó¤È±þÅú¤·¤Æ¤¤¤ë¤è¤¦¤Ë¸«¤»¤«¤±¤Æ¡¢¤½¤Îľ¸å¤Ë¥Í¥Ã¥È¥ï¡¼¥¯¤ò¼×ÃǤ¹¤ë¥×¥í¥°¥é¥à(iptables¤Ê¤É)¤ò¼Â¹Ô¤·¤Þ¤¹¡£¹¶·â¼Ô¤«¤é¤¹¤ë¤È¡¢¤¢¤ì¡©¥Ý¡¼¥È¤¬³«¤¤¤Æ¤¤¤ë¤Ï¤º¤Ê¤Î¤Ë²¿¸Î±þÅú¤·¤Ê¤¤¤«¤Ê¤¡¤È¥¤¥é¥¤¥é¤µ¤»¤ë¤³¤È¤âÌÜŪ¤À¤½¤¦¤Ç¤¹¡Ê¥É¥­¥å¥á¥ó¥È¤Ë¤¢¤ê¤Þ¤·¤¿¡Ë¡Ä¡Ä¾Ü¤·¤¯¤ÏPortSentry README ÆüËܸìÌõ¤ò¤´Í÷²¼¤µ¤¤¡£

URL †

http://sourceforge.net/projects/sentrytools/

¥é¥¤¥»¥ó¥¹ †

Common Public License, GNU General Public License (GPL)

PortSentry ¤Î¥¤¥ó¥¹¥È¡¼¥ë †

¡¡¤³¤Î¥¤¥ó¥¹¥È¡¼¥ë¤Ï Red Hat Linux 7.3 ¤Ç¹Ô¤¤¤Þ¤·¤¿¡£ºÇ¶á¤Î REHL ¤ä Fedora Core ¤Ç¤âƱÍͤÎÊýË¡¤Ç¥»¥Ã¥È¥¢¥Ã¥×¤Ç¤­¤ë¤È»×¤¤¤Þ¤¹¡£

¡¡¤Þ¤º¤Ï¥¢¡¼¥«¥¤¥Ö¤Î¼èÆÀ¤ÈŸ³«¤Ç¤¹¡£¤³¤Î¤¢¤¿¤ê¤Ï¤ªÌó«¤Ç¤¹¤Í¡£

$ wget http://jaist.dl.sourceforge.net/sourceforge/sentrytools/portsentry-1.2.tar.gz
$ tar xfz portsentry-1.2.tar.gz
$ cd portsentry_beta

¡¡ÀßÄê¥Õ¥¡¥¤¥ë portsentry_config.h ¤òÊÔ½¸¤·¤Þ¤¹¡£

$ vi portsentry_config.h

¡¡¥¤¥ó¥¹¥È¡¼¥ëÀè¤ä hosts.deny ¥Õ¥¡¥¤¥ë¤Î¥Ñ¥¹¤Î³Îǧ¤Ç¤¹¡£É¸½à¤Î¤Þ¤ÞÆÃ¤ËÊѹ¹¤·¤Ê¤¤¤ÇÍѤ¤¤ë¤³¤È¤Ë¤·¤Þ¤¹¡£

#define CONFIG_FILE "/usr/local/psionic/portsentry/portsentry.conf"
#define WRAPPER_HOSTS_DENY "/etc/hosts.deny"
#define SYSLOG_FACILITY LOG_DAEMON
#define SYSLOG_LEVEL LOG_NOTICE

¡¡¼¡¤Ï portsentry.conf ¤Ç¸¡½ÐÂоݤȤ¹¤ë¥Ý¡¼¥È¤ò»ØÄꤷ¤Þ¤¹¡£

TCP_PORTS="1,11,15,79,111,119,143,540,635,(ά),49724,54320"
UDP_PORTS="1,7,9,69,161,162,513,635,640,641,(ά),32774,31337,54321"

¡¡¤³¤³¤âÆÃ¤ËÊѹ¹¤»¤º¡¢¥Ç¥Õ¥©¥ë¥È¤Î¤Þ¤Þ»È¤¦¤³¤È¤Ë¤·¤Þ¤¹¡£

¡¡¿¯Æþ¸¡½Ð»þ¡¢¥Í¥Ã¥È¥ï¡¼¥¯¤ò¼×ÃǤµ¤»¤ëÊýË¡¤Ï iptables ¤ò»È¤¦¤³¤È¤Ë¤·¤Þ¤¹¡£206 ¹ÔÌÜ¤Ë°ÜÆ°¤·¤Æ³ºÅö¹Ô¤Î¥³¥á¥ó¥È¤òºï½ü¤·¤Æ¡¢iptables ¤Î¥Ñ¥¹¤ò /sbin/iptables ¤Ë½¤Àµ¤·¤Þ¤¹¡£

# iptables support for Linux
KILL_ROUTE="/sbin/iptables -I INPUT -s $TARGET$ -j DROP"

¡Êroute ¥³¥Þ¥ó¥É¤ò»È¤Ã¤Æ /sbin/route add xxx.xxx.xxx.xxx reject ¤Ç¤âµ¡Ç½¤Ï¤·¤Þ¤¹¡¢man ÆÉ¤à¤È¥Õ¥¡¥¤¥¢¥¦¥©¡¼¥ë¤È¤·¤Æ¤Ï»È¤¦¤Ê¡¢¤È¤¢¤ë¤Î¤Ç¡¢ÁÇľ¤Ë iptables ¤ò»È¤¦¤³¤È¤Ë¤·¤Þ¤¹¡£¡Ë

¡¡¼¡¤Ï´Æ»ëÂоݳ°¤È¤¹¤ë¥Û¥¹¥È¾ðÊó¤ÎÅÐÏ¿¤Ç¤¹¡£

$ vi portsentry.ignore

¡¡¥Õ¥¡¥¤¥ë¤ò³«¤¤¤Æ¡¢IP ¥¢¥É¥ì¥¹¡¢¤â¤·¤¯¤Ï¥Í¥Ã¥È¥ï¡¼¥¯¡Ü¥µ¥Ö¥Í¥Ã¥È¥Þ¥¹¥¯¤ÇÈϰϤò»ØÄꤷ¤Þ¤¹¡£¤³¤³¤Ï¼«Ê¬¤ÎÀܳ´Ä¶­¤òµ­½Ò¤·¤Æ¤ª¤­¤Þ¤»¤ó¤È¡¢²¿¤«¤¢¤ë¤ÈÀܳ¤Ç¤­¤Ê¤¯¤Ê¤Ã¤Æ¤·¤Þ¤¤¤Þ¤¹¡£¤½¤¦¤Ê¤ë¤Èº¤¤ë¤Î¤Ç¡¢É¬¤º¼«Ê¬¤Î´Ä¶­¤ÏÄɲ䷤Ƥª¤­¤Þ¤·¤ç¤¦¡£

127.0.0.1/32
0.0.0.0

¡¡¤³¤³¤Þ¤Ç¤­¤Æ¡¢¤è¤¦¤ä¤¯¥³¥ó¥Ñ¥¤¥ë¤Ç¤¹¡£make ¤È¤¦¤Ä¤È¡¢»È¤¤Êý¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£

$ make
Usage: make <systype>
<systype> is one of: linux, debian-linux, bsd, solaris, hpux, hpux-gcc,
freebsd, osx, openbsd, netbsd, bsdi, aix, osf, irix, generic

This code requires snprintf()/vsnprintf() system calls
to work. If you run a modern OS it should work on
your system with 'make generic'. If you get it to
work on an unlisted OS please write us with the
changes.

Install: make install

NOTE: This will install the package in this
      directory: /usr/local/psionic 

Edit the makefile if you wish to change these paths.
Any existing files will be overwritten.

¡¡¤¤¤í¤¤¤í½Ð¤Æ¤­¤Þ¤¹¤¬¡¢¤³¤Á¤é¤Î¥·¥¹¥Æ¥à¤Ï Red Hat Linux ¤Ê¤Î¤Ç¡Ömake linux¡×¤È¤·¤Æ¥³¥ó¥Ñ¥¤¥ë¤·¤Þ¤¹¡£

$ make linux
# make install

¡¡É¬Íפ˱þ¤¸¤ÆÀßÄê¥Õ¥¡¥¤¥ë /usr/local/psionic/portsentry/portsentry.conf ¤ò³Îǧ¡¦ÊÔ½¸¤·¤Þ¤¹¡£

¡¡ºÇ¸å¤Ëµ¯Æ°¤µ¤»¤Þ¤¹¡£TCP ¤È UDP ¤ò´Æ»ëÂоݤȤ·¤¿¤¤¤Î¤Ç -tcp ¤È -udp ¤Î¥ª¥×¥·¥ç¥ó¤ò¤Ä¤±¤¿£²¤Ä¤Î¥Ç¡¼¥â¥ó¤ò²ÔƯ¤µ¤»¤Þ¤¹¡£

# /usr/local/psionic/portsentry/portsentry -tcp
# /usr/local/psionic/portsentry/portsentry -udp

ps ¥³¥Þ¥ó¥É¤ÇÌäÂê¤Ê¤¯Æ°ºî¤·¤Æ¤¤¤ë»ö¤¬³Îǧ¤Ç¤­¤Þ¤¹¡£

$  ps ax | grep port
25267 ?        S      0:00 /usr/local/psionic/portsentry/portsentry -tcp
25269 ?        S      0:00 /usr/local/psionic/portsentry/portsentry -udp

¡¡ºÇ¸å¤Ë¥µ¡¼¥Ðµ¯Æ°»þ¤Ë PortSentry ¤â¼«Æ°µ¯Æ°¤¹¤ë¤è¤¦¤Ëµ­½Ò¤ò¹Ô¤¤¤Þ¤¹¡£

# vi /etc/rc.d/rc.local

¡¡¥Õ¥¡¥¤¥ë¤ò³«¤¤¤¿¤éËöÈø¤¢¤¿¤ê¤Ë°Ê²¼¤Îµ­½Ò¤òÄɲä·¤Þ¤¹¡£

# PortSentry
/usr/local/psionic/portsentry/portsentry -tdp
/usr/local/psionic/portsentry/portsentry -udp

PortSentry ¤Îưºî³Îǧ †

¡¡¥Ç¡¼¥â¥ó¤Îµ¯Æ°¸å¤Ï /var/log/messages ¤Ë¥á¥Ã¥»¡¼¥¸¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£tail /var/log/messages ¤Çưºî³Îǧ¡£

Jul 24 21:13:37 nsx portsentry[25266]: adminalert: PortSentry 1.2 is starting.
Jul 24 21:13:37 nsx portsentry[25267]: adminalert: Going into listen mode on TCP port: 1
Jul 24 21:13:37 nsx portsentry[25267]: adminalert: Going into listen mode on TCP port: 11
¡ÊŤ¤¤Î¤Çά¡Ë
Jul 24 21:13:39 nsx portsentry[25269]: adminalert: Going into listen mode on UDP port: 54321
Jul 24 21:13:39 nsx portsentry[25269]: adminalert: PortSentry is now active and listening.

Àµ¾ï²ÔƯ¤·¤Æ¤¤¤ë¤è¤¦¤Ç¤¹¡£ÌäÂê¤Ê¤·¡£netstat -na ¤ò¼Â¹Ô¤¹¤ë¤È¡¢·ë¹½ÁÔ´Ñ¡£¸«Ä¥¤Ã¤Æ¤Þ¤¹¤Ã¤Æ´¶¤¸¤¬¤·¤Æ°Â¿´¤Ç¤­¤Þ¤¹¡£

¤Ç¤Ï¡¢¼ÂºÝ¤Ë¥¢¥¿¥Ã¥¯¤ò»î¤ß¤Æ¤ß¤Þ¤¹¡£

¤³¤Á¤é¤Ï³°Éô¤Î¥Û¥¹¥È¤«¤é¡£

$ telnet nsx.pocketstudio.jp 143
Trying 210.128.158.225...
Connected to nsx.pocketstudio.jp.
Escape character is '^]'.
* OK [CAPABILITY IMAP4REV1 LITERAL+ SASL-IR LOGIN-REFERRALS STARTTLS  
LOGINDISABLED] nsx.pocketstudio.jp IMAP4rev1 2004.349 at Sun, 24 Jul 2005
21:16:12 +0900 (JST)
001 LOGOUT
* BYE nsx.pocketstudio.jp IMAP4rev1 server terminating connection
001 OK LOGOUT completed
Connection closed by foreign host.

¡¦¡¦¡¦¡¦¤ó¡Á¡¢¡¢ÆÃ¤ËÀ©¸Â¤¬¤«¤«¤Ã¤Æ¤Ê¤¤¤Î¤Ç¤Ï¡¦¡¦¡¦¡©

¤Õ¤Ä¤¦¤Î¥×¥í¥È¥³¥ë¤À¤«¤é¤«¤Ê¡£¥É¥­¥å¥á¥ó¥È¤Ë¤âÉáÄ̤ÎÄÌ¿®¤«¤É¤¦¤«¤Ï¼±Ê̤Ǥ­¤ë¤Ã¤Æ½ñ¤¤¤Æ¤¢¤Ã¤¿¤Î¤Ç¡¢¡¢¡¢¤Ç¤Ï°ã¤¦¥Ý¡¼¥È¤ò¤¿¤¿¤¤¤Æ¤ß¤ë¡£

$ telnet nsx.pocketstudio.jp 111
Trying 210.128.158.225...
Connected to nsx.pocketstudio.jp.
Escape character is '^]'.
Connection closed by foreign host.

¤ª¤Ã¡¢½³¤é¤ì¤¿¡£¥í¥°¤òÆÉ¤ó¤Ç¤ß¤ë¤È¡Ä¡Ä¤Ð¤Ã¤Á¤êÉÔÀµ¥¢¥¯¥»¥¹¤ò¸¡½Ð¤·¤Æ¡¢¤·¤«¤â /etc/hosts.deny ¤Ø¤ÎÄÉ²Ã¤È iptables ¤Ç¥Ñ¥±¥Ã¥È¤ò DROP ¤·¤¿¤È¤¤¤¦µ­Ï¿¡£

Jul 24 21:20:27 nsx portsentry[25316]: attackalert: Connect from host:
 sv.pocketstudio.jp/210.239.46.254 to TCP port: 111
Jul 24 21:20:27 nsx portsentry[25316]: attackalert: Host 210.239.46.254
 has been blocked via wrappers with string: "ALL: 210.239.46.254"
Jul 24 21:20:27 nsx portsentry[25316]: attackalert: Host 210.239.46.254
 has been blocked via dropped route using command: "/sbin/iptables -I 
INPUT -s 210.239.46.254 -j DROP"

¡¡/etc/hosts.deny ¥Õ¥¡¥¤¥ë¤ò³«¤¤¤Æ¤ß¤ë¤È¡¢ËöÈø¤Ë¤Á¤ã¤ó¤È¹¶·â¸µ(210.239.46.254) ¤Î¾ðÊó¤¬Äɲäµ¤ì¤Æ¤Þ¤·¤¿¡£

ALL: 210.239.46.254

¡¡iptables ¤Ç¤â -L ¥ª¥×¥·¥ç¥ó¤ò¤Ä¤±¤Æ¤ß¤ë¤È¡¢¥Ñ¥±¥Ã¥È¤ò DROP (ÇÑ´þ)¤¹¤ëÀßÄ꤬ȿ±Ç¤µ¤ì¤Æ¤Þ¤·¤¿¡£¥Ð¥Ã¥Á¥ê¡£

# /sbin/iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
DROP       all  --  sv.pocketstudio.jp   anywhere
(ά)

¡¡¤³¤ì¤Ç³°Éô¤«¤é¤Î¥Ý¡¼¥È¥¹¥­¥ã¥ó¤¬¤¢¤Ã¤Æ¤â¼«Æ°Åª¤Ë¼×ÃǤ·¤Æ¤¯¤ì¤ë»ö¤¬³Îǧ¤Ç¤­¤Þ¤·¤¿¡£¤â¤·¤É¤³¤«¤«¤éÁÀ¤ï¤ì¤ë¤³¤È¤¬¤¢¤Ã¤Æ¤â¡¢¤³¤ì¤Ê¤é°Â¿´¤Ç¤¹¤Í¡£Åµ·¿Åª¤Ç¤¹¤±¤É¡¢¤Þ¤º¿¯Æþ¤ò»î¤ß¤ë¤È¤­¤Ï¥Ý¡¼¥È¥¹¥­¥ã¥ó¤Ç¤¢¤¤¤Æ¤ë¥Ý¡¼¥È¤òÄ´¤Ù¤ë½ê¤«¤é»Ï¤á¤Þ¤¹¤«¤é¡¢ÂçÄñ¤ÎÉÔÀµ¥¢¥¯¥»¥¹¤Ë¤Ä¤¤¤Æ¤Ï PortSentry ¤Ç¼«Æ°ÇÓ½ü¤·¤Æ¤¯¤ì¤ë¤Ç¤·¤ç¤¦¡£

¡¡Â¾¤Ë¤â¤¤¤í¤¤¤í¤Êµ¡Ç½¤¬¤¢¤ë¤Î¤Ç¡¢¾Ü¤·¤¯¤Ï README ¤ò¤´Í÷¤Ë¤Ê¤Ã¤Æ¤¯¤À¤µ¤¤¡£

PortSentry README †

¡¡PortSentry README ÆüËܸìÌõ


¥È¥Ã¥×   ÊÔ½¸ Åà·ë²ò½ü º¹Ê¬ ¥Ð¥Ã¥¯¥¢¥Ã¥× źÉÕ Ê£À½ ̾Á°Êѹ¹ ¥ê¥í¡¼¥É   ¿·µ¬ °ìÍ÷ ñ¸ì¸¡º÷ ºÇ½ª¹¹¿·   ¥Ø¥ë¥×   ºÇ½ª¹¹¿·¤ÎRSS
Last-modified: Mon, 24 May 2010 20:32:21 JST (5984d)