« PREV : 1 : 2 : NEXT »

Linux 로그 확인

Posted 2009/10/21 10:42
Linux와 Unix는 이런 부분은 비슷하다고 생각되네요.

많은분들이 문제 확인과 증상을 보기위해 로그를 확인하실 겁니다.
로그의 기본 위치는 /var/log 입니다.

해당 위치에서 주요 확인 로그는 아래와 같죠
boot 부팅 관련 로그입니다.
maillog 메일 관련 로그 입니다.
messages 메일과 뉴스를 전체적인 로그이죠
secure 유저 접속에 관련된 로그입니다.
dmesg 시스템 부팅시 출력되는 메세지입니다.
cron cron관련 예약 작업 메세지 입니다.
wtmp 사용자들의 접속한 정보을 기록합니다.
xferlog FTP 서버의 데이터 전송관련 로그 기록

그럼 어떤식으로 확인을 하게 될까요?

boot.log에서 ?가 포함된 내용 확인
grep [search string] [file name]

grep “?” /var/logs/boot.log

boot.log에서 ?와 08/Feb가 포함된 내용 확인
grep [search string] [file name] | grep [2nd search string]
grep “?” /var/logs/boot.log | grep “08/Feb”

boot.log에서 ?와 08/Feb가 포함되나 Vmware가 들어간 내용은 제외하고 확인
grep [search string] [file name] | grep [2nd search string] | grep -v [search string]
grep “?” /var/logs/boot.log| grep “07/Feb” | grep -v “Vmware”

저작자 표시 비영리
Write your message and submit

사용자 계정 추가

Posted 2009/09/10 21:13

사용자 계정 추가

root 그룹으로 계정사용자 추가

# adduser itka -g root

비밀번호 설정

# passwd itka

New UNIX passward : *********

Retype new UNIX password : *********

명령어 adduser를 통해 계정을 추가 할 수 있습니다. 위 예제는 root 그룹으로 사용자 계정 wiz를 추가한 것 입니다. 그 밖의 옵션은 아래를 참고 하세요.

adduser 옵션

 -c comment 사용자설명 추가

 -d home 계정의 홈 디렉토리 지정

 -e expire 계정 만기일 지정

 -u uid uid지정

 -s shell 사용자 login shell지정

 -g group 지정그룹으로 속하게 함

 -G group 기본그룹 외 다른 그룹에 추가

1.2 계정을 root 권한으로 사용하기

// 사용자 관리 권한 부여

# vi /etc/passwd

-itka:x:500:0::*********************

-itka:x:0:0::*********************

계정 자체를 루트로 사용이 가능합니다. 사용하기에는 편리하지만 보안상 문제가 있을 수 있기 때문에 조심해서 사용해야 합니다.

Write your message and submit

MS-DOS의 램상주 프로그램(TSR)처럼 실행이 종료된 뒤에도 메모리에 계속 남겨두고 다음  실행시에 상대적으로 실행속도를 빠르게 하도록 설정하는 속성을 Sticky bit(스티키비트) 라고 하며 chmod명령으로 설정할 수 있다.

스티키 비트를 설정하려면 rwx처럼 t(sTicky)를 사용할 수있으며 설정되면 가장 오른쪽의

실행 비트가 t로 표시된다.

# ls -al test

-rw-rw-rw- 1 syhwang syhwang 21 Aug 22 20:30 test

# chmod +t test; ls -al test

-rw-rw-rwT 1 syhwang syhwang 21 Aug 22 20:30 test*

실행속성이 없는 파일에 Sticky bit가 설정되면 대문자 T가 오른쪽에 표시되며

실행속성이 있는 파일에 Sticky bit가 설정되면 소문자 t가 표시된다.

# chmod 1775 test

-rw-rw-r-t 1 syhwang syhwang 21 Aug 22 20:30 test*

위의 명령어도 동일한 효과가 나타난다.

또다른 기능

# ls -al test

-rwxr-xr-x 1 root syhwang 21 Aug 22 20:30 test*

# chmod 4755 test

-rwsr-xr-x 1 root syhwang 21 Aug 22 20:30 test*

다음과 같이 설정하는 경우 test를 다른 User가 수행하는 경우에도

Root의 권한으로 수행되도록 한다.

위와 같은 설정은 실행하는 User가 아닌 파일의 Owner의 권한으로 프로그램이

수행되도록 설정하는 것이다.

   

``sticky" 비트 - 이 비트가 디렉토리에 설정되어 있을 때 그 디렉토리내에서 파일의 언링크 (제거) 및 재명명은 파일 소유자, 디렉토리 소유자 또는 루트만이 할 수 있다. 이는 매우 공통된 유닉스의 확장으로 오픈 그룹의 Single Unix Specification 버전 2 에 명시되어 있다. 초기 유닉스 버전들은 이를 ``save program text" 비트라고 불렀으며 이를 메모리에 상주해야 하는 실행가능한 파일을 가리킬 때 사용하였다. 루트만이 이 비트를 설정할 수 있도록 시스템은 보증했는데 그렇지 않다면 사용자들이 억지로 ``모든 것"을 메모리에 올림으로써 시스템을 파손시킬 수 있을 것이다. 리눅스에서 이 비트는 일반 파일에 아무런 영향을 미치지 않으며 일반 사용자는 자신이 소유한 파일에 대해 이 비트를 변경할 수 있다: 리눅스의 가상 메모리 관리 기법은 이러한 비트를 사용해도 아무런 문제가 되지 않게 한다.

문서 성질의 보존 (Save Text Attribute): (디렉토리의 경우)

