4일차

4일차

spoofing

: ip주소,호스트이름 ,mac주소등 여러가지를 속일수있으며 스푸핑은 이런 속임을 이용한 공격을총칭한다.


arp 스푸핑
         arp란 : 네트워크

 1.바이러스감염 시키는것이 목적
 2.로컬네트워크 서버를 직접적으로(다이렉트로) 들어가기힘들떄 옆의 일반컴퓨터를 뚫어 간적접으로 정보수집 , 그리고 치고들어가기위해서
 3. 아직도 많이사용되는 방법

실습
#ping -b 192.168.1.255 (broadcast 를 보낸다)
#arp -a  (등록되는것은 local에있는 pc들이 등록된다)
  static 경우는 뒤에 (perm)이라 쓰인다.
  dynamic 인경우 default

 

client    hacker     server
 A    B     C


a->c로가는것을 도중해 해커가 가로챈다  a->b-c : c->b->a 요렇게.


-------------------------------------------
send_arp 두번실행해서 속이자.

send_arp 172.16.0.3 00:06:5b:89:D0:CC 172.16.0.4 00:c0:26:5d:25:aa <-- 공격 실시

    1. send_arp  사용법 읽히고 -> widows2003 server target 잡고 mac address2
  2. fragrouter relay
3. a,c 스푸핑시키고
4.a가 c에 접속시도 ->> fragrouter -B1  에서 정보가 뜬다
5. 해본후 정상적인 상황과 스푸핑당했을때의 상황을 비교해보자.


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

arp 스푸핑 방어법

 static 으로 잡아준다! (게이트웨이 . 클라이언트 둘다)
  -> 한쪽만 잡아주면 다른한쪽은 노출되게된다..


======================================================

ip스푸핑  - 로그인없이 접속가능
 
 /etc/hosts.equiv

 

=============================================
DNS 스푸핑

 

==============================================================================================

실습.

1.필수 라이브러리

  libnet  :  응용 프로그램이 패킷을 생성하여 보낼 수 있게 해주는 라이브러리
  LIBPCAP :스니핑할때필요 - libpcap을 사용한 스니핑프로그램


설치할것 : libnet , libpcap , db ,libnids,openssl , fake , fragrouter

  




=====================================


xp (client)


ip : 192.168.200.1
mac : 00-50-56-c0-00-08


linux(hack)

ip : 192.168.200.100

mac : 00:0C:29:C4:83:EF


windows2000(server)

ip : 192.168.200.200
mac : 00-0C-29-6B-5B-33


타겟을 써놓는것을 생활하 하자 햇갈리니


-------------------------------------------------
send_arp 소스ip(client) mac주소(공격자) targetip(server) targetmac(정상적으로써준다) 
            
         -target에 가서 소스의 맥주소가 제대로 바꼇는지 확인

send_arp 소스ip(server) mac주소(공격자) targetip(client) targetmac(정상적)

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


fragroute -B1  ( 패킷 릴레이 시켜줌)

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

ethereal 이나 tcpdump를 사용해 sniffing 해보자





                      (arp snoofing 1번사진) mac 확인 (출발지 -> 공격자 )


        <arp snoofing mac 확인 (공격자 -> 도착지)

이렇듯 스푸핑을 하면 패킷이 두번씩남게된다.
  출발지 -> 공격자 -> 도착지 
            ⑴            ⑵


-----------복습하자!

by 날씨좋네요 | 2008/06/12 17:32 | 넷보안 | 트랙백 | 덧글(0)

nmap 옵션 -3일차-


 nmap 옵션


-sT : connect() 함수를 이용한 open 스캔
-sS : 세션을 성립시키지 않는 tcp syn 스캔
-sF : fin 패킷을 이용한스캔
-sN : null 패킷을 이용한 스캔
-sX : xmas패킷을 이용한 스캔
-sU : udp 포트 스캔
-sA : Ack 패킷에 대한 ttl 값의 분석

