Script to Switch Wlan Between Managed and Monitor Mode

Apr 3, 2016 12:03 AM

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

Related Articles

637263493835297420.jpg

How to Use Zero-Width Characters to Hide Secret Messages in Text (& Even Reveal Leaks)

636455706472146367.jpg

How to Hide DDE-Based Attacks in MS Word

Comments

No Comments Exist

Be the first, drop a comment!