Tag: tcpdump

  • IPv4

    Lab 1.4 – IPv4 Packet Analysis

    This lab focused on examining network traffic at the IPv4 layer, with an emphasis on identifying abnormal or suspicious behavior within the packet capture.

    Lab Setup

    For this exercise, I used the capture file called ipv4.pcap.

    Once downloaded, I opened the file in Wireshark and began my analysis.

    Exercise 1 – Analyzing the First IPv4 Packet

    a) What version of IP is the first packet?

    We can find this either by looking at the Ethernet header or the IP header. Looking at the IP Header, the IP version is located in the higher-order nibble of the 0 byte offset. We can see there that this is an IPv4 packet.

    b) What is the IP Time To Live value, in decimal, in this packet?

    To answer this, I examined the IPv4 header of the first packet in the ipv4.pcap file. I specifically looked at the Time To Live (TTL) field, which determines how many hops (routers) the packet can pass through before being discarded.

    The TTL field is located 8 bytes into the IP header, but Wireshark conveniently displays this value directly in the decoded packet details. In this case, the TTL value was 64, which is a common default for Linux-based systems.

    This value can also give clues about the operating system or network behavior based on how far the packet has traveled.

    c) What is the source IP address, in hexadecimal, in the first packet?

    To find the source IP address in hexadecimal, I examined the IPv4 header in the first packet of the ipv4.pcap capture. The source IP address is located between bytes 12 and 15 from the start of the IP header.

    Wireshark makes this easy by displaying both the decimal and hexadecimal representations. For the first packet, the source IP is 192.168.11.65 in decimal, which corresponds to 0xc0 0xa8 0x0b 0x41 in hexadecimal.

    d) What is the destination IP address, in hexadecimal, in the first packet?

    To find the destination IP address in hexadecimal, I examined the IPv4 header of the first packet in the ipv4.pcap file. According to the IP header structure, the destination IP is stored between bytes 16 and 19 from the start of the IP header.

    Wireshark clearly shows this value in both hexadecimal and decimal. In this case, the destination IP is 192.168.1.1, which corresponds to the hexadecimal representation 0xc0 0xa8 0x01 0x01.

    Exercise 2 – Identifying Abnormalities in the IPv4 Header

    In this exercise, I examined the second packet in the ipv4.pcap capture and identified two key problems with its IP header.

    Problem 1: Invalid IP Version
    The first issue is that the IP header lists version 8, which is not a valid or supported IP version. Only versions 4 and 6 are in use today. Because of this, Wireshark marks the packet in red and does not attempt to decode it further.

    Problem 2: Invalid Header Checksum
    After inspecting the raw packet bytes, I found another issue in bytes 10 and 11, which represent the IP header checksum. The value was 0x0000, which is invalid and indicates the packet may have been corrupted or crafted improperly.

    Impact
    Both of these abnormalities would cause the packet to be dropped immediately by the first router or system it attempts to pass through. This exercise helped me understand how malformed packets are detected and discarded at the network layer.

    Exercise 3 – Hex Analysis Using tcpdump

    In this part of the lab, I used the tcpdump command-line tool to inspect raw packet data and answer questions related to the third packet in the ipv4.pcap capture.

    To extract the first few packets in hexadecimal format, I ran:

    a) What version of IP is this packet? What is the header length if the packet ?

    By looking at the raw hexadecimal output of the third packet, I found it starts with the byte 0x45. This first byte breaks down into two nibbles:

    • 4 → IP version
    • 5 → header length

    So, the version number of this packet is IPv4, as indicated by the high-order nibble of the first byte.

    The header length field is in units of double word so it has to be multiplied by 4 to be converted to a length of 20 bytes.

    b) What is the embedded protocol in this packet, according to the IP header?

    To determine the embedded protocol, I examined byte offset 9 in the IP header of the third packet. This byte indicates which protocol is encapsulated within the IPv4 packet.

    Using the tcpdump output, I located the value at this offset. For this packet, the value was 0x01, which corresponds to ICMP (Internet Control Message Protocol).

    Exercise 4 – Calculating ICMP Header and Data Length

    In this task, I analyzed the fourth packet in the ipv4.pcap file to determine how many bytes were used by the ICMP header and data, following the IPv4 header.

    To do this, I used two values from the IP header:

    • Total Length: 68 bytes (it is found in the 3rd byte offset of the IP Header // it has a hexadecimal value of 0x44)
    • Header Length: 20 bytes (which is shown as a value of 5 in the header, multiplied by 4)

    By subtracting the IP header length from the total IP datagram size:
    68 - 20 = 48 bytes

    So, the ICMP header and data together occupy 48 bytes in this packet.

  • Concepts of TCP/IP

    Objective:
    In this lab, I explored various aspects of the TCP/IP protocol by using tcpdump to analyze network traffic. The goal was to familiarize myself with the functionality of tcpdump and practice using its command-line options to read and interpret packet capture files.

    Exercise 1: Reading a PCAP File
    The first exercise involved using tcpdump to read a packet capture file named concepts.pcap. The objective was to analyse the contents and identify the number of recorded packets. I utilized the following command to read the file:

    Six records are displayed:

    Exercise 2: Reading Specific Records from a PCAP File

    Objective:
    In this exercise, I practiced using tcpdump to read a specified number of records from a packet capture file. The goal was to extract and display the first two records from the file concepts.pcap efficiently as well as identify the source IP address of the second record .

    Command Explanation:
    To achieve this, I used the following tcpdump command:

    • The -c 2 option instructs tcpdump to limit the output to the first two records.
    • The -t option suppresses the display of timestamps, making the output more concise.
    • The -n option ensures that IP addresses are displayed as numerical values rather than being resolved to hostnames.
    • The -r option specifies that tcpdump should read from the file rather than capturing live traffic.

    These options can be combined in a single command for efficiency.

    The second source IP address is 192.168.11.13 which is found here:

    Exercise 3: Displaying Network Records in Hexadecimal

    Objective:
    In this exercise, I learned how to use tcpdump to read a single record from a packet capture file and display it in hexadecimal format. This technique is useful when analyzing raw packet data for low-level protocol analysis. I am also asked to identify the first two bytes seen on the hex dump for the first record, the IP protocol field value and the TTL located the IP header.


    Command Explanation:
    To view the first record from the file concepts.pcap in hexadecimal format, I used the following command:

    The -x option displays the packet data in hexadecimal format.

    Regarding the first two bytes question: A hexadecimal character represents 4 bits (or a nibble), so a byte corresponds to 2 hexadecimal characters. The first two bytes are 0x45 and 0x00, respectively.

    The IP protocol field value is 0x01. It is a one-byte field located in the 9th byte offset from the beginning of the IP header. This tells us that the embedded transport protocol is ICMP.

    The TTL is located in the 8th byte offset from the beginning of the IP header and like the IP protocol field is a one-byte field. it is equal to 0x40 or 16*4 + 1*0 = 64 in decimal value.

    Exercise 4: Displaying MAC/Ethernet Addresses from a PCAP File

    Objective:
    In this exercise, I practiced using tcpdump to display the MAC (Media Access Control) addresses from a packet capture file. The goal was to read the first record from the file concepts.pcap and identify both the source and destination MAC addresses.


    Command Explanation:
    To display the MAC addresses from the first record, I used the following command:

    The -e option displays the link-layer (MAC/Ethernet) headers, showing both source (00:04:00:0a:04) and destination (00:0c:29:03:23:19) MAC addresses.

    The -v option increases the verbosity of the output, providing more detailed information about each packet. I can easily identify the ethertype which indicates which protocol follows the ethernet header (in this case it is IPv4). I can also quickly see that the protocol following the IP header is ICMP (It can be seen in the “proto” field).

    Exercise 5: Analyzing DNS Traffic in UDP Packets

    Objective:
    In this exercise, I analyzed DNS traffic captured in a PCAP file using tcpdump. The goal was to identify the type of activity and data within specific UDP packets, focusing on DNS queries and responses.

    Using the same command as in the last exercise, we can see the following two packets:

    The output displayed two consecutive UDP packets related to DNS activity:

    1. Source and Destination:
      • Source IP: 192.168.11.65, Source Port: 52894
      • Destination IP: 192.168.11.53, Destination Port: 53 (DNS port)
    2. Packet Details:
      • The first packet contains a DNS query (A? giac.org.), indicating that the client is requesting the IP address for the domain giac.org.
      • The second packet contains the DNS response, indicating that the server resolved giac.org to the IP address 66.35.45.203.
      • Both packets use the UDP protocol (proto UDP (17)).
      • The length of the first packet is 54 bytes, while the response packet is 70 bytes.

    Analysis:
    The presence of port 53 in the packet indicates DNS traffic. The query type (A?) specifies that the client is requesting an IPv4 address for the domain giac.org. The response from the DNS server includes the resolved IP address, confirming that the communication was successful.