by 날씨좋네요 | 2008/06/12 14:10 | 넷보안 | 트랙백 | 덧글(0)

4일차




4일차


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




sun memory

avail.
cache area : file cache <-------fix해서 쓰지말고 자동체제로 사용하자.
=========


         Peseudo File System Managemnet

 

 

 

 

INDEX

______________

 

1. swapfs

2. tmpfs

3. fdfs

4. cachefs

5. procfs

6. mntfs

______________

 

 

 

 

 

썬에서 지원하는 파일시스템(Sun Support Filesystem)

- Disk-based Filsystem : UFS, pcfs, hsfs, udfs

- Ram-based Filesystem : swapfs, tmpfs, fdfs, ...

- Distributed Filesystem : NFS

 

 

 

 

 

0. SWAP Overview

 

SWAP

- 물리적 디스크내에 존재 하는 가상 메모리 공간

- 물리적 메모리의 연장 공간

 

 

스왑은 메모리 내의 데이터 페이지 또는 세그먼트를 교체하는 것이다. 스왑핑은 컴퓨터가

주기억장치보다 더 큰 프로그램이나 데이터 파일을 다룰 수 있게 하는 유용한 테크닉이다.

운영체계는 주기억장치 내에 가능한 한 많은 데이터를 복사해 넣고, 나머지는 디스크 상에

남겨둔다. 운영체계가 디스크에 있는 데이터를 필요로할 때, 주기억장치 내의 데이터 일부

를 디스크 상의 데이터와 교체한다. DOS는 스왑핑을 수행하지 않지만, OS/2, 윈도우, 유닉

스 등을 포함한 많은 운영체계들이 스왑핑을 수행한다. 스왑핑은 때로, 페이징이라고 불리

기도 한다.

 

유닉스 시스템에서, 스왑핑은 전체 프로세스들을 주기억장치의 안이나 또는 밖으로 옮기는

것을 말한다.

 

 

(1). SWAP Issue?

 

* 서버에 physical한 메모리가 부족하게 된 경우에는 메모리 증설에 대한 이슈 사항전에

  잠시동안 SWAP 공간을 느림으로 해서 임시 방편적인 대처를 할 수 있다.

* 일반적으로 서버에서 SWAP 공간을 많이 쓴다는 것은 서버의 Physical한 메모리가 부족

  하게 된것을 의미 한다. 하지만 이 부분의 대한 것은 서비스의 사용에 의한 Memory Leak

  일 경우도 존재 한다.

* 솔라리스에서 SWAP은 반드시 Physical Memory와 같기는 해야 한다. 일반적으로 SWAP

  Physical Memory 2배 정도가 적당하다. 그 이상이 된다면 SWP을 관리하기 위한 운영

  체제의 노력이 많이 들기 때문에 적당하지 않다.

(2). Virtual Memory?

 

 

 

(2-1). Physical RAM

 


 

 

+---------------+ --------

|               |    A

|  SWAP Files   |    |

|               |    |

+---------------+    |

|               |    |

|  SWAP Slice   |    | SWAP Space

|               |    |

+---------------+    |

|               |    |

|               |    V

|      RAM      | --------

|               |

|               |

+---------------+

 

    [그림] SWAP Space

 

 

 

 

 


 

1. SWAP 설정

 

 

스왑(SWAP)을 추가하는 방법은 2가지 형태가 있다. (a) 스왑파일을 추가하는 경우와

(b) 스왑파티션을 추가하는 방법이다. 또한 (a) 부팅시에 스왑을 적용하는 방법과

(b) 현재 스왑을 추가하는 방법이 있다.

 

- SWAP File  (: /swap/swapfile)

- SWAP Slice (: /dev/rdsk/c0t0d0s1)

 

- 부팅시에 스왑추가(/etc/vfstab 파일사용)

- 현재 스왑추가    (swap 명령어 사용)

 

 

 

(1). 현재 SWAP 파일 추가

 

SWAP 파일 설정/해제 과정