"스틱키 비트 (sticky bit)"는 디렉토리에 적용될 경우에는 다른 뜻을 가지게 된다. 디렉토리에 스틱키 비트가 붙을 때에는 사용자는 -- 설령 사용자가 디렉토리에 일반적인 쓰기 허가권이 있더라도 -- 소유권이 있거나 확실하게 쓰기 허가권이 허락된 파일 만 지울 수 있게 된다. 이것은 /tmp 따위의 -- 월드-라이타블이면서도 일반 사용자가 무조건 파일을 지우면 좋지 않을 -- 디렉토리 등을 위해 쓰여진다. 스틱키 비트는 긴 디렉토리 리스팅 (ls -l)에서 t로 표시된다.

출처 : http://blog.naver.com/classbox?Redirect=Log&logNo=120021355582

SetUID / SetGID

Set-Bit 이해하기

   

(1) Set-Bit : Set-Bit란 기본권한이외에 특수한 목적을 위해 부여되는 특수권한이다. Set-Bit

                에는 Set-UID, Set-GID, Sticky Bit이 있으며, 이러한 권한은 시스템운영에 꼭

                필요하지만 보안상의 위험을 초래할 수 있으므로 정확한 이해가 필요하다.

   

  (참고1) 'ls -l'을 이용한 파일의 종류확인하기

  보통 'ls -l' 명령을 내리면 다음과 같이 나온다.

  -rwxrw-r--    1 posein  posein        95  4월  9 15:13 a.out

  파일의 권한과 관련된 부분이 -rwxrw-r--이다. 처음 -부분이 파일의 종류를 나타내는 것이다.

    - : 일반파일

    d : 디렉토리

    l : 링크파일

    b : 블럭디바이스(디스크 드라이버)

    c : 캐릭터 디바이스(입출력 관련 특수 파일)

    P : 네임드 파이프

    s : 소켓

   

   

(2) set-UID가 부여된 파일을 살펴보기

   

  1) 설명: Set-UID가 설정된 파일로는 passwd명령이 있다. 이 명령은 보통 패스워드를 변경

              하는 명령이다. 이 명령어를 가지고 Set-bit에 대해 알아보자.

  2) 예

    ㄱ. [root@www bin]# cd /usr/bin 한다.

    ㄴ. [root@www bin]# ls -l passwd

        -r-s--x--x    1 root    root        15368  5월 29  2002 passwd

        => 살펴보면 사용자권한의 x자리에 s라는 글자가 있다. 이것이 set-UID가 부여된 것이다. 

      이 명령의 소유자는 root이다. 따라서 이 명령어를 실행시킬 수 있는 사람은 root와 동일

      하게 passwd 명령을 이용하는 것이다.

   

  3) Set-Bit가 필요한 이유

      일반사용자가 자기 자신의 패스워드를 변경한다고 가정하자. 이 경우에 passwd명령으로

      패스워드변경한 후에 실제적인 기록은 /etc/shadow파일에 변경되어야 한다. 그러나,

      일반사용자는 /etc/shadow파일에 쓰기권한은 물론 읽기권한조차 부여가 되어있지 않다.

      이런 경우에는 passwd 명령을 이용한 순간에는 root권한으로 /etc/shadow라는 파일에

      기록할 필요가 있게 된다. 이러한 이유로 Set-Bit가 필요하다. 보안상 Set-Bit는 위험하지만

      꼭 필요한 요소이다.

   

(3)set-UID를 이용해보기

   

  1) 설명: Set-Bit가 이해되지 않는다면 와우리눅스 6.2(커널 2.2버전)을 설치하여 다음을 테스트

              해보면 쉽게 이해되리라 생각된다. 현재 리눅스(커널 2.4버전이상)에서는 되지 않는다.

              예전에 백도어(Back Door)로 많이 이용되면 방법이다.

  2) 방법 : 보통 리눅스에서는 bash를 사용한다. 이 bash파일을 이용하여 set-UID를 이용해보자.

    ㄱ. bash의 실행파일이 /bin/bash이므로, /bin디렉토리로 이동하자.

        [posein@house posein]$ cd /bin

    ㄴ. 'ls -l bash' 해본다.

      [posein@house /bin]$ ls -l bash

      -rwxr-xr-x    1 root    root      377960  5월 19  2000 bash*

        => 이 파일의 특성을 살펴보면 소유자는 root이고 실행파일로서 실행권한은 모든 계층에서

          사용가능하게 되어 있다. 다른 것이 있다면 속성은 변경권한은 루트에게만 있다는 것이다.

          이 파일은 모든 사용자들이 로그인과 동시에 사용된다.

    ㄷ. bash파일에 set-UID를 부여해본다. 일단 속성의 변경은 파일의 소유자인 root에게

        있으므로 루트권한을 획득했다고 가정한다.

        [root@house /bin]# chmod u+s bash

    ㄹ. bash파일의 속성을 확인해보자.

      [root@house /bin]# ls -l bash

      -rwsr-xr-x    1 root    root      377960  5월 19  2000 bash*

        => 속성이 바뀌었음을 알 수 있다.

    ㅁ. 이 파일은 모든 사용자들이 사용하는 파일이므로 일반사용자로 로그인해보자.

        로그인해보면 무엇인가 다름을 느낄 수 있다.

      [posein@house posein]#

        => 프롬프트부터 다르다. 리눅스에서 '$'는 일반사용자를 나타내고 '#'은 루트권한자임을

          나타낸다. 리눅스에서 현재접속한 일반사용자는 루트권한자로 처리한다는 것을

          알 수 있다.

    ㅂ. 명령어를 이용하여 사용자 확인해보자. 먼저, who명령어를 이용해보자.

      [posein@house posein]# who

      posein  pts/0    Jun 25 01:20

        => 접속한 사람은 'posein'이라는 것을 알 수 있다.

    ㅅ. 또 다른 명령인 whoami명령을 이용해보자.

      [posein@house posein]# whoami

      root

        => 루트로 인식함을 알 수 있다.

    ㅇ. 루트의 권한인지 사용해보자.

      파일의 소유자가 루트이고 루트만이 변경가능한 파일인 /etc/inittab파일을 이용하여

      테스트해보도록 하자.

      [posein@house posein]# vi /etc/inittab

      => 편집을 해보도록 한다. 편집을 시작하자 마자 ex모드 명령줄에서 'Warning: Changing

          a readonly file'라고 경고메시지가 뜬다. 즉 일단은 일반사용자로 인식했기 때문에 읽기

          전용 이라는 메시지가 뜬다. 그러나, 무시하고 ':wq!'를 이용하여 저장해보자. 저장이

          되서 변경됨을 알 수 있다. 즉 루트권한자로서 실행이 가능함을 알 수 있다. 참고로

          뛰어난 해커들은 이런식으로 원본파일에 set-UID속성을 부여하지 않는다. 일단 루트권한

          을 획득한 뒤 원본 파일을 다른 이름으로 바꿔서 복사시킨 후에 set-UID를 걸어서

          백도어로 사용한다.

   

