Skip to content

Instantly share code, notes, and snippets.

@chinthakagodawita
Last active May 15, 2019 07:24
Show Gist options
  • Save chinthakagodawita/5041eb0d8f1f68e9e23f to your computer and use it in GitHub Desktop.
Save chinthakagodawita/5041eb0d8f1f68e9e23f to your computer and use it in GitHub Desktop.

Setting a wifi card to monitor mode

This is required before libtins/libpcap will get packets:

DEVICE=wlan0
sudo ifconfig $DEVICE down
sudo iwconfig $DEVICE mode monitor
sudo ifconfig $DEVICE up

Once done, don't forget the reverse:

DEVICE=wlan0
sudo ifconfig $DEVICE down
sudo iwconfig $DEVICE mode auto
sudo ifconfig $DEVICE up

Channel hopping

Probably easier to do this in bash than trying to implement in C++.

Example script below. Might need updating for 802.11n + ac.

#!/bin/bash
IFACE=wlan0
IEEE80211bg="1 2 3 4 5 6 7 8 9 10 11"
IEEE80211bg_intl="$IEEE80211b 12 13 14"
IEEE80211a="36 40 44 48 52 56 60 64 149 153 157 161"
IEEE80211bga="$IEEE80211bg $IEEE80211a"
IEEE80211bga_intl="$IEEE80211bg_intl $IEEE80211a"

while true ; do
  for CHAN in $IEEE80211bga_intl ; do
    echo "Switching to channel $CHAN"
    iwconfig $IFACE channel $CHAN
    # Sleep for 0.1 seconds (similar to kismet)
    sleep 0.1
  done
done

Tweaking transmit/receive power of Wifi device

We need a card that supports this, the mini ones do not.

DEVICE=wlan0
# txpower is in dBm
sudo iwconfig $DEVICE txpower 5
@MisterBianco
Copy link

Is there any libraries or modules to support native C++ channel hopping, I wasn't really able to find anything solidly. Any guidance would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment