Skip to content

조회 수 16164 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부
portsentry

-------------------------------------------------------------------

portsentry-1.2-1.te.src.rpm : (portsentry-1.2-1.te.src.rpm )


portsentry-1.2-1.te.centos5.2.i386.rpm

-------------------------------------------------------------------



1. 다운 및 RPM 파일 생성 - 소스 rpm을 이용해 설치를 한다.

 
[root@server3 ~]# cd Desktop
[root@server3 Desktop]# ls
portsentry-1.2-1.te.src.rpm

[root@server3 Desktop]# rpm -Uvh portsentry-1.2-1.te.src.rpm - rpm으로 소스rpm을 설치한다.
경고: portsentry-1.2-1.te.src.rpm: Header V3 DSA signature: NOKEY, key ID df3d5207
   1:portsentry             경고: tengel 사용자가 존재하지 않습니다 - root를 이용합니다
경고: tengel 사용자가 존재하지 않습니다 - root를 이용합니다
경고: tengel 사용자가 존재하지 않습니다 - root를 이용합니다
경고: tengel 사용자가 존재하지 않습니다 - root를 이용합니다
경고: tengel 사용자가 존재하지 않습니다 - root를 이용합니다
경고: tengel 사용자가 존재하지 않습니다 - root를 이용합니다
########################################### [100%]


rpm 파일 생성

[root@server3 SPECS]# pwd
/usr/src/redhat/SPECS - 소스 rpm을 실행하면 /usr/src/redhat/SPECS 폴더에 xxx.spec 파일이 만들어 진다.
[root@server3 SPECS]# ls
portsentry.spec
[root@server3 SPECS]# rpmbuild -bb portsentry.spec - rpmbuild 명령어를 이용해 rpm 파일을 생성한다.
실행 중(%prep): /bin/sh -e /var/tmp/rpm-tmp.13137
+ umask 022
+ cd /usr/src/redhat/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ cd /usr/src/redhat/BUILD
+ rm -rf portsentry_beta
+ /bin/gzip -dc /usr/src/redhat/SOURCES/portsentry-1.2.tar.gz
+ tar -xvvf -
drwxr-xr-x crowland/users    0 2003-05-24 03:10:13 portsentry_beta/
-rw-r--r-- crowland/users 54342 2003-05-24 03:10:13 portsentry_beta/portsentry.c
-rw------- crowland/users  2876 2003-05-24 03:10:13 portsentry_beta/portsentry.h
-rw------- crowland/users 21027 2003-05-24 03:10:13 portsentry_beta/portsentry_io.c
-rw------- crowland/users  1933 2003-05-24 03:10:13 portsentry_beta/portsentry_io.h
-rw-r--r-- crowland/users  4618 2003-05-24 03:10:13 portsentry_beta/portsentry_util.c
-rw-r--r-- crowland/users  1360 2003-05-24 03:10:13 portsentry_beta/portsentry_util.h
-rw------- crowland/users  1746 2003-05-24 03:10:13 portsentry_beta/portsentry_config.h
-rw------- crowland/users  4688 2003-05-24 03:10:13 portsentry_beta/portsentry_tcpip.h
-rw------- crowland/users   480 2003-05-24 03:10:13 portsentry_beta/portsentry.ignore
-rw------- crowland/users 11198 2003-05-24 03:10:13 portsentry_beta/portsentry.conf
-rw------- crowland/users  6137 2003-05-24 03:10:13 portsentry_beta/Makefile
-rw------- crowland/users   372 2003-05-24 03:10:13 portsentry_beta/README.COMPAT
-rw------- crowland/users 20942 2003-05-24 03:10:13 portsentry_beta/README.install
-rw------- crowland/users  5364 2003-05-24 03:10:13 portsentry_beta/README.methods
-rw------- crowland/users  7310 2003-05-24 03:10:13 portsentry_beta/README.stealth
-rw------- crowland/users  8908 2003-05-24 03:10:13 portsentry_beta/CHANGES
-rw------- crowland/users  7044 2003-05-24 03:10:13 portsentry_beta/CREDITS
-rw------- crowland/users 15370 2003-05-24 03:10:13 portsentry_beta/LICENSE
-rwxr-xr-x crowland/users  2715 2003-05-24 03:10:13 portsentry_beta/ignore.csh
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd portsentry_beta
++ /usr/bin/id -u
+ '[' 0 = 0 ']'
+ /bin/chown -Rhf root .
++ /usr/bin/id -u
+ '[' 0 = 0 ']'
+ /bin/chgrp -Rhf root .
+ /bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ echo 'Patch #0 (portsentry-1.2.patch):'
Patch #0 (portsentry-1.2.patch):
+ patch -p1 -b --suffix .te -s
+ exit 0
실행 중(%build): /bin/sh -e /var/tmp/rpm-tmp.13137
+ umask 022
+ cd /usr/src/redhat/BUILD
+ cd portsentry_beta
+ LANG=C
+ export LANG
+ unset DISPLAY
+ /usr/bin/make -j2 linux
SYSTYPE=linux
Making
gcc  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -DLINUX -DSUPPORT_STEALTH -o ./portsentry ./portsentry.c \
                ./portsentry_io.c ./portsentry_util.c
./portsentry.c: In function 'PortSentryModeTCP':
./portsentry.c:1187: warning: pointer targets in passing argument 3 of 'accept' differ in signedness
./portsentry.c:1216: warning: ignoring return value of 'write', declared with attribute warn_unused_result
./portsentry.c: In function 'PortSentryModeUDP':
./portsentry.c:1384: warning: pointer targets in passing argument 6 of 'recvfrom' differ in signedness
./portsentry_io.c: In function 'DaemonSeed':
./portsentry_io.c:84: warning: ignoring return value of 'chdir', declared with attribute warn_unused_result
+ exit 0
실행 중(%install): /bin/sh -e /var/tmp/rpm-tmp.32132
+ umask 022
+ cd /usr/src/redhat/BUILD
+ cd portsentry_beta
+ LANG=C
+ export LANG
+ unset DISPLAY
+ /bin/rm -rf /var/tmp/portsentry-1.2-1.te-root
+ mkdir -p /var/tmp/portsentry-1.2-1.te-root/var/portsentry
+ /usr/bin/make install
Creating psionic directory /var/tmp/portsentry-1.2-1.te-root/usr/sbin
Setting directory permissions
Creating portsentry directory /var/tmp/portsentry-1.2-1.te-root/etc/portsentry
Creating portsentry directory /var/tmp/portsentry-1.2-1.te-root/usr/sbin
Setting directory permissions
chmod 700 /var/tmp/portsentry-1.2-1.te-root/etc/portsentry
Copying files
cp ./portsentry.conf /var/tmp/portsentry-1.2-1.te-root/etc/portsentry
cp ./portsentry.ignore /var/tmp/portsentry-1.2-1.te-root/etc/portsentry
cp ./portsentry /var/tmp/portsentry-1.2-1.te-root/usr/sbin
Setting permissions
chmod 600 /var/tmp/portsentry-1.2-1.te-root/etc/portsentry/portsentry.ignore
chmod 600 /var/tmp/portsentry-1.2-1.te-root/etc/portsentry/portsentry.conf
chmod 700 /var/tmp/portsentry-1.2-1.te-root/usr/sbin/portsentry


Edit /var/tmp/portsentry-1.2-1.te-root/etc/portsentry/portsentry.conf and change
your settings if you haven't already. (route, etc)


WARNING: This version and above now use a new
directory structure for storing the program
and config files (/var/tmp/portsentry-1.2-1.te-root/etc/portsentry).
Please make sure you delete the old files when
the testing of this install is complete.