(4) sticky bit에 대하여

   

  1) 설명: sticky bit는 /tmp디렉토리에서 사용되고 있다. 이 디렉토리를 살펴본다.

   

  2) 방법

    ㄱ. 일단 최상위 디렉토리로 이동해보자.

      [posein@house posein]$ cd /

    ㄴ. 속성의 확인

      [posein@house /]$ ls -l

      drwxrwxrwt    9 root    root        4096  6월 25 01:45 tmp/

        => /tmp디렉토리에 sticky 비트가 설정되어 있음을 알 수 있다. 이 디렉토리에서는 모든

          사용자가 파일이나 디렉토리를 만들고 지울 수 있다. 그러나, 해당파일이나 디렉토리를

          지울 수 있는 것은 그 파일이나 디렉토리의 소유자만 가능한다. 즉 절대로 다른 사람들이

          만든 파일이나 디렉토리등은 지울 수 없다. 그래서 sticky bit를 공유모드라고 한다.

 

출처 : http://blog.naver.com/classbox?Redirect=Log&logNo=120021355582

Write your message and submit



Write your message and submit
생각보다 간단하다.
아래 명령을 쉘을 열고, ADDTIONS시디 디렉토리로 이동후 실행 하도록하자

pkgadd -d ./VBoxSolarisAdditions.pkg
저작자 표시 비영리
Write your message and submit

1.VBoxLinuxAddition 마운트


[root@localhost ~]# mount /dev/hdc -iso9960 /media
[root@localhost ~]# cd /media/
[root@localhost media]# ls
32Bit        VBoxLinuxAdditions-amd64.run  VBoxWindowsAdditions-amd64.exe
64Bit        VBoxLinuxAdditions-x86.run    VBoxWindowsAdditions-x86.exe
AUTORUN.INF  VBoxSolarisAdditions.pkg      VBoxWindowsAdditions.exe

2.VBoxLinuxAddition에 필요한 모듈 설치

[root@localhost media]# sh VBoxLinuxAdditions-x86.run
Verifying archive integrity... All good.
Uncompressing VirtualBox 2.0.2 Guest Additions for Linux installation.........................................................................................................................................................................................
VirtualBox 2.0.2 Guest Additions installation
Please install the build and header files for your current Linux kernel.

The current kernel version is 2.6.18-92.el5
Please install the GNU compiler.
Problems were found which would prevent the Guest Additions from installing.
Please correct these problems and try again.
[root@localhost media]#
위와 같이 추가 모듈을 설치해야 한다는 메세지를 볼수 있다.
그 메세지는 아래 모듈을 설치하여 해결할수 있다.


yum install kernel-devel gcc
패키지를 패키지 관리자에서 찾기를 통해 설치도 가능함
 *
재부팅 할것


3.VBoxLinuxAddition 설치

[root@localhost media]#
sh VBoxLinuxAdditions-x86.run
Verifying archive integrity... All good.
Uncompressing VirtualBox 2.0.2 Guest Additions for Linux installation.........................................................................................................................................................................................
VirtualBox 2.0.2 Guest Additions installation
Building the VirtualBox Guest Additions kernel module...
Building the shared folder support kernel module...
Installing the VirtualBox Guest Additions...

Successfully installed the VirtualBox Guest Additions.
You must restart your guest system in order to
complete the installation.
[root@localhost media]#

 


저작자 표시 비영리
Write your message and submit

쉘에서 파일 다운로드 받기

Posted 2009/06/16 22:00

리눅스는 GUI의 사용이쉘 명령어 이용보다 매우 불편합니다.
대다두 리눅스 사용자들은 쉘에 익숙하기때문에 쉘에서 다운로드는 하는 명령어를 알아보도록 하겟습니다
.


1.wget
wget http://itka.kr/test.zip


2.lftpget
lftpget http://itka.kr/test.zip


3.curl
curl -O http://itka.kr/test.zip


많이 사용하는 순으로 정리했습니다.
wget
이 압도적으로 많이 쓰이죠
^^
GUI
도 편하지만 쉘이 직관적이고 작업도 편하답니다.


저작자 표시 비영리
Write your message and submit

시스템의 로그파일들을 root@도메인 계정으로 메일을 받아보시려면 아래와 같이 수정하시기 바랍니다.

#vi /etc/log.d/scripts/logwatch.pl

$Config{'mailto'} = "root";

 

/etc/cronttab 파일에 아래 내용을 추가 합니다.

#vi /etc/crontab

MAILTO=root@itka.kr

 

TIP1 /etc/aliases을 설정하면 로그파일을 여러 사용자가 받아볼수 있습니다.

#vi /etc/aliases

root: server@itka.kr; root@itka.kr

server: temp@itka.kr

 

TIP2 /etc/passwd의 주석 부분(밑줄 부분)이 보낸 사람이름으로 발송됩니다.