- 큰파일 생성     (: /swap/swapfile)

- SWAP ON         (: swap -a /swap/swapfile)

- SWAP OFF        (: swap -d /swap/swapfile)

- 큰파일 삭제     (: rm /swap/swapfile)

 

 

 

(1-1) 현재 SWAP 확인

# swap -l

swapfile             dev  swaplo blocks   free

/dev/dsk/c0t0d0s1   136,1      16 1049312 1049312

 

# swap -s

total: 91824k bytes allocated + 12312k reserved = 104136k used, 813800k available

 

[참고] total = used ( allocated + reserved ) + available

 

 

 

(1-2) 스왑 파일 추가

 

# mkdir /swap

# cd /swap

# mkfile 50m swapfile

# ls -l

-rw------T   1 root     other        50M  2 13 11:53 swapfile

 

# swap -a /swap/swapfile

 

# swap -l

swapfile             dev  swaplo blocks   free

/dev/dsk/c0d0s1     102,1       8 1048936 1048936

/swap/swapfile        -         8 102392 102392

 

# swap -s

total: 28420k bytes allocated + 13224k reserved = 41644k used, 851828k available

 

 

[참고] mkfile CMD

# mkfile 10[m | k | g | b] filename

 

# man mkfile

 

 

(1-3) SWAP 파일 OFF 및 파일 삭제

 

SWAP File Delete

# swap -d /swap/swapfile

 

# swap -l

swapfile             dev  swaplo blocks   free

/dev/dsk/c0d0s1     102,1       8 1048936 1048936

 

# swap -s

total: 28420k bytes allocated + 13224k reserved = 41644k used, 800632k available

 

# rm /swap/swapfile

 

 

 

(2) 부팅시에 SWAP 파일 추가

 

SWAP Add at Boot

 

# vi /etc/vfstab

#device         device          mount           FS      fsck    mount   mount

#to mount       to fsck         point           type    pass    at boot options

.....

/dev/dsk/c0t0d0s1       -       -       swap    -       no      -

.....

/swap/swapfile          -       -       swap    -       no      -

.....

 

 

(3). 현재 SWAP 파티션 추가

 

■ 스왑파티션 추가/해제 과정

- SWAP 파티션 추가         (: format)

- SWAP ON                  (: swap -a /dev/dsk/c0t1d0s0)

- SWAP OFF                 (: swap -d /dev/dsk/c0t1d0s0)

- SWAP 파티션 삭제         (: newfs /dev/rdsk/c0t1d0s0)

(3-1) 현재 스왑파티션 추가

 

SWAP slice Add

* Device Reconfiguration

* format(select slice)-/dev/dsk/c0t1d0s0

 

# swap -a /dev/dsk/c0t1d0s0

 

# swap -l

# swap -s

 

 

 

(3-2) 현재 스왑파티션 삭제/해제

 

SWAP Slice Delete

# swap -d /dev/dsk/c0t1d0s0

 

[EX] 스왑 파티션 추가(SWAP slice)

# df -k (/dev/dsk/c0t0d0s3, /data1)

# umount /data1

# swap -a /dev/dsk/c0t0d0s3

# swap -l

swapfile             dev  swaplo blocks   free

/dev/dsk/c0d0s1     102,1       8 1048936 1048936

/dev/dsk/c0d0s3     102,3       8 1024368 1024368

 

# swap -s

total: 27688k bytes allocated + 13148k reserved = 40836k used, 1365016k available

 

# swap -d /dev/dsk/c0t0d0s3

 

# newfs /dev/rdsk/c0t0d0s3

# mount /data1

 

 

 

(4) 부팅시에 SWAP 파티션 추가

 

SWAP Slice Add at Boot

# vi /etc/vfstab

/dev/dsk/c0t1d0s1      -       -       swap    -       no      -

 

 

 

 

 

[정리] SWAP Administration

Swap File

        a) 현재 Swap On/Off

                # mkfile 50m /swap/swapfile

                # swap -a /swap/swapfile

                # swap -d /swap/swapfile

                # rm /swap/swapfile

        b) 부팅시에 적용

                # mkfile 50m /swap/swapfile

                # vi /etc/vfstab(추가, 삭제)

                # rm /swap/swapfile

Swap Device(Swap Slice, Swap Partition)

        a) 현재적용

                # format

                # swap -a /dev/rdsk/c0d1s1

                # swap -d /dev/rdsk/c0d1s1

                # newfs /dev/rdsk/c0d1s1

        b) 부팅시에 적용

                # format

                # vi /etc/vfstab(추가, 삭제)

                # newfs /dev/rdsk/c0d1s1

 

 

 

 

 

[참고] 메모리 구조(Memory Structure)

 

IBM/HP/SUN Memory

File cache

Memory Leak

 

 

   <IBM Memory>

=====================

Non-Computation Area

 

=====================

Computation Area

 

=====================

 

 

   <HP Memory>

=====================

Availiable

File Cache

=====================

Used

 

=====================

 

 

   <Sun Memory>

=====================

Avail.

Cache Area

=====================

Used

 

=====================

 

 

 

[참고] UNIX 메모리 확인(시스템/프로세스)

(IBM) # topas, nmon

(HP)  # glance, top

(SUN) # prstat, sdtprocess

 

[참고] 유닉스 성능 점검 툴

- sar      system activity reporter

- vmstat   report virtual memory statistics

- iostat   report I/O statistics

- netstat  show network status

- mpstat   report per-processor or per-processor-set statistics

 

 

 

[참고] swap CMD

  


2. tmpfs(Temporrary File System)

 

   

/tmp 디렉토리

 

//tmp  디렉토리 관리하는 파일 시스템 ( temporary filesystem)

 

# df –h                       사용량        

Filesystem             size   used  avail capacity  Mounted on

/dev/dsk/c0d0s0        4.8G   2.9G   1.9G    61%    /

/proc                    0K     0K     0K     0%    /proc

mnttab                   0K     0K     0K     0%    /etc/mnttab

fd                       0K     0K     0K     0%    /dev/fd

swap                   785M    88K   785M     1%    /var/run

/dev/dsk/c0d0s4        469M   1.0M   421M     1%    /data2

/dev/dsk/c0d0s5        469M   1.0M   421M     1%    /data3

swap                   785M    12K   785M     1%    /tmp    <----- 정보 확인 //자동관리

/dev/dsk/c0d0s6        469M   1.0M   421M     1%    /data4

/dev/dsk/c0d0s7        634M   1.0M   627M     1%    /export/home

 

# modinfo | grep tmpfs

101 feae4b18   d97c  11   1  tmpfs (filesystem for tmpfs)

 

 

* /tmp

* /var/tmp

 

 

 

 

 

3. fdfs(File Descriptor Filesystem) // 파일 기술자.(파일을 구별할때스는 번호)

 

/dev/fd/#(0,1,2)     -- fd밑의 번호들을 관리한다.

 

# cd /dev/fd

# ls -l | sort -n | more

crw-rw-rw-   1 root     root     191,  0  2 14 19:06 0

crw-rw-rw-   1 root     root     191,  1  2 14 19:06 1

crw-rw-rw-   1 root     root     191,  2  2 14 19:06 2

crw-rw-rw-   1 root     root     191,  3  2 14 19:06 3

crw-rw-rw-   1 root     root     191,  4  2 14 19:06 4

crw-rw-rw-   1 root     root     191,  5  2 14 19:06 5

.....

 

# modinfo | grep fdfs

 

 98 feadef25    dac  12   1  fdfs (filesystem for fd)

 

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

fd     설명

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

0      표준 입력

1      표준 출력

2      표준 에러

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

 

 

 

 

 

 

4. cachefs(Cache Filesystem)

 

 

cachefs(Cache Filesystem)

[참고] /root/docs/SystemAdminII/6_cachefs.txt

 

* Local Cache