+ /usr/bin/install -Dp -m 700 /usr/src/redhat/SOURCES/portsentry.init /var/tmp/portsentry-1.2-1.te-root/etc/init.d/portsentry
+ /usr/bin/install -Dp -m 600 /usr/src/redhat/SOURCES/portsentry.modes /var/tmp/portsentry-1.2-1.te-root/etc/portsentry/portsentry.modes
+ /usr/bin/install -Dp -m 600 /usr/src/redhat/SOURCES/portsentry.cron /var/tmp/portsentry-1.2-1.te-root/etc/cron.d/portsentry
+ /usr/lib/rpm/find-debuginfo.sh /usr/src/redhat/BUILD/portsentry_beta
extracting debug info from /var/tmp/portsentry-1.2-1.te-root/usr/sbin/portsentry
166 blocks
+ /usr/lib/rpm/redhat/brp-compress
+ /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
+ /usr/lib/rpm/redhat/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
+ /usr/lib/rpm/brp-python-bytecompile
+ /usr/lib/rpm/redhat/brp-java-repack-jars
파일 처리 중: portsentry-1.2-1.te
실행 중(%doc): /bin/sh -e /var/tmp/rpm-tmp.92492
+ umask 022
+ cd /usr/src/redhat/BUILD
+ cd portsentry_beta
+ DOCDIR=/var/tmp/portsentry-1.2-1.te-root/usr/share/doc/portsentry-1.2
+ export DOCDIR
+ rm -rf /var/tmp/portsentry-1.2-1.te-root/usr/share/doc/portsentry-1.2
+ /bin/mkdir -p /var/tmp/portsentry-1.2-1.te-root/usr/share/doc/portsentry-1.2
+ cp -pr CHANGES CREDITS LICENSE README.COMPAT README.install README.methods README.stealth /var/tmp/portsentry-1.2-1.te-root/usr/share/doc/portsentry-1.2
+ exit 0
Provides: config(portsentry) = 1.2-1.te
Requires(interp): /bin/sh /bin/sh /bin/sh
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Requires(post): /bin/sh
Requires(preun): /bin/sh
Requires(postun): /bin/sh
Requires: /bin/bash config(portsentry) = 1.2-1.te libc.so.6 libc.so.6(GLIBC_2.0) libc.so.6(GLIBC_2.1) libc.so.6(GLIBC_2.3) libc.so.6(GLIBC_2.3.4) libc.so.6(GLIBC_2.4) rtld(GNU_HASH)
Obsoletes: sentry
파일 처리 중: portsentry-debuginfo-1.2-1.te
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Checking for unpackaged file(s): /usr/lib/rpm/check-files /var/tmp/portsentry-1.2-1.te-root
작성: /usr/src/redhat/RPMS/i386/portsentry-1.2-1.te.i386.rpm
작성: /usr/src/redhat/RPMS/i386/portsentry-debuginfo-1.2-1.te.i386.rpm
실행 중(%clean): /bin/sh -e /var/tmp/rpm-tmp.92492
+ umask 022
+ cd /usr/src/redhat/BUILD
+ cd portsentry_beta
+ /bin/rm -rf /var/tmp/portsentry-1.2-1.te-root
+ exit 0
[root@server3 SPECS]#




2. 설치

 
[root@server3 i386]# pwd
/usr/src/redhat/RPMS/i386 - rpmbuild 명령어를 이용해 생성된 rpm 파일은 /usr/src/redhat/RPMS/i386에 생성된다.
[root@server3 i386]# ls
portsentry-1.2-1.te.i386.rpm  portsentry-debuginfo-1.2-1.te.i386.rpm

[root@server3 i386]# rpm -Uvh portsentry-1.2-1.te.i386.rpm - portsentry를 설치한다.
준비 중...               ########################################### [100%]
   1:portsentry             ########################################### [100%]
[root@server3 i386]#




3. 환경설정

 
[root@server3 ~]# vi /etc/portsentry/portsentry.conf
# PortSentry Configuration

#######################
# Port Configurations #   
#######################

- TCPwrapper 가 감시하는 포트들로 TCP, UDP ports 가 3 part로 설정되어 있다.
- 점검할 포트를 추가하거나, 점검하지 않을 포트들을 빼거나 할 수 있다.


