Forum Thread: Script to Switch Wlan Between Managed and Monitor Mode

Hi.

My second script in this forum within just a couple of hours. Guess I am having a run ;-)

This really useful piece of code switches wlan0 between managed and monitor mode.

You can either specify the mode "mon" or "man" as parameter when starting or start without a parameter to switch to the opposite of the current mode.

The parameter "mon" will enter monitor mode, "man" will enter managed mode.

The script contains ifconfig down and up because some wifi cards (including mine) need this to switch between the modes.

The reason I wrote this code is simple: airomon-ng switches my card to monitor mode, but it does not switch back.
With this code, switching back and forth is no problem.
Enjoy and comment, if you like. I appreciate it.

Greeting from Germany

#!/bin/bash
printf "########### WlanModes ###########\n########## By 94erBrom ##########\n\n"
ifconfig wlan0 down
case "$1" in
mon)
iwconfig wlan0 mode monitor
echo "Inferface now in Monitor Mode"
;;
man)
iwconfig wlan0 mode managed
echo "Inferface now in Managed Mode"
;;
)
var=$(iwconfig 2>&1 | sed -e '/wlan/,/Mode/!d')
case "$var" in
Managed)
iwconfig wlan0 mode monitor
echo "Inferface now in Monitor Mode"
;;
Monitor)
iwconfig wlan0 mode managed
echo "Inferface now in Managed Mode"
;;
esac
esac
ifconfig wlan0 up

Be the First to Respond

Share Your Thoughts

  • Hot
  • Active