* Remote Cache

 

 

 

 

 

5. procfs(Process Filesystem)

 

/proc 디렉토리

 

# admintool &

# ps

admintool's PID => 450

# ls -ld /proc/450

 

admintool Termination

 

# ls -ld /proc/450

 

[참고] /root/docs/Reference/Process_CMD.txt

 

 

# modinfo | grep procfs

 38 fe9b0bc4  11195   5   1  procfs (filesystem for proc)

 

 

 

 

 

6. mntfs(Mount Filesystem)  

 

/etc/mnttab   : 마운트 테이블.

 

# cat /etc/mnttab

# mount

# df -k

 

# grep export /etc/mnttab    :: 현재마운트 정보

# umount /export/home

# grep export /etc/mnttab

 

# mount /export/home

# grep export /etc/mnttab

 

# modinfo | grep mntfs

 96 feaddea6   11d3  15   1  mntfs (mount information file system)

 

 

 

 

 

 

[참고] 원격 SWAP 마운트(Remote SWAP Usages)

 

1. NFS Server

 

Add the following line to /etc/dfs/dfstab:

# vi /etc/dfs/dfstab

share -F nfs -o rw=ClientA,root=ClientA /swap/swapfile

 

Run shareall(1M).

# shareall

 

 

 

2. NFS Client

 

Have the client add the following lines to /etc/vfstab:

# vi /etc/vfstab

ServerA:/swap/swapfile  -  /swap/swapfile  nfs  -  -  - 

/swap/swapfile          -  -               swap -  -  -

 

Have the client run mount:

# mount /swap/swapfile

 

The client can then run swap -a to add the swap space:

# swap -a /swap/swapfile

 

 

[참고] 대표적인 예

SunRay Client

Diskless Client

 

 

 

 

 

 

                  System Crash & Process Crash Administration

 

 

 

 

 

INDEX

________________

 

1. dumpadm CMD

2. coreadm CMD

________________

 

 

 

 

 

1. dumpadm CMD

 

 

솔라리스 운영체제에서 시스템 클래쉬(System Crash)가 발생하면 메모리상의 커널 영역을

파일로(Dump File 이라고 함) 저장한다. 이 파일의 분석을 통해 운영체제의 이상을 확인

하기 위해 사용될수 있다.

 

 

 

system crash? 메모리들이 오동작을 해서 운영체제의 패닉상태 ex>windows의 블루스크린

               

메모리에 이상이생김(오동작) -> swap으로 전달 -> swap slice를 사용해서 -> disk,file로 만들어놓는다.(system crash dump)      

 

        swamp >= ram  :: swap공간은 물리적공간(ram)보다 같거나 커야한다.(권장사항,기본체계)    

 

 

         ========= HOSTA ==========

 

            System Crash --+--> SWAP(: /dev/dsk/c0t0d0s1) 

                           |

                           +--> /var/crash/`hostname`/unix.X   (X : 숫자)

                                /var/crash/`hostname`/vmcore.X (X : 숫자)                          

 

  

 

 

 


이어지는 내용

by 날씨좋네요 | 2008/06/12 13:04 | 트랙백 | 덧글(0)

3일차



3일차.

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





 2.포트 ( 0~ 65535) : 0~1023 까지 1024를 well known포트라고 한다.
                             1024~65535 : 임의의 사용용도로 쓰거나 클라이언트가 서버 접속시 할당받는 포트범위이다.


-------------------------------------------------------------
 
 3.스캔  - icmp 스캔 : ping 확인.
           
   스캐너 : 빠르고 정확한게 관건

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

  udp open 스캔

   udp 패킷 으로 열린포트로 접근하면 아무런응답이없고
   udp 패킷으로 닫힌포트로 접근하면 icmp unreachable 패킷 이 되돌아 온다.

  중요한건 : 시간을 얼마나 기다리는건가 판단하는것도 중요.

---------------------------------
   tcp open 스캔
 
  열린포트 : syn ->s0yn+ack -> ack
  닫힌포트  : syn -> rst+ack

