You are on page 1of 4

CSCI369 Ethical Hacking

This material is copyrighted. It must not be


C distributed without permission from
Joonsang Baek and Jongkil Kim

Lab 3
Scanning & ARP Spoofing

1. Boot up Kali and Metasploitable VM.

Kali and Metasploitable will be used as an attacker’s machine and a target


machine, respectively. Metasploitable is purposely set up as vulnerable.

Check the connections between two VMs. You can use ifconfig to check
the IP addresses and use ping to check the connectivity.

2. Using fping
fping is a tool for ping sweep.

(a) Run fping –h or fping –h|less to know about available options.

(b) Run fping –g 10.0.2.1 10.0.2.10


(change the range to include the Metasploitable VM IP address)

3. Basics of Nmap

As we have learnt, Nmap is the most popular scanning tool. This exercise is
to familiarize yourself with nmap commands. Use –v to get more detailed
results.

(a) To view the help page of nmap, type nmap –h


To view it page by page run nmap –h | less

(b) Go to Kali, try SYN (-sS) FIN (-sF), and Xmas (-sX) scans using the nmap
against the Metasploitable. What results did you get? Did you anticipate
the results?

(c) Go to Kali, try to perform the UDP (-sU) scan against the Metasploitable.

4. Additional Nmap commands

(a) Say, you want to adjust timing for your scanning. What option would you
use? Try to give some values for your mode: -T0 or –T1 You may realize
that mode 0 and 1 will take too much time so that you have to stop it
using ctrl+c.

(b) Save your result to a text file. Use –oN file1.txt

1
CSCI369 Ethical Hacking
This material is copyrighted. It must not be
C distributed without permission from
Joonsang Baek and Jongkil Kim

5. Ack scan using Nmap (Find filtering examples)

(a) Go to Metasploitable. Get the IP address of it. Enable the firewall and
block all ports.
a. Set the default of firewall is DENY
$ sudo ufw default DENY
b. Turn on the firewall
$ sudo ufw enable
c. Check whether the firewall is working or not
$ sudo ufw status

(b) Go to Kali. Then run nmap –sA -v <IP address of


Metasploitable> What are the results of your scan? What does –sA
mean?

(c) Go to Metasploitable, again. Turn off the firewall.


d. Set the firewall down
$ sudo ufw disable
e. Check whether firewall is working or not
$ sudo ufw status

(d) Go to Kali. Try TCP Ack Scan on Metasploitable, again. What are the
results of your scan? What is the different from previous scan?

(e) Go to Metasploitable, again. Enable the firewall, but allow port 80.
a. Set the firewall up
$ sudo ufw enable
b. Add rule to allow port 80 and check whether the status of the
firewall
$ sudo ufw allow 80/tcp
$ sudo ufw status
c. Additionally, you can check the port 80 by browsing http://<IP
address of Metasploitable> at Kali

(f) Go to Kali, try FIN (-sF) scan using the nmap against the Metasplotiable.
Can you distinguish port 80 from the other ports? Let compare the result
with Ack (-sA) and SYN (-sS) scan.

(g) Go to Metasploitable, again. Turn off the firewall.


a. Set the firewall down
$ sudo ufw disable
b. Check whether firewall is working or not
$ sudo ufw status

2
CSCI369 Ethical Hacking
This material is copyrighted. It must not be
C distributed without permission from
Joonsang Baek and Jongkil Kim

6. OS fingerprinting (Remote OS Detection)

OS finger printing is when attacker sends a series of TCP and UDP packets to
the remote host and examines practically every bit in the responses. After the
tests the results are compared against the general behaviour of Operating
Systems for a match.
Nmap is the most popular active OS detection tool. Nmap probes a target with
large number of well crafted packets and the results are compared against
Nmap’s database of OS fingerprints (nmap-os-db).

Try to find the version of your Metasploitable using Nmap. For example, if IP
address of Metasploitable is 10.0.2.5, you can use the following command:

nmap -v -O 10.0.2.5
(Tip: You can check the version of Metasploitable by using “uname –a” in
Metasploitable.)

7. Scanning with Scapy


An advanced (stealthy) tool for creating and sending crafted packets and
displaying responses from the target, Metasploitable.

(a) (Recap) We can create and test TCP packet with various flags.
Examples: (let the IP address of Metasploitable VM is 10.0.2.5)
i. Crafting a TCP packet with a SYN flag
>>> IP(dst=“10.0.2.5”)/TCP(dport=80,flags=“S”)
ii. Crafting a TCP packet for NULL flag
>>> IP(dst=”10.0.2.5”)/TCP(dport=80,flags=0x00)
(b) The hexadecimal number is useful to set the flags. The first number
represents the first 4 bits and the second number represents the next 4
bits. For example, in Xmas scan fin, psh and urg have to be set.
[cwr|ece|urg|ack|psh|rst|syn|fin]
[ 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 ] → 0x29
>>>sr1(IP(dst=“10.0.2.5”)/TCP(dport=80,flags=0x29))

(c) Multiple ports scan


i. By range:
>>> sr1(IP(dst=“10.0.2.5”)/TCP(dport=(80,84),flags=0x10))
ii. By list:
>>> sr1(IP(dst=“10.0.2.5”)/TCP(dport=[80,84],flags=0x10))

8. Performing ARP Poisoning using arpspoof

We first need to gather some information about our network. On Kali VM,
run arp –a and see what happens. You may get information about machines
attached to your network interface, which is usually “eth0”. Pay attention to
IP address and HW address (MAC address) of each machine. If “gateway” is
not shown, run route –n and get IP address of the gateway. Write down the
IP address and MAC address of the gateway. Also, find out IP address and

3
CSCI369 Ethical Hacking
This material is copyrighted. It must not be
C distributed without permission from
Joonsang Baek and Jongkil Kim

MAC address of Metasploitable VM. Once you have done this, make sure you
have three terminal windows on Kali VM.
Before set-up,

(a) Turn on wireshark in Kali and capture the traffic on eth0 interface.
(b) Send ping to www.google.com in Metasploitable. Let Metasploitable
continuously send ping to www.google.com.
(c) Check wireshark in Kali. Can you see the ping (ICMP message) from
Metasploitable?

Set ip_forward enable, type


$ echo 1 > /proc/sys/net/ipv4/ip_forward
(Here, be careful about a space between “echo”, “1” and “>” . You can check
the value is set successfully by typing the following command. The output
must be 1:
$ head /proc/sys/net/ipv4/ip_forward

On the first terminal window, type (do not press enter)


$ arpspoof –i eth0 –t <IP of Metasploitable > <IP of Gateway>

On the second terminal window, type (do not press enter)


$ arpspoof –i eth0 –t <IP of Gateway> <IP of Metasploitable >

Press enter for both terminals.

Now go back to Metasploitable terminal and type arp –a. What is the MAC
address of the gateway?

(d) Observe the Wireshark on Kali and check whether you can see the ping
message from Metasploitable.

After you have done the task, press ctrl+c on the two terminals running
arpspoof to exit. (You may have to press enter a few times.)

You might also like