In this article, you will learn how to capture wireless frames using Wireshark in Linux (Example: Ubuntu. To follow this article, first, you should learn the basics of WireShark in the Wireshark Basic article, and then you can come back here.
There are some steps to be followed to achieve this.
Setup Check
Below are the requirements for capturing Wi-Fi packets using Wireshark.
Wi-Fi Interface
To check whether you meet this requirement, open the terminal using the shortcut Alt+Ctrl+T and run the command “iwconfig.” This output should show if there is an operable Wi-Fi interface. The following screenshot shows the output of this command:
In this example “wlp2s0” is the interface name for the Wi-Fi card.
- “IEEE 802.11” is the indication for the Wi-Fi interface.
- By default, the mode is “Managed,” which means that it is a client or station mode.
Support for Monitor Mode
The Wi-Fi card must support monitor mode to be able to sniff out wireless packets. This is a must, or you cannot sniff wireless packets using Wireshark. Open the terminal and run the command “iw phy0 info” or “iw list.” There is a huge list of information available here, but we just have to check the section for “monitor.” If the device does not support monitor mode, then it will not be possible to sniff the wireless packet using Wireshark.
Check Wireshark Software
Open the terminal and run the command “wireshark –version.” If Wireshark is installed, then there should be a version name with many details, as in the following screenshot:
If it is not installed, then use the commands “apt-get update” and “apt-get install wireshark” to install Wireshark on your system.
Configuring Monitor Mode
In previous sections, you saw that the Wi-Fi interface default mode is “managed.” To capture a wireless packet, we need to convert the “managed” mode to “monitor” mode. There are different commands that you can use, but to use a simple method first, we will try using the “iwconfig” command to create monitor mode.
Let us assume that the name of the Wi-Fi interface is “wlp2s0,” as shown in the screenshot.
Step 1: Enter Superuser Mode
First, enter into superuser mode; otherwise, we will get permission to do this.
Command: “su”
Step 2: Create Monitor Mode
Command: “iwconfig wlps20 mode monitor”
Output: If the interface is up and active, you will get the “Device or resource busy” error.
So, make interface down using the following command.
Command: “ifconfig wlsp2s0 down”
Then, execute the first command again.
Finally, check whether the interface is in monitor mode using the “iwocnfig” command.
Here is the screenshot to explain all the above steps:
Step 3: Configure Wi-Fi Sniffing Channel
In wireless protocol, there are two radio frequency bands:
- 5GHz [Frequency range is 5180MHz – 5825MHz]
- 2.4GHz [Frequency range is 2412MHz – 2484MHz]
Wiki link for WLAN channels list: https://en.wikipedia.org/wiki/List_of_WLAN_channels
If your wireless card supports 1 and 2, that means that the Wi-Fi card can sniff both bandwidth configured channels. Let us see what our card supports.
Using the command “iw list,” we can check this capability. We are looking for the section below in the command output screenshot:
As yu can see in the above list, this Wi-Fi chip supports only 2.4Ghz [Check the frequency range].
Each frequency is known as channel number. For example, 2412MHz is considered channel 1 [Shown in [] ].
Now, we need to configure one channel for our monitor mode interface. Let us try to set channel 11 [frequency is 2462MHz].
Command: “iwconfig wlp2s0 channel 11”
If above command outputs an error, this makes the interface up [“ifconfig wlp2s0 up”] and then executes the “iwconfig wlp2s0 channel 11” command. Finally, execute the “iwconfig” command to ensure that the channel is set up properly.
The following screenshot explains the steps given above:
Step 4: Launch Wireshark and Start Capturing
Now, we are all set to capture wireless packets. You can start Wireshark in the background using the following command:
In the startup window of Wireshark, you should see the following screen. Here, you can see a list of interfaces.
Next, choose your monitor mode interface, which is “wlp2s0.” Select this interface and then double-click on it.
You can see that live capturing is currently going on.
The following include some hints about wireless packets:
You should see the protocol section, which generally shows 802.11, which is wireless IEEE standard.
You should also see the “Beacon,” “Probe Request,” and “Probe Response” frames under the info section of any frame.
If you wish to save the capture and check it later, then select “save” or “save as” and save it for later analysis.
As long as the interface is in monitor mode you can capture wireless packet. Remember if you reboot the system the wireless interface will come up as “Managed” mod again.
Conclusion
In this article, you learned how to capture wireless packets using Wireshark in Linux. This is very easy to do in Linux using the built-in Wi-Fi card without installing any extra third-party software. You can make a shell script containing all these commands and run that single shell script to configure your system’s Wi-Fi card as monitor mode, set the preferred channel, and start using Wireshark.
from Linux Hint https://ift.tt/2ImT2os
0 Comments