Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The goal of this assignment is to generate a . pcap file containing 1 2 packets based on the given . pcap in given picture
The goal of this assignment is to generate a pcap file containing packets based on the given pcap in given picture You must use Scapy in Python to
construct and append each packet, then write the full set of packets to a pcap file that can be analyzed using TShark or Wireshark. The pcap file that you
generate must contain the same number of packets in the same order with identical fields, identical values for each field including payloads where necessary and
identical timestamps for each packet as seen in the pcap file that you were given in the picture And one of the
packets will be DNS
which is either TCP
UDP To be clear, you should NOT simply duplicate or copy packets from the existing pcap file. Your code must programmatically construct new packets, starting from the Ethernet layer and building up through TCPUDPDNS similar to the sample example shown in the provided document. This approach is required to demonstrate your understanding of how to build valid network packets. The following is a sample example of how to use Scapy to generate a pcap file with a single packet.
# Import Scapy
from scapy.all import Ether, IPv UDP, rdpcap, wrpcap
# Create a new packet stacked with Ether, IPv UDP, and a payload
packet Ethersrc dst
IPvsrc dst
UDPsport dport
# Write the pcap file
wrpcappcap', packet
Use ls to list all the available layers and lsIP to list all the available fields for the IP layer. For instance:
# List available Scapy layers
ls
# Sample output
Layer :: Ether, Dot LLC SNAP
Layer :: IP IPerror, IPy, GRE
Transport :: TCP UDP
Packet :: Packet, bindlayers code in python
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started