--------------------------------------
  stealth 스캔

  열린포트 : syn ->s0yn+ack -> rst       :쓰레드의 취약점을 노린 스캔
  닫힌포트  : syn -> rst+ack
-------------------------------------------
 fin ,xmas,null 스캔

 열린포트 : 응답없음
 닫힌포트 : rst 반응이 되돌아온다,


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

stealth 스캔 : 시간차 공격

 paranoid : 5분이나 10분 간격
 sneaky   : wan에서는 15초 단위로, lan에서는 5초 반위
 polite      : 0.4초 단위
 normal    : 정상
 aggressive : 호스트 타임아웃 : 5분,패킷당 1.25초 까지 응답을 기다린다.
 insane    : 호스트 타임아웃 : 75초 패킷 당 0.3초까지 응답을 기다린다.

------------------------------------------
 
port 스캔을 이용한 방법

 -특정포트에 대한 탐지를 통해 방화벽과 ids의 종류까지 알아 낼수 있다.



by 날씨좋네요 | 2008/06/11 14:51 | 넷보안 | 트랙백 | 덧글(0)

3일차




3일차


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

           

     
Network Service Type

 




 1
. Clinet-Server Model

________________________

 

서버는 서비스를 제공하는 호스트 또는 프로세스를 나타내고 클라이언트는 서비스를 제공

받는 호스트 또는 프로세스를 나타낸다.

 

(a). Client?

The client is a host or a process that uses services form another program known as

a server.

 

(b). Server?

The server is a host or a process that provides services to another program known as

a client.

 

 

 

====[Client]====        ====[Server]====

 

# telnet B 23           in.telnetd(23)

(Client Program)  (Server Process)

 

                        # telnet localhost 23 (Client Process)

 

 

          [그림] 서비-클라이언트 모델

 

 

 

 2. Server Service type

_________________________

 

솔라리스 운영체제에서 네트워크에서 다른 호스트에게 서비스를 제공하는 방법에는 두가지

가 존재한다. (a)Inetd 방식은 서버용 데몬을 띄워 놓지 않고 inetd 데몬에 의해 관리되는

방식을 말하고 (b)Standalone 방식은 단독으로 서비스 데몬이 떠서 서비스 하는 방식을 말

한다.

 

네트워크 서비스 종류

inetd 서비스 방식

standalone 서비스 방식

 

 

 

(1). inetd 서비스 동작 방식

 

The inetd daemon is a special network process that runs on each system and starts

server processes that do not automatically start at boot time.

The inetd daemon is the server process for both the standard Internet services and

Sun Remote Procedure Call (Sun RPC) services. The inetd daemon starts at boot time

using the /etc/rc2.d/S72inetsvc script. A configuration file lists the services that

the inetd daemon will listen for and start in response to network requests. If you

do not specify a configuration file, the inetd daemon uses the default

/etc/inet/inetd.conf file.

 

 

Inetd 방식의 서비스는 요청이 잦지 않는 경우에 유리하다.

 

 

====[Client]====        ====[Server]====

# telnet B 23           in.telnetd(23)

# ftp B 21              in.ftpd(21)

               inetd

             /etc/inetd.conf

             /etc/services

 

    [그림] inetd 방식의 서비스

 

 

 

(2). Standalone 서비스 동작 방식

 

Standalone 방식의 서비스는 요청이 잦은 경우에 유리하다.

 

 

====[Client]====        ====[Server]====

http://web request      httpd(80)

 

    [그림] Standalone 방식의 서비스

 

 

 

(3) inetd 방식의 서비스

 

inetd(슈퍼데몬이라고도 불림) 데몬이 읽어 들이는 파일은 /etc/inetd.conf, /etc/services

파일이다. /etc/inetd.conf, /etc/services 파일은 부팅시에 읽혀지는 파일이므로 이 파일

을 수정한 후 inetd에 의해 적용되기 위해서는 inetd 데몬을 restart(stop/start) 시켜야

