Author Topic: [Bash] mon.sh - change between monitor mode and managed mode  (Read 1351 times)

0 Members and 1 Guest are viewing this topic.

Offline frog

  • Knight
  • **
  • Posts: 232
  • Cookies: 16
    • View Profile
[Bash] mon.sh - change between monitor mode and managed mode
« on: August 20, 2012, 12:15:19 am »
I'm sick of typing this one out and I don't want to depend on aicrack-ng or the like for their special utilities. I suppose I could have went a step further and created a new virtual interface but I dgaf.

Code: (bash) [Select]
#!/bin/bash
# Change given interface to monitor mode..
export IFACE=$1
export MODE

usage() {
  echo "Usage: $0 <interface>"
}

identifyWorth() {
  if [ `whoami` != "root" ]; then
    echo "Get root and try again."
    exit
  fi
}

checkMode() {
  MODE=`iwconfig $IFACE | grep Mode`
  MODE=`echo ${MODE:30:7}`
 
  if [ $MODE = "Monitor" ]; then
    MODE="Monitor"
  else
    MODE="Managed"
  fi
}

setMode() {
  if [ $MODE = "Monitor" ]; then
    ifconfig $IFACE down; iwconfig $IFACE mode managed
    ifconfig $IFACE up
  fi

  if [ $MODE = "Managed" ]; then
    ifconfig $IFACE down; iwconfig $IFACE mode monitor
    ifconfig $IFACE up
  fi
}

showMode() {
  echo $IFACE "is now in" $MODE "mode."
}

identifyWorth

if [ -z $1 ]; then
  usage
  exit
fi

checkMode
setMode
checkMode
showMode