# Un-comment these if you are really anal: - 상세하게 체크를 하려면 주석 제거후 사용한다.
#TCP_PORTS="1,7,9,11,15,70,79,80,109,110,111,119,138,139,143,512,513,514,515,540,635,1080,1524,2000,2001,4000,4001,5742,6000,6001,6667,12345,12346,20034
,27665,30303,32771,32772,32773,32774,31337,40421,40425,49724,54320"

#UDP_PORTS="1,7,9,66,67,68,69,111,137,138,161,162,474,513,517,518,635,640,641,666,700,2049,31335,27444,34555,32770,32771,32772,32773,32774,31337,54321"

# Use these if you just want to be aware: - 디폴트로서 단지 어떤 일이 발생했는지만 파악하려면 사용한다.
TCP_PORTS="1,11,15,79,111,119,143,540,635,1080,1524,2000,5742,6667,12345,12346,20034,27665,31337,32771,32772,32773,32774,40421,49724,54320"
UDP_PORTS="1,7,9,69,161,162,513,635,640,641,700,37444,34555,31335,32770,32771,32772,32773,32774,31337,54321"

# Use these for just bare-bones - 불피요한 것들을 제외하고 꼭 필요한 부분만 사용하려면 이 설정을 사용한다.
#TCP_PORTS="1,11,15,110,111,143,540,635,1080,1524,2000,12345,12346,20034,32771,32772,32773,32774,49724,54320"
#UDP_PORTS="1,7,9,69,161,162,513,640,700,32770,32771,32772,32773,32774,31337,54321"

###########################################
# Advanced Stealth Scan Detection Options #
###########################################

- Advanced  모드로 모니터링 할 포트를 보여준다. 이곳에 설정된 포트 이하의 모든 포트들은 즉시 감시한다.
- 1024 포트 이상의 포트에 대해서는 잘못된 경고가 빈번하게 발생하므로 설정하지 않는 것이 좋다.

ADVANCED_PORTS_TCP="1024" - 1024 포트 이하는 스텔스 모드로 스캐닝하며 특정 포트를 지정하여 반응하지 않도록 할 수 있다.
ADVANCED_PORTS_UDP="1024"

# Default TCP ident and NetBIOS service  -- 스캐닝에서 제외하는 포트
ADVANCED_EXCLUDE_TCP="21,22,25,53,80,110,113,135,137,138,139,443"

# Default UDP route (RIP), NetBIOS, bootp broadcasts.
ADVANCED_EXCLUDE_UDP="520,517,518,513,138,137,123,68,67,53"

######################
# Configuration Files#
######################

# Hosts to ignore
- 무시할 호스트들을  저장한다.
- 해당하는 포트에 접속 요구가 들어올 때, 감지를 무시할 호스트들의 목록으로 localhost(127.0.0.1)와 0.0.0.0 IP 는 설정해야 한다.
IGNORE_FILE="/etc/portsentry/portsentry.ignore"

# Hosts that have been denied (running history) - 접근 거부된 적이 있는 호스트들을 저장한다.
HISTORY_FILE="/etc/portsentry/portsentry.history"

# Hosts that have been denied this session only (temporary until next restart) - 이번 연결에서만 거부된(재시작 될때까지 임시로 거부하는 ) 호스트들을 저장한다.
BLOCKED_FILE="/etc/portsentry/portsentry.blocked"

##############################
# Misc. Configuration Options#
##############################

RESOLVE_HOST = "1"

###################
# Response Options#
###################

- 공격자에 대한 처리 옵션이다. 각각의 옵션은 공격이 감지 되었을 때, 실행할 내용에 대한 설정이다.
- $TARGET$ 변수는 공격이 감지되었을 때 공격자의 주소가 대입된다.
- $PORT$ 는 스캔된 포트 값이 입력된다.

##################
# Ignore Options #
##################

# 0 = Do not block UDP/TCP scans. - UDP/TCP 스캔을 차단하지 않는다.
# 1 = Block UDP/TCP scans. - UDP/TCP 스캔을 차단한다.
# 2 = Run external command only (KILL_RUN_CMD) - 오직 외부 명령어만을 실행한다. (KILL_RUN_CMD)

