출처 : 대전국제IT교육센터 정성재 강사
1. Tripwire의
개요
트립와이어는 파일의 변조 여부를 모니터링하는 툴이다. 보통 공격자가 시스템에 침입을 성공하면
다시
들어오기 위한 구멍(Backdoor)을 만들게 된다. 이 때 공격자는 여러 프로그램을 변조하게 된다.
대표적으로 ps, ls,
netstat등 시스템의 정보를 확인할 수 있는 명령어가 주 타겟이다. 이렇게 침입
당한 시스템의 파일의 무결성을 검사해주는 프로그램이
tripwire이다. tripwire는 MD5, SHA, CRC-32
등의 다양한 해쉬 함수를 제공하고, 파일들에 대한 데이터베이스를
만들어 이를 통해 해커들에 의한
파일들의 변조여부를 검사하도록 되어 있다. 즉 tripwire는 먼저 시스템에 존재하는 파일에 대해
데
이터 베이스를 생성하고 저장한 후에 생성된 데이터베이스와 비교하여 추가,삭제되거나 변조된 파일
이 있는지 점검하고 관리자에게
리포팅해주는 도구이다.
2. Tripwire의 역사
트립와이어는
1992년 푸르드(Purdue)대학의 컴퓨터 보안 전문가인 유진 스패포드(Eugene Spafford)
박사와 대학원생인 지니 킴(Gene
Kim)에 의해 개발되었다. 초기의 tripwire 1.x는 오픈소스였으나
2.x로 오면서 tripwire사에서 상용화하여
tripwire 1.3대의 ASR(Academic Source Release)에 대해서
는 공개로 배포하고 있다.
현재
Linux시스템에서는 Open Source 프로젝트를 추진하여 2.3버전의 tripwire를 다운받아 사용할
수 있고, 그 외의
운영체제인 Solaris, Windows NT 계열, HP-UX, IBM AIX 시스템등에서 2.X대 버전
을 사용하려면 상업용 버전을
이용해야 한다.
3. Tripwire 설치하기
(1) 설명: 트립와이어는
대부분의 배포판 리눅스에서 기본적으로 제공한다. 트립와이어가 없거나
관련정보를 얻으려면 아래의 2개의 사이트에서 구할 수
있다.
(2) 관련사이트
http://www.tripwire.com
http://www.tripwire.org
(3) 설치하기
1) http://www.tripwire.org에 접속해서
tripwire-2.3-47.i386.tar.gz을 다운받는다.
2) 압축은 푼다.
tar zxvf
tripwire-2.3-47.i386.tar.gz
3) 압축을 풀면 rpm패키지파일이 나오는데 이 파일을 설치한다.
rpm -Uvh tripwire-2.3-47.i386.rpm
4. Tripwire
사용하기
(1) tripwire 설정파일 및 정책파일 생성하기
1) 설명: twinstall.sh라는
파일을 실행시키면 트립와이어는 site keyfile과 local keyfile을
생성하기 위한
Passphrases를 입력하도록 요구한다. site keyfile은 정책파일과 환경
파일을 설정하는데 사용되고,
local keyfile은 트립와이어 데이터베이스와 레포트 파일
을 초기화하고 보호하는데 사용되는 일종의 암호이다.
2) twinstall.sh 실행
[root@www root]# cd /etc/tripwire
[root@www tripwire]# ./twinstall.sh
----------------------------------------------
The Tripwire site and
local passphrases are used to
sign a variety of files, such as the
configuration,
policy, and database files.
Passphrases
should be at least 8 characters in length
and contain both letters and
numbers.
See the Tripwire manual for more information.
----------------------------------------------
Creating key
files...
(When selecting a passphrase, keep in mind that good
passphrases typically
have upper and lower case letters, digits and
punctuation marks, and are
at least 8 characters in length.)
Enter the site keyfile passphrase: // 사이트키의 암호값을 설정한다.
Verify
the site keyfile passphrase:
Generating key (this may take several
minutes)...Key generation complete.
// 두번의 암호 입력이 성공하면
/etc/tripwire디렉토리에 site.key라는 파일에 암호가 저장
//된다.
(When
selecting a passphrase, keep in mind that good passphrases typically
have upper and lower case letters, digits and punctuation marks, and are
at least 8 characters in length.)
Enter the site keyfile
passphrase:
Verify the site keyfile passphrase:
Generating key
(this may take several minutes)...Key generation complete.
(When
selecting a passphrase, keep in mind that good passphrases typically
have upper and lower case letters, digits and punctuation marks, and are
at least 8 characters in length.)
Enter the local keyfile
passphrase: // 로컬키의 암호값을 설정한다.
Verify the local keyfile
passphrase:
Generating key (this may take several minutes)...Key
generation complete.
// 이 로컬키의 값은 /etc/tripwire/호스트명-local.key파일로
저장된다.
----------------------------------------------
Signing
configuration file...
Please enter your site passphrase: // 환경설정파일
생성을 위해 사이트키값 입력
Wrote configuration file: /etc/tripwire/tw.cfg
// 환경설정파일은 tw.cfg파일로 저장된다. 그러나 이 파일은 편집이 불가능한 바이너리파일
//이다. 따라서 내용을
확인하거나 설정내용을 변경하려면 twcfg.txt을 편집하면 된다.
A clear-text version of
the Tripwire configuration file
/etc/tripwire/twcfg.txt
has been
preserved for your inspection. It is recommended
that you delete this
file manually after you have examined it.
----------------------------------------------
Signing policy
file...
Please enter your site passphrase: // 정책파일 생성을 위해 사이트키값
입력
Wrote policy file: /etc/tripwire/tw.pol
// 정책파일은 감시할 디렉토리와
파일을 지정하고, 어느 정도 수준으로 감시할 것인지를
//설정하는 파일이다. /etc/tripwire/tw.pol에
저장된다.
A clear-text version of the Tripwire policy file
/etc/tripwire/twpol.txt
has been preserved for your inspection. This
implements
a minimal policy, intended only to test essential
Tripwire functionality. You should edit the policy file
to describe
your system, and then use twadmin to generate
a new signed copy of the
Tripwire policy
(2) 데이터베이스 초기화
1) 설명: 데이터베이스를 초기화한다. 로컬키 암호를 물어본다. 몇몇
시스템에서는 에러가 발생
할 수도 있으며 시간이 조금 걸린다.
2) 사용예
[root@www
sbin]# tripwire --init
Please enter your local passphrase:
Parsing policy file: /etc/tripwire/tw.pol
Generating the
database...
*** Processing Unix File System ***
-- 중략
--
Wrote database file: /var/lib/tripwire/www.twd
The database
was successfully generated.
=> 초기화된 데이터베이스는
/var/lib/tripwire/호스트명.twd파일로 저장된다.
(3) 무결성 검사
1) 설명: tripwire
--check라고 명령을 내리면 된다.
2) 사용예
[root@www sbin]# tripwire
--check
Parsing policy file: /etc/tripwire/tw.pol
*** Processing
Unix File System ***
Performing integrity check...
-- 생략
--
(4) 데이터베이스 갱신
1) 설명: 무결성 검사 후 발견되어진 변경 파일이 침입에 의한 것이 아니라 정상적인
변화라면
기존에 만들어졌던 데이터베이스를 갱신해야 한다.
2) 사용예
[root@www
sbin]# tripwire --update
=> 같은 명령으로 'tripwire -m u'가 있다.
(5)
정책파일 갱신
1) 설명: 정책파일을 갱신하는 방법에는 'tripwire --update-policy'와 'twadmin
--creat-profile'
두가지 방법이 있다.
2) 사용예
[root@www
sbin]# tripwire --update-policy /etc/tripwire/tw.pol
5.
Tripwire 테스트하기
(1) 임의의 파일이용한다.
1) 특정한 파일의 이름을 임시로 변경한다.
[root@www root]# mv install.log install.log~
2) 임의로
install.log파일을 생성한다.
cat > install.log
3) 트립와이어를 이용하여
체크한다.
[root@www root]# tripwire --check
4) 결과를 확인한다.
5) 만약
결과를 확인 후에 변화된 결과가 정상적인 것이라면 데이터베이스를 갱신한다.
[root@www root]# tripwire
--update
=> 위 명령으로 안되면 'tripwire --init'명령으로 초기화시킨다.