Assnigment#1
Assnigment#1
Objectives
In this Assignment, you will use Scapy, a Python-based packet manipulation tool, to craft custom
packets. These custom packets will be used to perform reconnaissance on a target system.
Background / Scenario
Penetration testers and ethical hackers often use specially crafted packets to discover and/or exploit
vulnerabilities in clients’ infrastructure and systems. You have used Nmap to scan and analyze
vulnerabilities in a computer attached to the local network.
In this assignment, you will perform further reconnaissance on the same computer using custom
ICMP and TCP packets.
Required Resources
Kali VM customized for Ethical Hacker course
Internet Access
Instructions
Part1: Investigate the Scapy Tool
Scapy is a multi-purpose tool originally written by Philippe Biondi. In this part, you will load the Scapy
tool and explore some of its capabilities. Tools like Scapy should only be used to scan or communicate
with machines that you own or have written permission to access.
Question
How does the author describe the capabilities of Scapy in the first paragraph of the page?
a) The commands to craft and send packets require root privileges to run. Use the sudo su
command to obtain root privileges before starting Scapy. If prompted for a password, enter kali.
b) Load the Scapy tool using the scapy command.
c) At the >>> prompt within the Scapy shell, enter the ls() function to list all of the available
default formats and protocols included with the tool. The list is quite extensive and will fill
multiple screens.
TFTP is a protocol used to send and receive files on a LAN segment. It is commonly used to
back up configuration files on networking devices. Scroll up to view the available TFTP packet
formats.
Question:
How many types of TFTP packet formats are listed?
Step3: Examine the fields in an IPv4 packet header.
a) It is important to understand the structure of an IP packet before creating and sending custom
packets over the network. Each IP packet has an associated header that provides information
about the structure of the packet. Review this information before continuing with the lab.
a. Use the sniff() function to collect traffic using the default eth0 interface of your VM. Start the
capture with the sniff() function without specifying any arguments.
>>> sniff()
b. Open a second terminal window and ping an internet address, such as www.cisco.com.
Remember to specify the count using the -c argument.
┌──(kali㉿kali)-[~]
c. Return to the terminal window that is running the Scapy tool. Press CTRL-C to stop the
capture. You should receive output similar to what is shown here:
Copy answer
d. View the captured traffic using the summary() function. The a=_ assigns the variable a to hold
the output of the sniff() function. The underscore ( _ ) in Python is used to temporarily hold the
output of the last function executed.
>>> a=_
>>> a.summary()
The output of this command can be extensive, depending on the applications running on the
network.
a. Open a new terminal window. Use the ifconfig command to determine the name of the
interface that is assigned the IP address (10.6.6.1) you can change depend on your machine.
This is the default gateway address for one of the virtual networks running inside Kali. Note
the name of the interface.
b. Return to the terminal window that is running the Scapy tool. Use the syntax
sniff(iface="interface name") to begin the capture on the br-internal virtual interface.
>>> sniff(iface="br-internal")
c. Open Firefox and navigate to the URL http://10.6.6.23/. When the Gravemind home page
opens, return to the terminal window that is running the Scapy tool. Press CTRL-C. You
should receive output similar to:
>>> a=_
>>> a.summary()
a. Use interface ID associated with 10.6.6.1 (br-internal) to capture ten ICMP packets sent and
received on the internal virtual network. The syntax is sniff(iface="interface name", filter =
“protocol", count = integer).
┌──(kali㉿Kali)-[~]
>>> a=_
>>> a.nsummary()
The summary should only contain 10 lines because the capture count is equal to 10.
Question
What traffic is displayed in the output of the nsummary() function?
d. To view details about a specific packet in the series, refer to the blue line number of the packet.
Do not include the leading zeros.
>>> a[2]
The detailed output shows the layers of information about the protocol data units (PDUs) that
make up the packet. The protocol layer names appear in red in the output. Examine the source
(src) and destination (dst) addresses as well as the raw data (load=) portion of the collected
packet.
Question:
Why are there two sets of source and destination fields?
e. Use the wrpcap() function to save the captured data to a pcap file that can be opened by
Wireshark and other applications. The syntax is wrpcap(“filename.pcap", variable name), in
this example the variable that you stored the output is “a".
>>> wrpcap(“capture1.pcap", a)
f. The .pcap file will be written to the default user directory. Use a different terminal window to
verify the location of the capture1.pcap file using the Linux ls command.
>>> sniff(iface="br-internal")
b. Open another terminal window, enter sudo su to perform packet crafting as root. Start a second
instance of Scapy. Enter the send() function to send a packet to 10.6.6.23 with a modified ICMP
payload.
┌──(kali㉿kali)-[~]
└─$ sudo su
┌──(root㉿kali)-[/home/kali]
└─# scapy
>>> send(IP(dst="10.6.6.23")/ICMP()/"This is a test")
Response
Sent 1 packet
c. Return to the first terminal window and press CTRL-C. You should receive a response similar
to this:
d. Enter the summary command to display the summary with packet numbers.
>>> a=_
>>> a.nsummary()
Question:
Question
What is the difference between the original ICMP packet conversation and the custom ICMP
packet conversation?
Part4: Create and Send a TCP SYN Packet.
In this part, you will use Scapy to determine if port 445, a Microsoft Windows drive share port, is open
on the target system at 10.6.6.23.
b. Navigate to the second terminal window. Create and send a TCP SYN packet using the
command shown.
This command sent an IP packet to the host with IP address 10.6.6.23. The packet is addressed
to TCP port 445 and has the S (SYN) flag set.
a. In the original Scapy terminal window, stop the packet capture by pressing CTRL-C. The
output should be similar to that shown.
b. View the captured TCP packets using the nsummary() function. Display the details of the TCP
packet that was returned from the target computer at 10.6.6.23.
Question:
What does the SA flag indicate in the packet returned from 10.6.6.23?
Due date:
➔➔ The deadline for submitting Your activity is Oct 23rd, 2024, at 11:59PM. After that
date no submission will be evaluated.
1- You need to submit screen shots that show you solve the task.