BLOCK_UDP="1"
BLOCK_TCP="1"

###################
# Dropping Routes:#
###################

- 라우트를 누락시키거나 호스트를 내부의 필터링 테이블에 추가할 경우 사용한다. 패킷 필터를 쓰는 것이 좋다.

# Generic
#KILL_ROUTE="/sbin/route add $TARGET$ 333.444.555.666"

# Generic Linux
#KILL_ROUTE="/sbin/route add -host $TARGET$ gw 333.444.555.666"

# Newer versions of Linux support the reject flag now. This
# is cleaner than the above option.
#KILL_ROUTE="/sbin/route add -host $TARGET$ reject"

# Generic BSD (BSDI, OpenBSD, NetBSD, FreeBSD)
#KILL_ROUTE="/sbin/route add $TARGET$ 333.444.555.666"

# Generic Sun
#KILL_ROUTE="/usr/sbin/route add $TARGET$ 333.444.555.666 1"

# NEXTSTEP
#KILL_ROUTE="/usr/etc/route add $TARGET$ 127.0.0.1 1"

# FreeBSD
#KILL_ROUTE="route add -net $TARGET$ -netmask 255.255.255.255 127.0.0.1 -blackhole"

# Digital UNIX 4.0D (OSF/1 / Compaq Tru64 UNIX)
#KILL_ROUTE="/sbin/route add -host -blackhole $TARGET$ 127.0.0.1"

# Generic HP-UX
#KILL_ROUTE="/usr/sbin/route add net $TARGET$ netmask 255.255.255.0 127.0.0.1"

# ipfwadm support for Linux
#KILL_ROUTE="/sbin/ipfwadm -I -i deny -S $TARGET$ -o"

# ipfwadm support for Linux (no logging of denied packets)
#KILL_ROUTE="/sbin/ipfwadm -I -i deny -S $TARGET$"

# ipchain support for Linux
#KILL_ROUTE="/sbin/ipchains -I input -s $TARGET$ -j DENY -l"

# ipchain support for Linux (no logging of denied packets)
#KILL_ROUTE="/sbin/ipchains -I input -s $TARGET$ -j DENY"

# iptables support for Linux
KILL_ROUTE="/sbin/iptables -I INPUT -s $TARGET$ -j DROP" - 접근을 거부할 호스트들을 자동으로 iptables 에 추가한다.

#KILL_ROUTE="/sbin/ipfw add 1 deny all from $TARGET$:255.255.255.255 to any"

#KILL_ROUTE="/bin/echo 'block in log on external_interface from $TARGET$/32 to any' | /sbin/ipf -f -"

###############
# TCP Wrappers#
###############

- 이 설정을 사용하면 /etc/hosts.deny 에 접근 거부할 호스트들을 자동으로 추가시킨다.

- 확장된 host 순서 옵션이 불가능 할 경우 사용 (default)
#KILL_HOSTS_DENY="ALL: $TARGET$"

- 확장된 host 순서 옵션이 가능할 경우 사용
#KILL_HOSTS_DENY="ALL: $TARGET$ : DENY"

###################
# External Command#
###################

- 호스트 연결이 이루어질 때 실행되는 명영이다.

#KILL_RUN_CMD_FIRST = "0"

#KILL_RUN_CMD="/some/path/here/script $TARGET$ $PORT$"

#KILL_RUN_CMD="/bin/mail -s 'Portscan from $TARGET$ on port $PORT$' user@host < /dev/null"

#####################
# Scan trigger value#
#####################

- 경고를 하기 전에 허용할 포트 연결 수를 입력한다. 초기값인 0은 바로 반응하는 것이며, 1 or 2로 설정하면 가끔 나타날 수 있는 거짓 경고를 줄여준다.

SCAN_TRIGGER="1"

######################
# Port Banner Section#
######################

- portsentry 에 의해 차단되는 접속자에게 보여줄 문장이다. 스탤스 스캔 감지 모드는 이 기능을 사용하지 않는다.

