In this lab, our goal is to attack a local DNS server. We will first set up an environment with the following two machines. Then, with our attacks, we will change the IP address of the domain info.cern.ch:

Before attack

The picture below shows the real page of http://info.cern.ch with Firefox on the user machine (it432a).

After attack

The picture below shows a fake page of http://info.cern.ch with Firefox on the user machine (it432a). It actually shows the web content of the attacker's web server.

Now, let's start with setting up the environment.

[10pts] Part 1: Disabling DNSSEC and Checking a Real Webpage

On the user machine (it432a), change the setting of Firefox as follows:

Submit

In the lab report:

[10pts] Part 2: Setting Up the User Host (it432a)

We need to set up the user machine it432a so that its local DNS server is it432b. In particular, in it432a, perform the following steps.
  1. In a terminal, execute the following command.
    sudo nmcli con edit "Wired connection 1" 
    
  2. In the interactive shell of nmcli, run the following commands one-by-one.
    print
    set ipv4.ignore-auto-dns yes
    set ipv4.dns 192.168.172.5
    save 
    quit
    
  3. In a terminal, execute the following command.
    sudo service NetworkManager restart
    

Submit

To check whether this configuration is successful, run the following command in a terminal:
nmcli dev show | grep DNS
Give the results of the above command in the lab report to show that your work is successful.

[15pts] Part 3: Setting Up the Local DNS Server (it432b)

In it432b, we will install and set up bind9 program for the DNS service.
  1. Install bind9:
    sudo apt update
    sudo apt install bind9
  2. Change /etc/bind/named.conf.options as follows:
  3. Flush the DNS cache and retart the DNS server.
    sudo rndc dumpdb -cache
    sudo rndc flush
    sudo service bind9 restart

Power of the firewall at USNA

The firewall filters out all outgoing DNS requests. Try the following: You will see a timeout error. Host4 sent a DNS request to it432b, and it432b sent a DNS request to the root DNS server, but the reply will never come back.

Submit

Run the above dig command from it432a and show that it times out.

[40pts] Part 4: Spoofing the DNS Response to User

In this part, you (as an attacker) are supposed to create and send a fake DNS answer to the user's DNS requests. In particular,
  1. In the attacker machine (i.e., it432c), sniff DNS requests from the user machine (i.e., it432a).
  2. Given a DNS request from the user machine, create a fake response to the following domain name:
     info.cern.ch 
    The actual IP address is 188.184.21.108, but set the IP address in your fake response to the following:
     192.168.172.6 
    Note that this is the IP address of the attacker machine (i.e., it432c).
The execution result in it432a should look as follows:
it432a
choi@it432a:~$ sudo systemd-resolve --flush-cache
choi@it432a:~$ dig info.cern.ch

; <<>> DiG 9.16.1-Ubuntu <<>> info.cern.ch
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2294
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;info.cern.ch.			IN	A

;; ANSWER SECTION:
info.cern.ch.		86400	IN	A	192.168.172.6

;; Query time: 71 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Sat Aug 06 03:03:41 EDT 2022
;; MSG SIZE  rcvd: 57

Notes

Submit

[10pts] Part 5: Showing a Fake Webpage in a Web Browser

Submit

In the lab report:

[15pts] Part 6: Lab Report and Submission

~/bin/submit -c=IT432 -p=lab03 lab03_report.doc *.py

Recovering to the original setup

In it432a, perform the following steps.
  1. In a terminal, execute the following command.
    sudo nmcli con edit "Wired connection 1" 
    
  2. In the interactive shell of nmcli, run the following commands one-by-one.
    print
    set ipv4.ignore-auto-dns no
    set ipv4.dns 
    save 
    quit
    
  3. In a terminal, execute the following command.
    sudo service NetworkManager restart