Simulate Wi-Fi (802.11) between Linux Virtual Machines on Qemu/VirtualBox/...
-
It can be used in Hypervisors (GNS3, QEmu, Virtualbox, VMware, Hyper-V, ...)
-
The Wireless emulator uses the
mac80211_hwsim
linux driver -
Implements the packet loss simulation based on distance
-
Emulates the node mobility in GNS3
-
Tested:
- with
hostapd
andwpa_supplicant
with these configurations:- Open
- WEP
- WPA2
- WPA-EAP
- in the context of WPA2 attack with
Aircrack-NG
(Kali / Parrot-OS) - with OpenWRT
- with
-
Remaining features to be implemented:
- Integrate to other OS (Windows...)
- Add obstacle models
- Etc.
- vwifi-client should be started on the VMs, and vwifi-server on the Host
- vwifi-client and vwifi-server can communicate either with the VHOST protocol, or with the TCP protocol
- The vwifi-spy is the same as vwifi-client but :
- it receives always all communications, even if the loss of packets is enable.
- it works only with TCP.
- by default, it connects to 127.0.0.1
- vwifi-client and vwifi-spy use the
mac80211_hwsim
kernel module to have the wifi interfaces - To use TCP protocol, vwifi-server and vwifi-client/vwifi-spy must be connected to a different IP network than that of the wifi
- vwifi-ctrl is used to interact with vwifi-server
sudo apt-get install make g++
sudo apt-get install libnl-3-dev libnl-genl-3-dev
- Not necessary :
make gitversion # To add the last commit id to the VERSION
make update # To download and update the file mac80211_hwsim.h
- To building :
make
make tools # To change the file mode bits of tools
sudo make install
- See the wiki : Install-on-OpenWRT-X86_64
-
Shell :
- Load the module VHOST :
# sudo rmmod vhost_vsock vmw_vsock_virtio_transport_common vsock # if necessary sudo modprobe vhost_vsock sudo chmod a+rw /dev/vhost-vsock
- Start the vwifi-server :
vwifi-server
-
Hypervisor
- QEmu : add the option :
-device vhost-vsock-pci,id=vwifi0,guest-cid=NUM
with NUM an identifier greater than 2 - GNS3 (>= 2.2) : QEmu : add the option :
-device vhost-vsock-pci,id=vwifi0,guest-cid=%guest-cid%
- QEmu : add the option :
- Create the wlan interfaces (on this example, 2 interfaces) :
sudo modprobe mac80211_hwsim radios=2
# sudo macchanger -a wlan0 # we advice to change the MAC address of the wlan (with macchanger, ip, ifconfig, ...)
- Connect all these wlan interfaces to the vwifi-server :
sudo vwifi-client
- vwifi-client displays "ID=-1". vwifi-server uses the cid to identify this guest.
- vwifi-server and vwifi-client must be connected to a different IP network than that of the wifi (for example : 172.16.0.0/16)
- Start the vwifi-server :
vwifi-server
- We will suppose that the Host have the IP address : 172.16.0.1
- Create the wlan interfaces (on this example, 2 interfaces) :
sudo modprobe mac80211_hwsim radios=2
# sudo macchanger -a wlan0 # we advice to change the MAC address of the wlan (with macchanger, ip, ifconfig, ...)
- Connect all these wlan interfaces to the vwifi-server :
sudo vwifi-client 172.16.0.1
- vwifi-client displays an ID which is an hashsum of the IP. It is used by vwifi-server to identify this guest.
sudo modprobe mac80211_hwsim radios=1
sudo vwifi-spy
- Capture from wlan0 :
sudo tcpdump -n -I -i wlan0
- Configure wlan0 to monitor mode :
sudo ip link set wlan0 down
sudo iw wlan0 set monitor control
sudo ip link set wlan0 up
- Start Wireshark and capture from wlan0 :
sudo wireshark
- Show the list of connected guest (display : cid and coordinate x, y z) :
vwifi-ctrl ls
- Set the new coordinate (11, 12, 13) of the guest with the cid 10 :
vwifi-ctrl set 10 11 12 13
- Enable the lost of packets :
vwifi-ctrl loss yes
- Disable the lost of packets :
vwifi-ctrl loss no
- Display the config of vwifi-server :
vwifi-ctrl status
- Display the distance in meters between the guest with the cid 10 and the guest with the cid 20 :
vwifi-ctrl distance 10 20
sudo apt install hostapd wpasupplicant
- Guest Wifi 1 :
sudo ip a a 10.0.0.1/8 dev wlan0
sudo hostapd tests/hostapd_wpa.conf
- Guest Wifi 2 :
sudo wpa_supplicant -Dnl80211 -iwlan0 -c tests/wpa_supplicant.conf
sudo ip a a 10.0.0.2/8 dev wlan0
ping 10.0.0.1
- Guest Wifi 3 :
sudo wpa_supplicant -Dnl80211 -iwlan0 -c tests/wpa_supplicant.conf
sudo ip a a 10.0.0.3/8 dev wlan0
ping 10.0.0.2
sudo apt install hostapd iw tcpdump
- Guest Wifi 1 :
sudo ip a a 10.0.0.1/8 dev wlan0
sudo hostapd tests/hostapd_open.conf
- Guest Wifi 2 :
sudo ip link set up wlan0
sudo iw dev wlan0 connect mac80211_open
sudo ip a a 10.0.0.2/8 dev wlan0
ping 10.0.0.1
- Guest Wifi 3 :
sudo ip link set up wlan0
sudo tcpdump -n -e -I -i wlan0 -w /hosthome/projects/vwifi_capture_wlan0.pcap
tail -f -c +0b /home/user/projects/vwifi_capture_wlan0.pcap | wireshark -k -i -
sudo apt install iw
- Guest Wifi 1 :
sudo ip link set up wlan0
sudo iw wlan0 set type ibss
sudo iw wlan0 ibss join MYNETWORK 2412 # frequency 2412 is channel 1
sudo ip a a 10.0.0.1/8 dev wlan0
- Guest Wifi 2 :
sudo ip link set up wlan0
sudo iw wlan0 set type ibss
sudo iw wlan0 ibss join MYNETWORK 2412 # frequency 2412 is channel 1
sudo ip a a 10.0.0.2/8 dev wlan0
ping 10.0.0.1
- start-vwifi-client.sh : do all the commands necessary to start vwifi-client on a Guest
- fast-vwifi-update.sh : set with vwifi-ctrl the coordinates of each VMs which has the option
guest-cid=
, found in the open project of GNS3 - client.sh : configure the client wifi with Open or WPA