정식 명칭은 Port Scan Detecton and Acrive Defense 이라고 합니다.
얼마전에 서버 작업중 이녀석 때문에 ssh 접근이 막혀서 애를 먹은적이 있었는데
로컬에서 확인해보니 해당 데몬이 작동 중이였습니다.
설치는 매우 간단합니다. google 등 검색엔진을 이용하여 해당 데몬을 다운 받습니다.
wget ftp://ftp.superuser.co.kr/security/portsentry/portsentry-1.0.tar.fz
-rw-r–r– 1 root root 43K 2016-03-28 11:17 portsentry-1.0.tar.gz
[root@ns /usr/local/src2]# tar zxvf portsentry-1.0.tar.gz
portsentry-1.0/
portsentry-1.0/CHANGES
portsentry-1.0/CREDITS
portsentry-1.0/LICENSE
portsentry-1.0/Makefile
portsentry-1.0/README.COMPAT
portsentry-1.0/README.install
portsentry-1.0/README.methods
portsentry-1.0/README.stealth
portsentry-1.0/ignore.csh
portsentry-1.0/portsentry.c
portsentry-1.0/portsentry.conf
portsentry-1.0/portsentry.h
portsentry-1.0/portsentry.ignore
portsentry-1.0/portsentry_config.h
portsentry-1.0/portsentry_io.c
portsentry-1.0/portsentry_io.h
portsentry-1.0/portsentry_tcpip.h
portsentry-1.0/portsentry_util.c
portsentry-1.0/portsentry_util.h
디렉토리 이동 후 “make linux”로 컴파일 후 “make install”을 해줍니다.
[root@ns /usr/local/src2]#cd portsentry-1.0
# make linux && make install
설치가 완료 되면/usr/local/psionic/portsentry/ 디렉토리가 생성 됩니다. ls 명령어로 확인을 하면 설정 파일들이 생성되 있음을 볼 수 있습니다.
[root@ns /usr/local/src2]# ls -lh /usr/local/psionic/portsentry/
total 64K
-rwx—— 1 root root 38K Mar 28 11:18 portsentry
-rw-r–r– 1 root root 85 Mar 28 11:22 portsentry.blocked.tcp
-rw-r–r– 1 root root 0 Mar 28 11:22 portsentry.blocked.udp
-rw——- 1 root root 11K Mar 28 11:18 portsentry.conf
-rw——- 1 root root 85 Mar 28 11:22 portsentry.history
-rw——- 1 root root 236 Mar 28 11:18 portsentry.ignore
설치가 끝나면 portsentry.conf 파일을 vi 편집기로 열고 스캔 차단할 port 내용들을 등록 해줍니다.
저는 기본 conf 파일에 있는 기본값 그대로 사용 하였습니다.
# vi /usr/local/psionic/portsentry/portsentry.conf
TCP_PORTS=”1,11,15,79,111,119,143,540,635,1080,1524,2000,5742,6667,12345,12346,20034,31337,32771,32772,32773,32774,40421,49724,54320″
UDP_PORTS=”1,7,9,69,161,162,513,635,640,641,700,32770,32771,32772,32773,32774,31337,54321″
conf 파일 내용이 복잡하지 않기 때문에 쉽게 응용이 가능 하므로 직접 테스트 해보시면 좋을 것 같습니다.
아래 명령어를 이용하여 데몬을 실행 시키도록 하겠습니다.
[root@ns ]# /usr/local/psionic/portsentry/portsentry -tcp
[root@ns ]# /usr/local/psionic/portsentry/portsentry -udp
*tcp,udp 말고도 [stcp,atcp,sudp] 등 프로토콜들도 실행 가능 합니다.
[root@]# ps -ef | grep portsentry
root 27437 1 0 11:22 ? 00:00:00 /usr/local/psionic/portsentry/portsentry -tcp
root 27440 1 0 11:22 ? 00:00:00 /usr/local/psionic/portsentry/portsentry -udp
*리부팅 시에도 데몬 실행을 원하면 /etc/rc.local 파일에 해당 명령어를 등록 해주면 됩니다.
현재 데몬일 실행중임을 확인 하고 데몬이 설치된 서버에 nmap을 이용하여 포트 스캔을 시도 하였습니다.
#nmap -sT 115.68.xxx.xxx
시도 후 ssh 접근을 시도하면
ssh_exchange_identification: read: Connection reset by peer 라는 문구와 함께 ssh 접근이 막혀 버립니다.
서버에서 hosts.deny 파일을 확인 하면 nmap 포트스캔을 시도한 ip가 자동으로 등록되어 있는것을 볼 수 있습니다.
[root@ns /usr/local/src2]# cat /etc/hosts.deny
#
# hosts.deny This file contains access rules which are used to
ALL: 115.68.xxx.xxx
'Linux' 카테고리의 다른 글
[CentOS] 해킹점검 - perl (0) | 2016.05.12 |
---|---|
[CentOS] 해킹점검 내용 - eval (0) | 2016.05.12 |
[CentOs 6.x] ssh_exchange_identification: read: Connection reset by peer 에러 (1) | 2016.03.04 |
[CentOS 6.x]NFS 설정 및 관련 포트 고정 설정 (0) | 2016.02.23 |
[CentOS 6.x] [lshw 명령어를 이용하여 하드웨어 스펙 확인] (0) | 2016.02.19 |