wireshark & tcpdump
Packets refer to the data sent across a network when our devices communicate with servers or each other. These two packet sniffer tools are useful for analyzing packets on our interfaces.
To start. Wireshark is the graphical interface version we can use to sniff packets and tcpdump is the command line interface we can use. Tcpdump is generally faster and less resource-consuming than wireshark, however it’s less efficient at analyzing packets than wireshark and we can’t see as much information.
what are packets? and what does sniffing them mean?
Packet sniffing is essentially just intercepting packets so we can understand more about what our interface is interacting with. In this case we are intercepting and analysing these packets to understand more about protocols, source destination, in some cases HTTP stream. Packets are pieces of data sent across the network containing data that has been split into smaller pieces. Once the packets reach their destination they are reassmbled in order.
I would liken internet communication to ordering furniture like a bed, from ikea. Exept imagine each part of the bed is sent in a different parcel. You order a bed and it arrives in a package with the destination address, the source address, the weight of the parcel, whats inside, what the item actually is. Once it reaches its destination (your house) you reassmble the bed so you can sleep in it. Packet sniffing in this analogy, is essentially intercepting the parcels that contain each part of the bed and looking at the address and feeling the parcel to make sure its actually what you ordered.
The anatomy of data packets is important to understand, the figure below shows the anatomy of an IP (internet protocol) packet. Think of a packet like a parcel, this contains all of the information about the data being stored in the packet. The actual information eg. images, text, videos is referred to as the payload.
version- refers to the version of the IP being used (4 bits)
IHL (IP header field)- shows how many 32 bit words are in the IP header
flags- helps the user control fragments (3 bits) the value of the first bit is always zero, bit one means do not fragment, and bit two indicates how many fragments its split into.
indentification- IP header field, a unique number that has been assigned to a packet by the host. essentially the address and routing instructions for the packet.
total length- specifies the length of the packet
fragment offset- tell us the offset of the data for fragmented packets.
type of service- decides priority of the packet and what quality of packet.
protocol- eg, TCP or UDP or ICMP etc.
Header checksum- tells us if there are errors
Packet sniffing tools access the networks data-link layer where packets are encapsulated before they are sent through the network. Packet sniffers can be positioned strategically at different points of a network to intercept traffic for example routers, switches, and firewalls.
In the above diagram, packet sniffers are positioned at points of the network to intercept packets. Unencryoted packets can be read and analysed by potential attackers (or you). In this case we are going to be analysing packets being sent from a client to a server so our sniffing will look more like this:
installing wireshark
Wireshark is the graphical interface (GUI) packet sniffing tool we are going to use. To start we are going to launch our VM. I am using Kali Linux.
tcpdump basics
Tcpdump is a command-line tool used to capture and analyze network packets. When you run tcpdump, it captures packets from the network interface you specify. These packets contain information about the source and destination addresses, protocols used, and the data being transmitted. Tcpdump displays this information in human-readable format, making it easy to understand.
What are some basic tcpdump commands and switches?
a basic command for listening on our eth0 interface is going to look like
tcpdump {options} {expression}
we can also use the -v or verbose command for more details
hdh