1. tcp_wrapper란 무엇인가?
tcp_wrapper는 systat, finger, ftp, telnet, rloginrsh, exec,
tftp,talk등을 모니터링하고 filtering을 할 수 있는 프로그램이다.
[user] --> [telnet client] --> [inetd] --> [telnet server] --> [login]
tcp_wrapper적용후
[user]-->[telnet server]-->[tcp Wrapper]-->[login]
tcp_wrapper는 외부에서 들어오는 호스트를 방어하는의미를 가지고 있
는 것으로 IP address를 체크하여 관리자가 접속을 허용한 호스트들만을
접속하기 때문에 외부로의 크래킹 으로부터 방어를 할 수 있다.
2. TCP_Wrapper 백도어 버전 체크.
누군가 tcp_wrapper의 백도어 버전을 올려 놓았다구 하는군요.
421번 포트를 통하여 특정권한을 얻을 수 있도록 변형된 버전입니다.
backdoor version:
# ls -l tcp_wrappers_7.6.tar.gz
-r--r--r-- 1 root 99186 jan 21 07:16 tcp_wrappers_7.6.tar.gz
Restored version:
# ls -l tcp_wrappers_7.6.tar.gz
-r--r--r-- 1 root 99438 Jan 21 16:29 tcp_wrapper_7.6.tar.gz
-r--r--r-- 1 root 360448 Jan 21 16:29 tcp_wrapper_7.6.tar
99438이 정확한 파일 사이즈입니다.
만약 99186이라면 의심을 한번 해보시기 바랍니다.
3. TCP_Wrapper 설치 방법
RedHat linux라면 tcp_wrapper가 기본적으로 설치되어있다.
tcp_wrapper를 ftp.initdata.co.kr/pub/solaris/security/tcp_wrapper/src
에서 받는다.
# gzip -d tcp_wrapper_7.6.tar.gz
# tar xvf tcp_wrapper_7.6.tar
or
# zcat tcp_wrapper_7.6.tar.Z | tar xvf -
# cd tcp_wrapper_7.6
# uname -a로 자신의 시스템 명을 알아낸다.
# make REAL_DAEMON_DIR=/usr/sbin sunos5 (Solaris 2.x)
만약 gcc를 사용할 경우
# make REAL_DAEMON_DIR=/usr/sbin CC=gcc sunos5
컴파일이 정상적으로 끝나면 tcpdchk, safe_finger, try-from,
tcpdmatch, tcpd등 5개의 실행화일이 생성된다.
tcpd를 REAL_DAEMON_DIR로 복사한다.
# cp tcpd /usr/sbin
# cp tcpdmatch tcpdchk safe_finger try-from /usr/local/bin
/etc/inetd.conf화일의 수정 외부연결로부터 보호할 서비스를 골라
tcpd가 보호하도록 수정한다.
ftp stream tcp nowait root /usr/sbin/in.ftpd in.ftpd
telnet stream tcp nowait root /usr/sbin/in.telnetdin.telnetd
수정후
ftp stream tcp nowait root /usr/sbin/tcpd in.ftpd
telnet stream tcp nowait root /usr/sbin/tcpd in.telnetd
/etc/hosts.deny화일을 만들고 그 내용을 ALL:ALL함으로서 모든
호스트의 접근을 통제한다.
예외의 사용은 /etc/hosts.allow에 적어 넣습니다.
tcp_wrapper는 처음에 hosts.deny를 참조하여 접근정책을 수립하고
hosts.allow를 참조하여조정한다.
그래서 hosts.deny에서 all을 hosts.allow에서 허가를해주면
예외사항으로 처리되지요.
/etc/hosts.allow
all:127.0.0.1 ->이것은 자기자신을 나타낸다.
all:210.219.210. ->이것은 210.219.210.1 - 254까지 가능
all:210.219.210.221 -> 이것은 210.219.210.221 사용자만 가능
in.telnetd:210.219.210. ->이것은 210.219.210.1 - 254은 telnet을 사용
in.ftpd:ALL EXCEPT 210.219.210. 147.46.10.10
-> 이것은 210.219.210번대와 147.46.10.10번 사용자를 제외
허고 모든 호스트에게 ftp를 허용
불법침입에 대해서 특정 id로 mail을 보내도록 하기위해서는
다음과 같이 /etc/hosts.deny file을 수정한다.
/etc/hosts.deny
ALL:ALL:(/usr/local/bin/safe_finger -l @%h | \
/usr/bin/mail -s %d-%h root)&
or
/etc/hosts.deny
ALL: ALL : ((/usr/local/bin/safe_finger -l @%h;echo "----- \
USERS LIST-------";/usr/bin/rusers -l -i %h) | \
/usr/bin/mailx -s "불법침입" root)
tcpdchk를 실행하여 환경설정에 문제가 있는지 체크한다.
tcpdmatch로 환경화일 체크
예) # tcpdmatch in.ftpd mit.edu
# tcpdmatch in.telnetd mit.edu
inetd의 재가동
# ps -ef | grep inetd
388 ?? | 0:08.56 /usr/sbin/inetd
# kill -HUP 388
4. 참조
http://baikdou.kaist.ac.kr/tips/tcpwrapper/TCP_Wrapper.htm
http://admin.snu.ac.kr/Docs/program/tcp_wrapper.php3
http://www.bigcom.co.kr/tech/admin/tcpwrapper.htm
tcp_wrapper는 systat, finger, ftp, telnet, rloginrsh, exec,
tftp,talk등을 모니터링하고 filtering을 할 수 있는 프로그램이다.
[user] --> [telnet client] --> [inetd] --> [telnet server] --> [login]
tcp_wrapper적용후
[user]-->[telnet server]-->[tcp Wrapper]-->[login]
tcp_wrapper는 외부에서 들어오는 호스트를 방어하는의미를 가지고 있
는 것으로 IP address를 체크하여 관리자가 접속을 허용한 호스트들만을
접속하기 때문에 외부로의 크래킹 으로부터 방어를 할 수 있다.
2. TCP_Wrapper 백도어 버전 체크.
누군가 tcp_wrapper의 백도어 버전을 올려 놓았다구 하는군요.
421번 포트를 통하여 특정권한을 얻을 수 있도록 변형된 버전입니다.
backdoor version:
# ls -l tcp_wrappers_7.6.tar.gz
-r--r--r-- 1 root 99186 jan 21 07:16 tcp_wrappers_7.6.tar.gz
Restored version:
# ls -l tcp_wrappers_7.6.tar.gz
-r--r--r-- 1 root 99438 Jan 21 16:29 tcp_wrapper_7.6.tar.gz
-r--r--r-- 1 root 360448 Jan 21 16:29 tcp_wrapper_7.6.tar
99438이 정확한 파일 사이즈입니다.
만약 99186이라면 의심을 한번 해보시기 바랍니다.
3. TCP_Wrapper 설치 방법
RedHat linux라면 tcp_wrapper가 기본적으로 설치되어있다.
tcp_wrapper를 ftp.initdata.co.kr/pub/solaris/security/tcp_wrapper/src
에서 받는다.
# gzip -d tcp_wrapper_7.6.tar.gz
# tar xvf tcp_wrapper_7.6.tar
or
# zcat tcp_wrapper_7.6.tar.Z | tar xvf -
# cd tcp_wrapper_7.6
# uname -a로 자신의 시스템 명을 알아낸다.
# make REAL_DAEMON_DIR=/usr/sbin sunos5 (Solaris 2.x)
만약 gcc를 사용할 경우
# make REAL_DAEMON_DIR=/usr/sbin CC=gcc sunos5
컴파일이 정상적으로 끝나면 tcpdchk, safe_finger, try-from,
tcpdmatch, tcpd등 5개의 실행화일이 생성된다.
tcpd를 REAL_DAEMON_DIR로 복사한다.
# cp tcpd /usr/sbin
# cp tcpdmatch tcpdchk safe_finger try-from /usr/local/bin
/etc/inetd.conf화일의 수정 외부연결로부터 보호할 서비스를 골라
tcpd가 보호하도록 수정한다.
ftp stream tcp nowait root /usr/sbin/in.ftpd in.ftpd
telnet stream tcp nowait root /usr/sbin/in.telnetdin.telnetd
수정후
ftp stream tcp nowait root /usr/sbin/tcpd in.ftpd
telnet stream tcp nowait root /usr/sbin/tcpd in.telnetd
/etc/hosts.deny화일을 만들고 그 내용을 ALL:ALL함으로서 모든
호스트의 접근을 통제한다.
예외의 사용은 /etc/hosts.allow에 적어 넣습니다.
tcp_wrapper는 처음에 hosts.deny를 참조하여 접근정책을 수립하고
hosts.allow를 참조하여조정한다.
그래서 hosts.deny에서 all을 hosts.allow에서 허가를해주면
예외사항으로 처리되지요.
/etc/hosts.allow
all:127.0.0.1 ->이것은 자기자신을 나타낸다.
all:210.219.210. ->이것은 210.219.210.1 - 254까지 가능
all:210.219.210.221 -> 이것은 210.219.210.221 사용자만 가능
in.telnetd:210.219.210. ->이것은 210.219.210.1 - 254은 telnet을 사용
in.ftpd:ALL EXCEPT 210.219.210. 147.46.10.10
-> 이것은 210.219.210번대와 147.46.10.10번 사용자를 제외
허고 모든 호스트에게 ftp를 허용
불법침입에 대해서 특정 id로 mail을 보내도록 하기위해서는
다음과 같이 /etc/hosts.deny file을 수정한다.
/etc/hosts.deny
ALL:ALL:(/usr/local/bin/safe_finger -l @%h | \
/usr/bin/mail -s %d-%h root)&
or
/etc/hosts.deny
ALL: ALL : ((/usr/local/bin/safe_finger -l @%h;echo "----- \
USERS LIST-------";/usr/bin/rusers -l -i %h) | \
/usr/bin/mailx -s "불법침입" root)
tcpdchk를 실행하여 환경설정에 문제가 있는지 체크한다.
tcpdmatch로 환경화일 체크
예) # tcpdmatch in.ftpd mit.edu
# tcpdmatch in.telnetd mit.edu
inetd의 재가동
# ps -ef | grep inetd
388 ?? | 0:08.56 /usr/sbin/inetd
# kill -HUP 388
4. 참조
http://baikdou.kaist.ac.kr/tips/tcpwrapper/TCP_Wrapper.htm
http://admin.snu.ac.kr/Docs/program/tcp_wrapper.php3
http://www.bigcom.co.kr/tech/admin/tcpwrapper.htm