How to replay Wireshark captured packets? - wireshark

I have captured some packets in Wireshark and need to replay those again in any way.

The Wireshark wiki Tools page lists many packet capture related tools, among them some tools that can replay packets such as Bit-Twist, PlayCap, Scapy, tcpreplay and several others.

I just had to do this on a Windows machine. Most all of the methods required a UNIX machine or cygwin. Colasoft Packet Player worked great without having dependencies on other software or drivers.

Related

Show multiple tcpdump outout within one wireshark

I know how to use wireshark to show one tcpdump result using ssh. But now I want to debug kubernetes network. There will be multiple nodes and I need to capture all the packets. So I must run tcpdump on each nodes. Is it possible to combine tcpdump output and show in one wireshark?
Yes, Wireshark can merge capture files. Refer to the section on Merging capture files in the Wireshark User Guide for all the information you need. Alternatively, you can use the mergecap command-line tool, which is part of the suite of Wireshark command-line tools, to merge the files. There may be other tools of interest that can probably help you here as well; try searching for "merge" on the Wireshark Tools wiki page.
I have found out a solution.
Using gretap to connect all hosts into one bridge. And use tc mirror to mirror all packets to this bridge. Then just capture this bridge, I can get all the packets now.

WiFi Beacon Packets

I'm trying to write a simple C code with WinPcap to broadcast a beacon packet and capture it in all nearby WiFi units. The code I'm using is very similar to the ones available at WinPcap[1].
The code runs fine if I create an ad-hoc network connection and join all the computers into it. However, this process of creating and joining to an ad-hoc network is cumbersome. It would be much better if, regardless of what network each computer is in, the beacon packets would be broadcasted and captured once the code is running.
As simple as this problem might sound, after some searching it seems that this is not possible to be done on windows (unless re-writing drivers or maybe the kernel):
Raw WiFi Packets with WinPcap[2]
Sending packets without network connection[3]
Does winpcap/libpcap allow me to send raw wireless packets?[4]
Basically, it would be necessary to use the WiFi in monitor mode, which is not supported in Windows[5]. Therefore, if the computers are not in the same network connection, the packets will be discarded.
1st Issue
I'm still intriguing, beacon and probe request packets are a normal traffic across the network. How they could be being sent and received constantly but the user is not allowed to write a program to do so? How to reconcile that?
2nd Issue
Does anyone has experience with Managed Wifi API[6]? I've heard that it might help.
3rd Issue
Acrylic WiFi[7] claims to have developed a NDIS driver which support monitor mode under Windows. Does anyone has experience with this software? Is it possible to integrate with C codes?
4th Issue
Is it possible to code such Wifi beacon on Linux? and on Android?
www.winpcap.org/docs/docs_412/html/main.html
stackoverflow.com/questions/34454592/raw-wifi-packets-with-winpcap/34461313?noredirect=1#comment56674673_34461313
stackoverflow.com/questions/25631060/sending-packets-without-network-connection-wireless-adapter
stackoverflow.com/questions/7946497/does-winpcap-libpcap-allow-me-to-send-raw-wireless-packets
en.wikipedia.org/wiki/Monitor_mode#Operating_system_support
managedwifi.codeplex.com/
www.acrylicwifi.com/
Couple questions I will try to answer. Mgmt and Ctrl packets are used for running a wifi network and don't contain data, I would not call these normal packets. Windows used to(I think still does) convert data packets into ethernet frames and pass it up the stack. Beacon and Probe Req pkts are not necessary for TCP/IP stack to work, ie. web browsers don't need beacon frames to get your web page. Most OS's need minimal info from mgmt/ctrl pkts to help a user interact with a wifi adapter, most mgmt/ctrl pkts only are useful to the driver(and low level os components) to figure how to interact with the network. This way the wifi adapters look and act like ethernet adapters to high level os components.
Never had any experience with Managed Wifi API or Acrylic, so can't give you any feedback.
Most analyzers that capture and send packets do it in 2-3 separate modes mainly because of hardware. Wifi adapters can be in listen mode(promiscuous mode and/or monitor mode) or adapter mode. To capture network traffic you need to listen and not send, ie. if someone sends a pkt while you are sending you miss that traffic. In order to capture(or send) traffic you will need a custom NDIS driver in windows, on linux many of them already do. Checkout wireshark or tshark, they use winpcap to capture pkts in windows and there are some adapters they recommend to use to capture pkts.
Yes it is possible to send a beacon on linux, ie. Aireplay. I know its possible to capture traffic on Android but you it needs to have rooted or custom firmware, which I would believe also means you can send custom pkts. If you are simply trying to send a pkt it might be easier to capture some traffic in tshark or wireshark and use something like aireplay to resend that traffic. You could also edit the packet with a hex editor to tune it to what you need.