한다.

 

inetd 데몬이 읽어 들이는 파일

/etc/inetd.conf

/etc/services

 

  

(3-1). /etc/inetd.conf(/etc/inet/inetd.conf)

 

# vi /etc/inetd.conf

.....

telnet  stream  tcp6    nowait  root    /usr/sbin/in.telnetd    in.telnetd

ftp     stream  tcp6    nowait  root    /usr/sbin/in.ftpd       in.ftpd -a

.....

 

# man inetd.conf

....

      

[참고] By specifying a protocol value of tcp6 or udp6 for a service, the inetd daemon

passes the given daemon an AF_INET6 socket. The following daemons have been modified

to accept AF_INET6 sockets and service connection requests coming from either IPv4 or

IPv6-based transports: ftp, telnet, shell, login, exec, tftp, finger, and printer.

Modified services do not usually require separate configuration lines for tcp or udp.

 

 

 

(3-2). /etc/services(/etc/inet/services)

 

# vi /etc/services

.....

ftp             21/tcp

telnet          23/tcp

.....

 

 

  

3. Practice

______________

 

 

(EX1) Inetd 방식 테스트

 

ftp, telnet은 대표적인 inetd 방식의 서비스들이다. in.ftpd, telnetd 데몬은 서비스 요

청이 있지 않으면 떠 있지 않는다. 하지만 서비스 요청이 있게 되면 데몬이 뜨게 된다.

 

[TERM1] 관리자 윈도우

# ps -ef | grep in.ftpd   (# pgrep -lf in.ftpd)

# ps -ef | grep inetd     (# pgrep -lf inetd)

 

[TERM2] 사용자 윈도우

# ftp localhost

user01 사용자로 로그인

 

[TERM1] 관리자 윈도우

# ps -ef | grep in.ftpd

 

 

 

(EX2) Inetd 방식의 서비스 접근 제어

 

inetd 방식의 서비스 접근제어에서는 /etc/inetd.conf 파일의 서비스의 이름부분 앞에 주

