다음 이전 차례

5. tcpwraper는 시체가 아니다!

tcp_wraper... 요거 사용하는 사람 별로 없을것이라 생각됩니다. 요것이 무엇이냐! 바로 관리자가 선택적으로 접속하는 호스트를 막는 툴이다  이겁니다. 자, 필요한 파일들을 볼까요?

/etc/hosts.allow
/etc/hosts.deny

그리고 서비스로 하나 만들 것이 있죠. 파일이름은 host_check로 할께요.


#!/bin/sh
 
 ################################  변수정의부문
 
 # 메일 수신자
 mailto=reduck96
 
 # 화면출력 여부, 메일전송 여부
 dsp=$1; msg=$2
 
 # 접속자 정보 등
 a=$3; c=$4; d=$5; h=$6; n=$7; p=$8; s=$9; u=$10
 
 # 현재 시간
 time=`date`
 
 # 접속시도자 소속 서버의 finger 정보
 finger=`/usr/bin/finger -l @$h 2> /dev/null`
 
 
 ################################  화면 출력부문
 
 if [ $dsp = Y ]
    then
 
 /bin/echo "
                      ===================================\n\
                           접속이 허용되지 않습니다.     \n\
                      ===================================\n\
 \n\
               Access Time             : $time\n\
               Client host address     : $a\n\
               Client information      : $c\n\
               Client host name(or IP) : $h\n\
               Client host name        : $n\n\
               Client user name        : $u\n\n
"
 
 fi
 
 
 ################################  메일 송신부문
 
 if [ $msg = Y ]
    then
 
 /bin/echo "
                        ===============================\n\
                              접속 거부자 상세정보     \n\
                        ===============================\n\
 \n\
         Access Time                    : $time\n\
         Access client host address     : $a\n\
         Access client information      : $c\n\
         The daemon process name        : $d\n\
         Access client host name(or IP) : $h\n\
         Access client host name        : $n\n\
         The daemon process id          : $p\n\
         Server information             : $s\n\
         Access client user name        : $u\n\
 \n\
--------------------------------------------------------\n\
                       Access client finger information                    \n\
 --------------------------------------------------------\n\
 $finger\n\
 ---------------------------------------------------------\n\
 \n\n" | \
      /bin/mail -s "tcp_wrapper report [$d]" $mailto
 
 fi

이렇게 host_check 파일을 만든뒤, /etc/에 넣어둡시다. 참, 이거 잊지 마세요.

chmod a+rx /etc/host_check

요렇게 실행할 수 있게 만들어 놓아야 되요. 자아, 이제 나머지 hosts.allow와 hosts.deny를 작살내봅시다. hosts.allow의 내용입니다.


#
# hosts.allow   This file describes the names of the hosts which are
#               allowed to use the local INET services, as decided
#               by the '/usr/sbin/tcpd' server.
#
in.telnetd : \
    127.0.0.1 \
    203.249.111. \
    133.207. \
    203.249.107.174 \
    nec.co.jp \
: rfc931: ALLOW 

그리고, hosts.deny의 내용입니다.


#
# hosts.deny    This file describes the names of the hosts which are
#               *not* allowed to use the local INET services, as decided
#               by the '/usr/sbin/tcpd' server.
#
# The portmap line is redundant, but it is left to remind you that
# the new secure portmap uses hosts.deny and hosts.allow.  In particular
# you should know that NFS uses portmap!
ALL : ALL EXCEPT LOCAL :\
 twist ( /etc/host_check Y Y %a %c %d %h %n %p %s %u ) &

대충 보시면 아시겠죠? hosts.allow에는 허용할 컴의 ip내지 domain을 쓰면 됩니다. 그리고 hosts.deny는 수정할 것이 거의 없습니다. 단, 메일받는 사람의 ID는 바꾸어 주셔야 겠죠? reduck96 부분입니다. 이것이 우째 작동을 하느냐  궁금하시죠? 일단 허용되지 않는곳의 IP에서 telnet으로 접속을 시도합니다. 그러면 바로 host_check가 돌죠. 그리고 접속을 시도한 컴에게 finger를 시도해서 정보를 메일로 관리자에게 보냅니다. 물론 host_check를 특수한 프로그램으로 바꾸어 한다면 무지무지 재미있겠죠? 예를 들어 Tear_Drop이라든지, PING_DUMP같은 아주 성질 나쁜 것으로요. 요런 거 어디서 구하냐구요? 흐흐흐    이곳에 한번 가보세요. 재미있는 툴들이 많습니다.

http://www.rootshell.com

자, 세부 설정은 여러분들에게 숙제로 남기겠습니다. 잘 설정해서 사용하시기를... 참, telnet말고도 다른것도 막고싶다구요? 그럼 예제를 더 넣어드릴께요.


portmap rpc.nfsd rpc.mountd: \
    127.0.0.1 \
    203.249.111. \
: ALLOW
in.fingerd in.cfingerd : rfc931:DENY 
in.timed ipop3d: ALL@ALL: rfc931: DENY 
in.ntalkd in.talkd: ALL: rfc931: ALLOW 
in.ftpd: ALL@ALL: rfc931: ALLOW

이정도면 되겠죠? 간단하죠? 사용할 대몬프로그램의 이름을 앞에 써주고 형식은 같으니 변형해서 사용하시면 됩니다. 요렇게 해서 걸린 IP들을 조사해보면, 대부분 sscan으로 휘집어 깐다는 것을 아실 수 있을 것입니다. 조심하세요. 저에게 sscan걸리면 전 바로 Vs 모드(보복모드)로 돌변하니까요.


다음 이전 차례