root:x:0:0:ITKA.KR:/root:/bin/bash

저작자 표시 비영리
Write your message and submit

NetFlow를 활용한 트래픽 관리

Posted 2009/06/16 21:57

1.     NetFlow 데이터란?

 

Source IP destination IP사이에 발생하는 일련의 패킷들을 NetFlow라고 정의할 수 있는데, 여기에는 NetFlow버전에 따라 다양한 정보를 포함하고 있다. 기본적으로 source IP, destination IP, application port 번호, IP Protocol Type, Service Type, AS번호 등이다. 이런 정보를 이용해 현재 발생하고 있는 이벤트에 대한 추적이 가능하다.

 

참조: http://www.cisco.com/warp/public/cc/pd/iosw/ioft/neflct/tech/napps_wp.htm

 

기존의 MRTG가 실제 트래픽 사용률에 대한 정보를 보여 주었다면, NetFlow 데이터는 위에서 언급한 정보들을 가지고 있으므로 과다한 트래픽을 발생시키는 IP, 바이러스에 감염된 PC, 그리고 현재 우리 네트웍에서 어떤 유형의 트래픽이 많은 지를 분석할 수 있다.

 

따라서 MRTG FlowScan을 병행하면 굳이 고가의 NMS 프로그램을 구입하지 않더라도 수준급의 보안 시스템을 구축했다고 볼 수 있지 않을까?

 

* 실제예 : 바이러스에 감염된 전용선 가입자의 MRTG 그래프 및 FlowScan 검색

MRTG그래프

이 그래프는 어떤 전용회선 가입자의 트래픽 사용현황을 보여주는 것으로써 input값이 일정하고 또 새벽에도 input값이 일정하게 있는 것으로 보아 바이러스에 감염됐음을 짐작할 수 있다. 하지만 어떤 IP인지는 이 그래픽만으로는 알 수 없다. 이때 FlowScan을 이용하면 된다.

 

FlowScan

2003/11/27 04:08:22 211.238.196.17 -> 211.238.205.100 ICMP_ECHO 1 92

2003/11/27 04:08:22 211.238.196.17 -> 211.238.205.101 ICMP_ECHO 1 92

2003/11/27 04:08:22 211.238.196.17 -> 211.238.205.102 ICMP_ECHO 1 92

2003/11/27 04:08:22 211.238.196.17 -> 211.238.205.103 ICMP_ECHO 1 92

2003/11/27 04:08:22 211.238.196.17 -> 211.238.205.104 ICMP_ECHO 1 92

2003/11/27 04:08:22 211.238.196.17 -> 211.238.205.105 ICMP_ECHO 1 92

2003/11/27 04:08:22 211.238.196.17 -> 211.238.205.106 ICMP_ECHO 1 92

2003/11/27 04:08:22 211.238.196.17 -> 211.238.205.107 ICMP_ECHO 1 92

2003/11/27 04:08:22 211.238.196.17 -> 211.238.205.108 ICMP_ECHO 1 92

2003/11/27 04:08:22 211.238.196.17 -> 211.238.205.109 ICMP_ECHO 1 92

FlowScan으로 위 가입자의 IP주소(211.238.196.17)를 검색해보니 특정 IP주소(211.238.205.X번대) 92Byte의 일정한 크기로 스캔하는 웜(Welchia)에 감염되었음을 알 수 있다.

 

☞ 이제부터 NetFlow 데이터를 분석하는 프로그램들을 설치해보자.

 

2.     프로그램 설치

1)     내가 설치한 시스템 사양

[H/W]

모델명 : 인텔 ISP2150 (인텔 조립서버라고 많이 부름)

CPU : PIII 800MHz *2 (듀얼CPU)

Memory : 1024Gbytes

DISK : 9Gbytes*1, 72Gbytes*1 (모두 SCSI방식, 72G NetFlow데이터 쌓임)

[S/W]

OS : Redhat Linux 7.2

설치패키지 : Linux설치 시 대부분의 패키지 설치(게임 관련 패키지 제외)

 

2)     프로그램 설치순서 및 역할

Apache

웹서버

Perl5

Perl로 작성된 프로그램 인터프리터

RRDTool

분석된 Flow데이터를 저장하는 DB파일

Flow-tools

flow 데이터를 수집하는 collector

Perl Modules

Perl 추가 모듈

Korn Shell

CUFlow 프로그램에서 사용

FlowScan

수집된 flow데이터를 분석하여 보고서 작성

CUFlow

보고서 종류 중 하나. 다른 종류로써 CampusIO SubNetIO가 있고 서로 혼용해서 사용가능

 

 

3)     설치

    Apache Linux 설치 시 패키지로 설치하거나 최신버전을 다운받아 설치하면 된다.

    Perl5역시 Apache와 동일한 방법으로 설치하면 된다.

RRDTool

다운받기

www.rrdtool.org 에서 stable버전인’rrdtool.tar.gz’ 받음

설치