How can I sniff the packets from IP(s) of other devices connected to the same local wireless network?

I am able to capture only the packets routed through my NIC, but I want to sniff all the packets from other PC(s) connected to the same local wireless network. I am using Wireshark, but it cannot sniff the packets from the remote IP(s) connected to the same local network (created by a wireless router).
You haven't provided much detail about your capture setup - in particular what OS your capture PC is running or what hardware you have. The best advice I can give you to start with is to visit the Wireshark WLAN (IEEE 802.11) capture setup wiki page and carefully read its contents, particularly those sections that best relate to your system. At the very least, you will need to be able to place your wireless NIC into monitor mode, and the method by which you do that is OS dependent, so do visit that wiki page for more details.
If you happen to be running Windows and you are unable to place your NIC into monitor mode using Wireshark or you don't have an adaptor (such as an Airpcap adaptor) capable of capturing the traffic, or npcap doesn't work for you, then you might want to try other tools besides Wireshark, such as Microsoft's Network Monitor or their newer Message Analyzer capture tools.
Lastly, if nothing else works, then you might want to visit the Wireshark Tools wiki page to try to find other potential tools that might work for you in your particular capture environment.
You can use the Cain and Abel sniffing tool. It is very easy one. You can sniff packets by Cain and Abel and log them using WireShark.
You can download it from https://web.archive.org/web/20190603235413/http://www.oxid.it/cain.html

Parsing packets captured using wireshark for management frames identification using libpcap or similar library

I want to parse packets captured by wireshark offline using libpcap. I am capturing packets from a wireless network in monitor mode. I have read that "libpcap" can be used to capture and parse packets captured in the ethernet. Can it be used for wireless networks too? If yes, can anyone suggest me some tutorial? and if No, which library is suitable for it and how to use it?
libpcap, and its Windows port, WinPcap can be used to capture network traffic (in fact, they're what Wireshark uses to capture network traffic), as well as to read a capture file in pcap format (the default format for Wireshark's existing releases) and, in libpcap 1.1 and later, to read some capture files in pcap-ng format (the default format for the current development version of Wireshark; it should write out files that libpcap 1.1 and later can read).
They can handle a number of network types, including Ethernet and Wi-Fi.
They do not, however, support parsing any packet types; that's the job of the code that uses them, whether it's tcpdump/WinDump, Wireshark, or some other application. There's a library called WiFiPcap that is:
A C++ wrapper around libpcap that parses 802.11 frames, and the most common layer 3 (IPv4, IPv6, ARP) and layer 4 protocols (TCP, UDP, ICMP) contained within them. Also works without link-layer headers. Works in Linux and Windows.
(copied from its web page, but edited to fix the protocol layer numbers to match the OSI model).
I have not looked at it, but it might do what you want.
There might also be other libraries that could be used to parse the packets.

pcap - streaming and receiving udp in the same computer

To explain what I would like to get, here's an example.
Let's say, we have a PC with one NIC. It has single IP address 172.16.0.1.
Using VLC, we start a udp stream to 172.16.0.1:1234, then launch another copy of VLC and connect to udp://#172.16.0.1:1234. Now we'll see our video streaming.
If you run sniffer, you will see packets from 172.16.0.1:some_random_port to 172.16.0.1:1234 on loopback. There's no trafic on our NIC.
What I want to do is to stream and receive udp in the same computer, like VLC does it. But the main problem is that pcap can only pcap_open() a real device, it can't work with loopback.
Is it possible to solve that problem?
P.S. I'm using Windows and WinPcap, unlike Linux version, it can send packets.
If you just want to send and receive UDP packets, I would suggest just using regular Winsock sockets, just as you'd use regular sockets on UN*X; using WinPcap requires that you re-implement IP and UDP, and won't let you send to another socket on the same machine under Windows (or on at least some versions of UN*X, either).
If you want to watch the traffic you're sending, unfortunately WinPcap won't help, as it relies on packets being sent out and received from NDIS (its driver plugs into NDIS), and that doesn't happen for packets sent from one socket on a machine to another socket on the same machine.
(Note, BTW, that libpcap can send packets on Linux and *BSD and Mac OS X and Solaris and Digital/Tru64 UNIX, for example, and has been able to do so for several years; older versions of libpcap didn't support it, but the versions available for the past few years can. However, as per my first paragraph, it would not make sense to use libpcap to send and receive regular UDP packets on those OSes, just as it makes no sense to use WinPcap for that purpose on Windows.)

Resources