#PORT_BANNER="** UNAUTHORIZED ACCESS PROHIBITED *** YOUR CONNECTION ATTEMPT HAS BEEN LOGGED. GO AWAY."





4. 서비스 시작 및 확인

 
[root@server3 ~]# service portsentry start
portsentry (을)를 시작 중: (atcp)                          [  OK  ]
portsentry (을)를 시작 중: (audp)                          [  OK  ]

[root@server3 ~]# vi /etc/portsentry/portsentry.blocked.atcp - 이번 연결에서만 거부된(재시작 될때까지 임시로 거부하는 ) 호스트들을 확인 할 수 있다.
[root@server3 ~]# vi /etc/portsentry/portsentry.history - 접근 거부된 적이 있는 호스트들을 확인할 수 있다.
[root@server3 ~]# iptables -nL - iptables 에 거부할 호스트들을 추가하는 옵션을 설정해 놓으면 iptables를 통해 확인할 수 있다.



- 참고
/etc/portsentry/portsentry.modes : portsentry 모드 파일
portsentry 프로그램은 여섯개의 다른 모드로 동작한다. 하지만 한번에 하나의 프로토콜만 동작시킬 수 있다.
파일 안에 여섯가지의 가능한 모드를 추가한 다음 사용할 두가지 모드에 대해서만 주석을 제거하여 사용한다.
예)
#tcp - 기본적인 port-bound TCP 모드
#udp - 기본적인 port-bound UDP 모드
#stcp - 스텔스 TCP 스캔 감지 모드
sudp - 스텔스 UDP 스캔 감지 모드
atcp - advanced 스텔스 TCP 스캔 감지 모드
#audp - advanced 스텔스 UDP 스캔 감지 모드

List of Articles
번호 제목 글쓴이 날짜 조회 수
88 /etc/passwd 구조 l2zeo 2010.03.31 34917
87 리눅스용 각종 보안도구 사이트모음 ADMINPLAY 2009.07.12 33626
86 매직키를 이용한 응급복구법 l2zeo 2010.03.31 32081
85 리눅스 보안 - 권한설정에 주의해야할 명령어들은 ? l2zeo 2010.03.31 27743
84 [적용] iptables 접속 차단 스크립트 ADMINPLAY 2010.05.03 25594
83 Modsecurity 무료 웹방화벽 설치 file ADMINPLAY 2010.09.12 24046
82 denyhosts (ssh, ftp 등의 접근 차단) ADMINPLAY 2010.05.03 21356
81 Modsecurity-apache 2.5.X 설치중 에러 server: /usr/lib/... ADMINPLAY 2010.09.12 21283
80 modsecurity-2.5 configure: *** apr library not found. ADMINPLAY 2010.09.12 21129
79 php 수호신 설치 ADMINPLAY 2010.05.03 20822
78 php.ini 보안 설정 ADMINPLAY 2010.05.03 20371
77 PHP 보안관련 설정 권고사항 ADMINPLAY 2010.05.19 20206
76 해킹 당했는지 알아보는 방법 ADMINPLAY 2010.05.03 19975
75 iptables와 mod_security 연동을 통한 ip 차단 file ADMINPLAY 2010.09.15 19761
74 iptables를 이용한 SSH brute force 공격방어 l2zeo 2010.05.29 19684
73 Modsecurity-apache 2.5.12 file ADMINPLAY 2010.09.12 18705
72 리눅스 해킹점검 가이드 ADMIN 2008.12.10 18234
71 웹어플리케이션 보안 ADMINPLAY 2010.05.03 17146
» 보안 체킹 프로그램 - portsentry file ADMINPLAY 2010.04.27 16164
69 Cisco/Tip/라우터,스위치에서 패킷 캡쳐하기 file l2zeo 2010.03.23 16121
Board Pagination Prev 1 2 3 4 5 Next
/ 5

Copyright ADMINPLAY corp. All rights reserved.

abcXYZ, 세종대왕,1234

abcXYZ, 세종대왕,1234