tar –zxvf rrdtool.tar.gz ('rrdtool-1.0.43’ 디렉토리 생성, 버전에 따라 다름)

cd rrdtool-1.0.43

./configure –enable-shared –prefix=/usr/local/rrdtool

make install site-perl-install

 

Flow-tools

다운받기

http://www.splintered.net/sw/flow-tools/

설치

tar –zxvf flow-tools-0.66.tar.gz

cd flow-tools-0.66

./configure; make; make install

* 관련 파일들이 ‘/usr/local/netflow’ 디렉토리에 설치된다.

 

Perl Modules

CPAN Shell 방식으로 설치할 수도 있고, 관련 Module을 다운받아서 설치 할 수도 있다. 여기서는 관련 Module들을 다운받아 설치한다. , ConfigReader는 다른방식으로 설치한다.

다운받기

http://search.cpan.org/search?dist=Boulder

http://search.cpan.org/search?dist=ConfigReader

http://search.cpan.org/search?dist=HTML-Table

http://net.doit.wisc.edu/~plonka/Net-Patricia/

http://net.doit.wisc.edu/~plonka/Cflow/

설치

(Cflow)

tar –zxvf Cflow-1.051.tar.gz

cd Cflow-1.051

perl Makefile.PL

make; make test; make install

* 다른 Module들도 같은 방식으로 설치

설치

(ConfigReader)

ConfigReader Makefile.PL 파일이 없으므로, REAME 파일 참조해서

- You'll find documentation in ConfigReader.pod, as well as in the source files. The *.pm files should be installed in a "ConfigReader" subdirectory on your Perl include path. -

 

/usr/lib/perl5/5.8.0/ConfigReader 디렉토리를 만들어서 *.pm 복사하고,

/usr/lib/perl5/site_perl/5.8.0/ConfigReader 디렉토리도 만들어서 *.pm 복사하면 된다.

 

tar -zxvf ConfigReader-0.5.tar.gz

cd ConfigReader-0.5

cd /usr/lib/perl5/5.8.0

mkdir ConfigReader

cd ConfigReader

cp /home/src/ConfigReader-0.5/* .

 

Korn Shell

다운받기

Linux설치 CD#2 RPM디렉토리나 http://www.kornshell.com

설치

rpm –Uvh pdksh-5.2.14-16.i386.rpm

 

FlowScan

다운받기

http://net.doit.wisc.edu/~plonka/FlowScan/

설치

(‘root’계정이 아닌 일반 계정으로 설치할 것을 권고)

tar -zxvf FlowScan-1.006.tar.gz

cd FlowScan-1.006

./configure --prefix=/var/netflow

make

make -n install

make install

cd cf

cp flowscan.cf /var/netflow/bin

 

CUFlow (일반계정으로 설치 계속)

다운받기

http://www.columbia.edu/acis/networks/advanced/CUFlow/

설치

tar –zxvf CUFlow-1.4.tgz

cd CUFlow-1.4

cp CUFlow.* /var/netflow/bin/

 

☞ 자, 이제 NetFlow데이터를 수집하고 가공하기 위해 필요한 프로그램 설치는 끝났다. 그럼 실제 라우터나 스위치에서 NetFlow 데이터를 FlowScan서버로 보내는 방법과 이를 서버에서 처리하기 위한 사전 환경설정에 대해서 알아보자.

 

3.     NetFlow 데이터 보내기

1)     시스코 라우터 설정 (여기서는 시스코7513 라우터에서 설정)

 

#Global-mode

ip flow-export version 5 peer-as

ip flow-export destination x.x.x.x y (x.x.x.x –collector’s ip주소 / y -port번호, 보통 FlowScan프로그램은 2055/UDP를 사용한다.)

#Interface-mode

ip route-cache flow

 

2)     확인 (아래 flows 개수가 증가하는 지 확인)

7513#sh ip flow export

Flow export is enabled

  Exporting flows to x.x.x.x (y)

  Exporting using source IP address x.x.x.x

  Version 5 flow records, peer-as

  439795660 flows exported in 16392366 udp datagrams

  0 flows failed due to lack of export packet

 

4.     FlowScan서버 환경구성

 

1)     flow-tools

flow파일 및 RRD파일이 저장될 디렉토리 생성

#mkdir –p /var/netflow/

#mkdir –p /var/netflow/ft

#mkdir –p /var/netflow/rrds

#mkdir –p /var/netflow/scoreboard

/usr/local/netflow/bin 밑에 export라는 파일을 만들고 소유권한을 ‘chmod a+x export’로 준다.

#cd /usr/local/netflow/bin

#touch export

#chmod a+w export

 

export 파일을 아래와 같이 편집한다.

#!/usr/bin/perl

$file = $ARGV[0];

if ( $file =~ /.*ft-v05\.(\d\d\d\d)-(\d\d)-(\d\d)\.(\d\d)(\d\d)(\d\d)/ ){
$cflowfile = "flows.".$1.$2.$3."_".$4.":".$5.":".$6;
$command = "/usr/local/netflow/bin/flow-export -f0 < $file > /var/netflow/$cflowfile";
print "$command\n";
system($command);
}else{print "File $file didn't match\n";}

 

tcpdump flow 데이터가 들어오는지 확인

#tcpdump –n udp port 2055

ð  라우터로부터 NetFlow데이터를 정상적으로 받는지 확인. 만일 스크롤되는 데이터가 없다면 라우터의 NetFlow 설정부터 확인

 

NetFlow 캡쳐하기

#/usr/local/netflow/bin/flow-capture -w /var/netflow/ft 0/0/2055 -S5 -V5 -E1G -n 287 -N 0 -R /usr/local/netflow/bin/export

 

* flow-capture프로그램 옵션 설명

·         -w /var/netflow/ft : flow-capture가 캡쳐한 flow 파일이 저장되는 장소

·         0/0/2055 : local IP/remote IP/port번호, 0 any IP를 의미, 0은 모든 IP 의미

 

2)     flowscan

/var/netflow/bin/flowscan.cf 파일 수정

#ReportClasses 부분   -> 어떤 보고서 형식을 사용할 지

ReportClasses CUFlow

#FlowFileGlob 부분  -> 가공된 NetFlow파일 형식을 지정하는 부분. 예로들면, ‘flows.20031214_17:50:00’과 같은 형식

FlowFileGlob flows.*:*[0-9]

CampusIO.cf와 같은 나머지 FlowScan 파일은 수정할 필요없음.

 

3)     CUFlow

/var/netflow/bin/CUFlow.cf 파일 수정

# Subnet 부분 : 내부에서 사용하는 IP블록, CIDR형식. 여러 줄 가능

Subnet 210.100.64.0/19

Subnet 211.12.160.0/20

 

# Network 부분 : 네트웍 그룹으로써 이 그룹에 대한 트래픽을 모니터링하고 싶은 경우. “Network x.x.x.x/y lable” 형식

Network 210.100.66.0/24,211.12.162.0/24 data_center

 

# OutputDir 부분 : RRD 파일이 저장되는 장소

OutputDir /var/netflow/rrds

 

# Scoreboard/AggregateScore 부분 : 트래픽을 많이 발생시키는 순위에 대한 html파일이 저장되는 부분.

Apache에서 이 파일을 링크하도록 구성하면 웹에서 확인 가능

Scoreboard  25  /var/netflow/scoreboard  /var/netflow/scoreboard/toptalkers.html

AggregateScore  25  /var/netflow/rrds/agg.dat  /var/netflow/scoreboard/overall.html

 

# Router 부분 : flow를 발생시키는 라우터 리스트

Router 210.100.64.1 GSR

Router 211.12.160.1 7513

 

☞ 이제 모든 준비가 끝났으므로 FlowScan을 실행시켜 NetFlow데이터가 제대로 쌓이는 지 확인해 보자.

 

5.     FlowScan 실행

 

1)     스크립트 작성

#touch /var/netflow/bin/fs.sh;

#chmod 755 /var/netflow/bin/fs.sh

#vi /var/netflow/bin/fs.sh

#!/bin/sh
# description: Start FlowScan

case "$1" in
'start')
cd /var/netflow/ ; bin/flowscan >>/var/log/flowscan 2>&1 </dev/null & >/dev/null
touch /var/lock/subsys/flowscan.1
;;
'stop')
rm -f /var/lock/subsys/flowscan.1
;;
*)
echo "Usage: $0 { start | stop }"
;;
esac
exit 0

 

2)     flowscan 실행하기

#/var/netflow/bin/fs.sh start

#tail –f /var/log/flowscan (아래와 같이 보이면 성공)

sleep 30...
2002/06/24 03:05:09 working on file flows.20020624_03:00:00...
2002/06/24 03:05:53 FlowScan-1.020 CUFlow: Cflow::find took 44 wallclock secs (43.57 usr + 0.11 sys = 43.68 CPU) for 8729930 flow file bytes, flow hit ratio: 156224/158726
2002/06/24 03:05:56 FlowScan-1.020 CUFlow: report took 3 wallclock secs ( 0.00 usr 0.03 sys + 1.47 cusr 1.30 csys = 2.80 CPU)
sleep 30...
 

3)     flowdumper

   용도 : FlowScan에 의해 가공된 파일은 RRD형식이므로 cat같은 명령으로는 읽을 수 없다. Flowdumper RRD파일을 텍스트로 변형시켜 보여줌으로 grep과 같은 명령어와 혼합하면 원하는 데이터를 얻을 수 있다.

   사용예

#flowdumper –s flows.20031214_20:45:00 | grep 211.238.196.17

 

4)     CUGrapher.pl

    용도 : RRD파일을 가공해서 그래프로 보여주는 perl프로그램

    CUFlow-1.4 디렉토리에서 아파치의 cgi-bin디렉토리로 복사

    http://yourserver/cgi-bin/CUGrapher.pl 로 접속

    참고사이트

o    http://wwwstats.net.wisc.edu

o    http://flows.ikano.com

 

6.     기타 관련 사이트

    http://www.cisco.com/go/fn - This is the Cisco Feature Navigator

    http://httpd.apache.org/ - This is the home page for Apache. This is the web server that I recommend.

    http://www.rrdtool.org/ - This is the RRDTool home page.

    http://www.splintered.net/sw/flow-tools/ - This is the flow-tools home page.

    http://net.doit.wisc.edu/~plonka/FlowScan/ - This is the FlowScan home page.

    http://www.columbia.edu/acis/networks/advanced/CUFlow/ - This is the CUFlow home page.

    http://net.doit.wisc.edu/~plonka/list/flowscan/ - This is the FlowScan mailing list home page.

    http://wwwstats.net.wisc.edu - Examples of FlowScan and CUFlow.

    http://flows.ikano.com - Another example web site.

    https://www1.columbia.edu/sec/bboard/mj/cuflow-users/ - CUFlow mailing list archive. The mailing list is cuflow-users@columbia.edu.

저작자 표시 비영리
Write your message and submit

메일 전용 유저 생성

Posted 2009/06/16 21:55

useradd  -M -s /bin/false 유저명

-M 메일 계정이라는 정보

-s 사용 쉘 지정 /bin/false 은 사용허가를 않함이다

*쉘 접속이 필요할 경우

useradd -d /home/lwg -s /bin/csh lwg

-d 홈 디렉토리 지정

-s 사용 쉘 지정 /bin/csh 은 사용을 허가함이다


저작자 표시 비영리
Write your message and submit

SpamAssassin - http://spamassassin.apache.org/

 

3.1 Download

 

[root@ihelpers src]# wget http://ftp.apache-kr.org/spamassassin/source/Mail-SpamAssassin-3.1.1.tar.gz

 

 

Perl Module Search - http://search.cpan.org/

 

[root@ihelpers src]# wget http://search.cpan.org/CPAN/authors/id/G/GA/GAAS/Digest-SHA1-2.11.tar.gz

[root@ihelpers src]# tar xvfz Digest-SHA1-2.11.tar.gz

[root@ihelpers Digest-SHA1-2.11]# perl Makefile.PL

[root@ihelpers Digest-SHA1-2.11]# make

[root@ihelpers Digest-SHA1-2.11]# make install

 

[root@ihelpers src]# wget http://search.cpan.org/CPAN/authors/id/G/GA/GAAS/HTML-Parser-3.51.tar.gz

[root@ihelpers src]# cd HTML-Parser-3.51

[root@ihelpers src]# tar xvfz HTML-Parser-3.51.tar.gz

 

[root@ihelpers HTML-Parser-3.51]# perl Makefile.PL

Warning: prerequisite HTML::Tagset 3 not found.

Writing Makefile for HTML::Parser

 

[root@ihelpers src]# wget http://search.cpan.org/CPAN/authors/id/P/PE/PETDANCE/HTML-Tagset-3.10.tar.gz

[root@ihelpers src]# tar xvfz HTML-Tagset-3.10.tar.gz

[root@ihelpers src]# cd HTML-Tagset-3.10

[root@ihelpers HTML-Tagset-3.10]# make

[root@ihelpers HTML-Tagset-3.10]# make install

 

[root@ihelpers HTML-Parser-3.51]# perl Makefile.PL

Writing Makefile for HTML::Parser

[root@ihelpers HTML-Parser-3.51]# make

[root@ihelpers HTML-Parser-3.51]# make install

 

3.2 설치

 

[root@ihelpers src]# tar xvfz Mail-SpamAssassin-3.1.1.tar.gz

[root@ihelpers src]# cd Mail-SpamAssassin-3.1.1

[root@ihelpers Mail-SpamAssassin-3.1.1]# perl Makefile.PL

What email address or URL should be used in the suspected-spam report

text for users who want more information on your filter installation?

(In particular, ISPs should change this to a local Postmaster contact)

default text: [the administrator of that system]

 

NOTE: settings for "make test" are now controlled using "t/config.dist".

See that file if you wish to customise what tests are run, and how.

 

checking module dependencies and their versions...

 

***************************************************************************

NOTE: the optional Razor2 (version 2.61) module is not installed.

 

  Used to check message signatures against Vipul's Razor collaborative

  filtering network. Razor has a large number of dependencies on CPAN

  modules. Feel free to skip installing it, if this makes you nervous;

  SpamAssassin will still work well without it.

 

  More info on installing and using Razor can be found

  at http://wiki.apache.org/spamassassin/InstallingRazor

 

Net::Ident::_export_hooks() called too early to check prototype at /usr/lib/perl5/site_perl/5.8.0/Net/Ident.pm line 29.

optional module missing: Razor2

 

warning: some functionality may not be available,

please read the above report before continuing!

 

Writing Makefile for Mail::SpamAssassin

Makefile written by ExtUtils::MakeMaker 6.03

 

 

[root@ihelpers Mail-SpamAssassin-3.1.1]# make

[root@ihelpers Mail-SpamAssassin-3.1.1]# make test

[root@ihelpers Mail-SpamAssassin-3.1.1]# make install

 

3.3 Test

 

[root@ihelpers Mail-SpamAssassin-3.1.1]# spamassassin -t < sample-nonspam.txt

[root@ihelpers Mail-SpamAssassin-3.1.1]# spamassassin -t < sample-spam.txt

 

 

. SpamAssassin Daemon ( 'spamd' Daemon ) 실행 - sendmail

 

3.4 사용자 추가

 

groupadd spamd

useradd -g spamd spamd

 

3.5 스크립트 및 서비스 등록

 

vi /etc/sysconfig/spamassassin

# Hint : if you want to enable SpamAssassin debugging

# (the debug output goes to /var/log/maillog) then use :

# SPAMDOPTIONS="-x -u spamd -H /home/spamd -d -D"

# Don't leave debugging turned on unnecessarily though,

# because it will slow down a busy server.

#

# Otherwise, for normal operation (debugging disabled) use :

SPAMDOPTIONS="-x -u spamd -H /home/spamd -d"

 

 

[root@ihelpers init.d]# cp redhat-rc-script.sh /etc/rc.d/init.d/spamd

[root@ihelpers init.d]# chkconfig --add spamd

[root@ihelpers init.d]# vi /etc/mail/spamassassin/local.cf

[root@ihelpers init.d]# /etc/rc.d/init.d/spamd start

 

procmail은 수신메일을 spamc에 전달하고 spamc는 데몬에 연결하여 이메일을 확인하도록 한다. spamd 데몬은 항상 실행상태에 있으며 전달받은 메일을 스캔해 스팸인 경우 별도의 스팸표시를 한다.

 

3.6 procmailrc 설정

 

[root@ihelpers root]# cat /etc/procmailrc #

# SpamAssassin procmail

#

OPPRIVS=yes

:0fw

* < 256000

| /usr/bin/spamc

 

3.7. 환경설정

 

1. spamassassin 설정파일 추가 및 수정

 

[root@ihelpers root]# cat /etc/mail/spamassassin/local.cf

# This is the right place to customize your installation of SpamAssassin.

#

# See 'perldoc Mail::SpamAssassin::Conf' for details of what can be

# tweaked.

#

# Only a small subset of options are listed below

#

###########################################################################

 

#   Add *****SPAM***** to the Subject header of spam e-mails

#

rewrite_header Subject *****SPAM*****

 

#   Save spam messages as a message/rfc822 MIME attachment instead of

#   modifying the original message (0: off, 2: use text/plain instead)

#

report_safe 0

 

#   Language

#

ok_locales en ko

ok_languages en ko

 

#   Set which networks or hosts are considered 'trusted' by your mail

#   server (i.e. not spammers)

#

# trusted_networks 212.17.35.

 

#   Set file-locking method (flock is not safe over NFS, but is faster)

#

lock_method flock

 

#   Set the threshold at which a message is considered spam (default: 5.0)

#

required_score 8.0

 

#   Use Bayesian classifier (default: 1)

#

use_bayes 1

 

#   Bayesian classifier auto-learning (default: 1)

#

bayes_auto_learn 1

 

#   Set headers which may provide inappropriate cues to the Bayesian

#   classifier

#

bayes_ignore_header X-Bogosity

bayes_ignore_header X-Spam-Flag

bayes_ignore_header X-Spam-Status

 

# Rules for all senders

score HEADER_8BITS 0

score HTML_COMMENT_8BITS 0

score SUBJ_FULL_OF_8BITS 0

 

 

 

 

3.8 데몬 재 실행

 

[root@ihelpers root]# /etc/rc.d/init.d/spamd restart

Shutting down spamd: [  확인 ]

Starting spamd: [  확인 ]

 

3. SpamAssassin Configuration Tool

http://www.yrex.com/spam/spamconfig.php
저작자 표시 비영리
Write your message and submit

MRTG 설치 및 활용하기

Posted 2009/06/16 21:52

MRTG 설치 및 활용하기

1. zlib :그래픽 파일을 압축
homepage :
http://www.zlib.net/

# wget http://www.zlib.net/zlib-1.2.3.tar.gz
# tar xvzf zlib-1.2.3.tar.gz
# mv zlib-1.2.3 /usr/local/zlib

# cd /usr/local/zlib

# ./configure
# make
# make test
# make install


2. libpng : zlib로 압축한 그래픽 파일을 PNG로 변경
homepage :
http://www.libpng.org/pub/png/libpng.html


 

# wget ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.2.16.tar.gz

# tar xvzf libpng-1.2.16.tar.gz
# mv libpng-1.2.16 /usr/local/libpng
# cd /usr/local/libpng
# cp scripts/makefile.linux ./makefile

# make test
# make install


3 . jpeg :
homepage : http://www.ijg.org

# wget
http://www.ijg.org/files/jpegsrc.v6b.tar.gz

# tar xvzf jpegsrc.v6b.tar
# mv jpeg-6b /usr/local/jpeg
# cd /usr/local/jpeg
# ./configure
# make
# make test
# make install


4. gd : jpeg, png, gif 등의 라이브러리
homepage :
http://www.libgd.org/


# wget http://www.libgd.org/releases/gd-2.0.34.tar.gz
# tar xvzf gd-2.0.34.tar.gz
# mv gd-2.0.34 /usr/local/gd
# cd /usr/local/gd
# make
# make install


5. MRTG
homepage : http://oss.oetiker.ch/mrtg/

# wget http://oss.oetiker.ch/mrtg/pub/mrtg-2.15.1.tar.gz
# tar xvzf mrtg-2.15.1.tar.gz
# cd mrtg-2.15.1
# ./configure --prefix=/usr/local/mrtg --with-gd=/usr/local/gd \

> --with-z=/usr/local/zlib --with-png=/usr/local/libpng
(
또는, /etc.ld.so.conf 파일에 각 프로그램의 라이브러리를 지정해도 된다.

 각 프로그램의 lib 디렉토리 경로를 입력한 후 ldconfig 명령으로 동적링크를

 바인딩)

# make
# make install



5.1 cfg파일 생성

cfgmaker
명령어를 이용하여 cfg파일을 생성

# /usr/local/mrtg/bin/cfgmaker --global 'WorkDir: /usr/local/apache/htdocs/mrtg' \

> --global 'Options[_]: bits,growright' --output /usr/local/mrtg/cfg/mrtg.cfg \

> community@ip주소

workdir :
수집한 자료값이 저장될 디렉토리

option : 여러 설정 옵션

  - bits : 기본 단위

  - growright : 새로운 데이터가 오른쪽에 생성

output : cfg 파일이 저장될 디렉토리



5.2 MRTG실행

#/usr/local/mrtg/bin/mrtg  /usr/local/mrtg/cfg/mrtg.cfg
(
처음 실행하면 warning 메시지가 뜨는데 이는 log값이 처음으로 생성이 되어 비교할 값이

없어서 나타나는 메시지이다. 이 명령을 3 실행하면 같은 warning 메시지는 나타나지

않는다.)



5.3 5분마다 mrtg 실행하기

# crontab -e 옵션을 사용해서
*/5 * * * *
  
/usr/local/mrtg/bin/mrtg  usr/local/mrtg/cfg/mrtg.cfg


5.4 index 파일 만들기

# /usr/local/mrtg/bin/indexmaker /usr/local/mrtg/cfg/mrtg.cfg \

> --output /usr/local/apache/htdocs/mrtg/index.html


저작자 표시 비영리
Write your message and submit

Lotus Domino Server 설치

Posted 2009/05/15 13:37


저작자 표시 비영리
Write your message and submit

오늘 사이트를 돌아다니다 괜찮은 기사를 접하게 되었습니다.

 

제가 평상시 관심있게 보고있는 내용으로써 쉘 스크립트 인데, 그부분을 다룬 내용이더군요.

유닉스를 공부한다 하더라도 방대한 양에 마스터 하기 힘들기 때문에 스크랩 하여 필요할 때 꺼내보시고, 참고하셨으면 합니다. J

 

그리고 유닉스를 능숙하게 사용하기 라는 카테고리가 있는것으로 보아, 다른 글도 추가로 읽어보세요

 

유닉스를 능숙하게 사용하기: 고급 셸 스크립트 기법

http://www.ibm.com/developerworks/kr/library/au-speakingunix_shellscripttech/

Write your message and submit

서버에 접근시 기본적으로 서버의 정보를 표시해주도록 되어 있는데 아래 배너 파일을 만들어 서버정보를 보여주지 않도록 합니다.

1. 아래 4개의 문서를 제작하거나 수정합니다.

#vi /etc/motd

#vi /etc/issue

#vi /etc/issue.net

#vi /etc/redhat-release


각 문서에 아래 내용 추가

================== for login user ==================

It will be punished for illegal login to this system.

It is saved for login information in another system.

내용은 같지 않아도 됩니다. :)

Write your message and submit