(#) 처리를 하게 되면 서비스를 연결할수 없게 되므로 서비스를 차단할수 있다. 또한

/etc/inetd.conf 파일의 주석(#) 처리를 제거하면 서비스는 다시 개시된다.

 

 

====[Client]====                   ====[Server]====

# ftp B 21         inetd           in.ftpd(21)

                   /etc/inetd.conf

                     # ftp -----

              

      

 

             [그림] inetd 방식의 서비스

 


# vi /etc/inetd.conf

.....

[수정전]

ftp     stream  tcp6    nowait  root    /usr/sbin/in.ftpd       in.ftpd -a

[수정후]

#ftp     stream  tcp6    nowait  root    /usr/sbin/in.ftpd       in.ftpd -a

A

+----- (주석처리)

 

# ftp localhost

Connected to localhost.

220 solaris254 FTP server ready.

Name (localhost:root): user01     <----- 'user01' 입력

331 Password required for user01.

Password:                         <----- 사용자 암호 입력

230 User user01 logged in.

Remote system type is UNIX.

Using binary mode to transfer files.

ftp> quit                         <----- 'quit' 입력

221-You have transferred 0 bytes in 0 files.

221-Total traffic for this session was 231 bytes in 0 transfers.

221-Thank you for using the FTP service on solaris254.

221 Goodbye.

#

 

=> 접근이 가능하다. 이것은 /etc/inetd.conf 파일을 수정한 후에 적용시키지 않았기 때문

   이다.

 

# pkill -1 inetd

# ftp localhost

ftp: connect: Connection refused  <----- 메세지 확인

ftp> quit                         <----- 'quit' 입력

#

 

=> 접근이 가능하지 않는다.

 

 

 

[참고] 서비스 종류에 따른 접근 제어

Standalone 방식은 데몬을 띄우면 서비스가 되고 데몬을 띄우지 않으면 서비스가 닫히게 된

. inetd 방식은 /etc/inetd.conf 파일을 사용하여 주석처리를 통해 서비스 접근 제어를

하게 된다.

 

서비스 접근 제어(Service Access Control)

Standalone 방식: 데몬을 종료/시작  (: /etc/init.d/apache stop/start)

inetd      방식: /etc/inetd.conf 주석사용

 

[EX] Standalone 방식의 서비스 접근 제어

# cd /etc/apache

# cp httpd.conf-example httpd.conf

# /etc/init.d/apache start

# ps -ef | grep httpd

Window Web Browser : http://192.168.10.XXX -----> 웹페이지가 보임

 

# cd /var/apache/htdocs

# cat > index.html

Hello, Solaris

WelcometoMyServer

<Ctrl + D>

Window Web Browser : http://192.168.10.XXX -----> 웹페이지가 보임

 

# /etc/init.d/apache stop

# ps -ef | grep httpd

Window Web Browser : http://192.168.10.XXX -----> 웹페이지가 안 보임

 

 

 

(EX3) inetd 방식의 FTP 서비스 포트 변경

 

inetd 서비스에 대해 서비스 포트를 변경하기 위해서는 /etc/services 파일을 사용한다.

아래 예제와 같이 FTP의 서비스 포트를 2121번으로 변경하면 외부에서 FTP로 접속할 당시

FTP 포트를 2121로 지정해야 한다. 이런 경우에는 몇명의 사용자만이 FTP 서비스를 사

용하기 위해서 포트를 변경하는 경우이다.

 

 

===== HOSTA ======          ===== HOSTB =====

 /etc/services                 /etc/services

 

(a) ftp 21/tcp                  ftp 21/tcp

# ftp HOSTB 21                  in.ftpd(21)

 

(b) ftp 21/tcp                  ftp 2121/tcp

# ftp HOSTB 2121 ----- O ---->  in.ftpd(2121)

# ftp HOSTB 21   ----- X ---->  in.ftpd(2121)

 

      [그림] FTP 서비스 포트 변경

 

 

# vi /etc/inetd.conf

.....

[수정전]

#ftp     stream  tcp6    nowait  root    /usr/sbin/in.ftpd       in.ftpd -a

[수정후]

ftp     stream  tcp6    nowait  root    /usr/sbin/in.ftpd       in.ftpd -a

 A

 +----- 주석 제거

 

# pkill -1 inetd

 

# vi /etc/services

.....

[수정전]

ftp      21/tcp

[수정후]

ftp      2121/tcp

 

# pkill -1 inetd

 

# ftp localhost 21

ftp: connect: Connection refused   <----- 메세지 확인

ftp> quit                          <----- 'quit' 입력

 

# ftp localhost 2121

Connected to localhost.

220 solaris254 FTP server ready.

Name (localhost:root): <Ctrl + C>  <----- <Ctrl + C> 입력

#

 

(복구 작업)

/etc/services 파일의 FTP 포트 번호 복구(2121->21)

 

 

 

(EX4) 서버용 포트 & 클라이언트 포트의 상관 관계

 

서버와 클라이언트 프로세스가 서로 통신하게 되면 서버의 포트는 잘 알려진 포트(Well-

Kown Port)를 사용하게 되고, 클라이언트 포트는 임의의 포트를 사용하게 된다.

 

# telnet 172.16.8.254

root 사용자로 로그인

 

# netstat -an | grep EST | grep 172.16.8.XXX

<LocalAddr.port>           <RemoteAddr.port>          <Status>

172.16.8.254.23   172.16.8.XXX.32187         ESTABLELISHED

 

[Server Port] 잘 알려진 포트(Well-known port)

[Client Port] 임의의 포트(Arbitrary port)

 

[참고] Reference in the /root/docs/SystemAdminII/2_portnumber.txt file.

 

 

by 날씨좋네요 | 2008/06/11 12:54 | solar2 | 트랙백 | 덧글(0)

◀ 이전 페이지          다음 페이지 ▶