#!/bin/bash
# 13/08/2013
#This is dicamarques edition of the script with mac changed to the ones from the list here https://docs.google.com/spreadsheet/lv?key=0AvvH5W4E2lIwdEFCUkxrM085ZGp0UkZlenp6SkJablE and easier wlan config 
#
# wifi_zone_new
#  A script that emulates a Nintendo Zone in a way that you can actually connect to
#  other people all over the world.
#
# Initial version written by Somebunny (9. August 2013).
#

#
# documentation (sort of)
#
# You will need the following packages/programs:
#  - rfkill
#  - dnsmasq (will be killed if already running)
#  - hostapd (will be killed if already running)
# You should not need any additional configuration work.
#
# This script MUST be run as root, or using sudo, reconfiguring network
#  interfaces does not seem to work when run by non-root.
#
# Please adapt the following sections to your own computer:
#  - variables "zone" and "world", found below
#  - you can add hotsopts in "InitZone()", just copy what is there
#
# Usage: call the script with one extra parameter that describes the
#  MAC address to use. I have prepared some options that work from
#  the thread in the gbatemp forums.
#
# Shutdown: call the script with the parameter "stop".
#
#
# A first attempt to organise everything in a somewhat smarter way.
#

# First, some obligatory checks.
if [[ $EUID -ne 0 ]]; then
   echo "This script must be run as root or with sudo."
   echo "I don't like this either, but some calls here are really picky!"
   exit 1
fi

# some global settings; you should only need to adapt them for your system once
#  * this is the network interface used for your custom AP; must be wireless
zone=$2
#  * this is the network interface used to access the internet; can be almost anything
world=$3

# some local variables; using default values so that something is there
ssid="attwifi"
mac=4E:53:50:4F:4F:46
country=DE
name="Main MAC (All/Any)"

#
# local function that sets up the local variables;
#  crude but better than having to change the script every time
# NOTE: this part should be heavily modified so that it doesn't
#  depend on a static config. Maybe something with an external
#  file or something, so you don't have to share your relay point
#  with the entire world if you don't want to.
#
InitZone() {
  # kill all existing support tools
  killall dnsmasq 2> /dev/null
  killall hostapd 2> /dev/null
  # flush routing entries
  iptables --flush
  # deconfigure network interface
  /sbin/ifconfig $zone down
  case $1 in
    "stop")
      # emergency exit - restore old network state
      echo "Stopping Nintendo Zone hotspot"
      /etc/init.d/network-manager restart # yeah... didn't find a better way to fix it...
      exit
    ;;
    "random") #thanks to duke_srg for this. Edit the title line with the games you have. The default has Mk7, Super Mario 3D world and AC:NL
#For more codes see https://docs.google.com/spreadsheet/ccc?key=0Ajsweg1Cjr5_dGhlaDNfd2Fid0ZpNTBYQ2pwVUlLT3c#gid=0 just add the ctr code here
#everytime you run random it picks a different mac, so once you get mk, then ac...
TITLES=AMKAREEGD
BASE=NSP
RANDOM=$(head -c 2 /dev/urandom | hexdump -e '1/2 "%u"')
CTR=$(($RANDOM%$(($(expr length $TITLES)/3))))
mac=$(echo $BASE$TITLES | cut -c 1-3,$(($CTR*3+4))-$(($CTR*3+6)) | hexdump -e '6/1 "%02X:"' | head -c 17)
      ssid="attwifi"
      country=DE
      name="Random MAC from custom title list"
    ;;
    "default")
      # default settings, my old WiFi card that recently died
      ;;
#MrLeb Changes begin here
	  "spoof1")
      ssid="attwifi"
      mac=02:53:50:4F:4F:46
      country=IDK
      name="Spoof number 1"
  ;;
    "spoof2")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:00
      country=IDK
      name="Spoof number 2"
  ;;
    "spoof3")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:01
      country=IDK
      name="Spoof number 3"
  ;;
    "spoof4")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:02
      country=IDK
      name="Spoof number 4"
  ;;
    "spoof5")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:03
      country=IDK
      name="Spoof number 5"
  ;;
    "spoof6")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:04
      country=IDK
      name="Spoof number 6"
  ;;
    "spoof7")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:05
      country=IDK
      name="Spoof number 7"
  ;;
    "spoof8")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:06
      country=IDK
      name="Spoof number 8"
  ;;
    "spoof9")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:07
      country=IDK
      name="Spoof number 9"
  ;;
    "spoof10")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:08
      country=IDK
      name="Spoof number 10"
  ;;
    "spoof11")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:09
      country=IDK
      name="Spoof number 11"
  ;;
    "spoof12")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:0A
      country=IDK
      name="Spoof number 12"
  ;;
    "spoof13")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:0B
      country=IDK
      name="Spoof number 13"
  ;;
    "spoof14")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:0C
      country=IDK
      name="Spoof number 14"
  ;;
    "spoof15")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:0D
      country=IDK
      name="Spoof number 15"
  ;;
    "spoof16")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:0E
      country=IDK
      name="Spoof number 16"
  ;;
    "spoof17")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:0F
      country=IDK
      name="Spoof number 17"
  ;;
    "spoof18")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:10
      country=IDK
      name="Spoof number 18"
  ;;
    "spoof19")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:11
      country=IDK
      name="Spoof number 19"
  ;;
    "spoof20")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:12
      country=IDK
      name="Spoof number 20"
  ;;
    "spoof21")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:13
      country=IDK
      name="Spoof number 21"
  ;;
    "spoof22")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:14
      country=IDK
      name="Spoof number 22"
  ;;
    "spoof23")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:15
      country=IDK
      name="Spoof number 23"
  ;;
    "spoof24")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:16
      country=IDK
      name="Spoof number 24"
  ;;
    "spoof25")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:17
      country=IDK
      name="Spoof number 25"
  ;;
    "spoof26")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:18
      country=IDK
      name="Spoof number 26"
  ;;
    "spoof27")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:19
      country=IDK
      name="Spoof number 27"
  ;;
    "spoof28")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:1A
      country=IDK
      name="Spoof number 28"
  ;;
    "spoof29")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:1B
      country=IDK
      name="Spoof number 29"
  ;;
    "spoof30")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:1C
      country=IDK
      name="Spoof number 30"
  ;;
    "spoof31")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:1D
      country=IDK
      name="Spoof number 31"
  ;;
    "spoof32")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:1E
      country=IDK
      name="Spoof number 32"
  ;;
    "spoof33")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:1F
      country=IDK
      name="Spoof number 33"
  ;;
    "spoof34")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:20
      country=IDK
      name="Spoof number 34"
  ;;
    "spoof35")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:21
      country=IDK
      name="Spoof number 35"
  ;;
    "spoof36")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:21
      country=IDK
      name="Spoof number 36"
  ;;
    "spoof37")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:23
      country=IDK
      name="Spoof number 37"
  ;;
    "spoof38")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:24
      country=IDK
      name="Spoof number 38"
  ;;
    "spoof39")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:25
      country=IDK
      name="Spoof number 39"
  ;;
    "spoof40")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:26
      country=IDK
      name="Spoof number 40"
  ;;
    "spoof41")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:27
      country=IDK
      name="Spoof number 41"
  ;;
    "spoof42")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:28
      country=IDK
      name="Spoof number 42"
  ;;
    "spoof43")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:29
      country=IDK
      name="Spoof number 43"
  ;;
    "spoof44")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:2A
      country=IDK
      name="Spoof number 44"
  ;;
    "spoof45")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:2B
      country=IDK
      name="Spoof number 45"
  ;;
    "spoof46")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:2C
      country=IDK
      name="Spoof number 46"
  ;;
    "spoof47")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:2D
      country=IDK
      name="Spoof number 47"
  ;;
    "spoof48")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:2E
      country=IDK
      name="Spoof number 48"
  ;;
    "spoof49")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:2F
      country=IDK
      name="Spoof number 49"
  ;;
    "spoof50")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:30
      country=IDK
      name="Spoof number 50"
  ;;
    "spoof51")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:31
      country=IDK
      name="Spoof number 51"
  ;;
    "spoof52")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:32
      country=IDK
      name="Spoof number 52"
  ;;
    "spoof53")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:33
      country=IDK
      name="Spoof number 53"
  ;;
    "spoof54")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:34
      country=IDK
      name="Spoof number 54"
  ;;
    "spoof55")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:35
      country=IDK
      name="Spoof number 55"
  ;;
    "spoof56")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:36
      country=IDK
      name="Spoof number 56"
  ;;
    "spoof57")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:37
      country=IDK
      name="Spoof number 57"
  ;;
    "spoof58")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:38
      country=IDK
      name="Spoof number 58"
  ;;
    "spoof59")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:39
      country=IDK
      name="Spoof number 59"
  ;;
    "spoof60")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:3A
      country=IDK
      name="Spoof number 60"
  ;;
    "spoof61")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:3B
      country=IDK
      name="Spoof number 61"
  ;;
    "spoof62")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:3C
      country=IDK
      name="Spoof number 62"
  ;;
    "spoof63")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:3D
      country=IDK
      name="Spoof number 63"
  ;;
    "spoof64")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:3E
      country=IDK
      name="Spoof number 64"
  ;;
    "spoof65")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:3F
      country=IDK
      name="Spoof number 65"
  ;;
    "spoof66")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:40
      country=IDK
      name="Spoof number 66"
  ;;
    "spoof67")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:41
      country=IDK
      name="Spoof number 67"
  ;;
    "spoof68")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:42
      country=IDK
      name="Spoof number 68"
  ;;
    "spoof69")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:43
      country=IDK
      name="Spoof number 69"
  ;;
    "spoof70")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:44
      country=IDK
      name="Spoof number 70"
  ;;
    "spoof71")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:45
      country=IDK
      name="Spoof number 71"
  ;;
    "spoof72")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:46
      country=IDK
      name="Spoof number 72"
  ;;
    "spoof73")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:47
      country=IDK
      name="Spoof number 73"
  ;;
    "spoof74")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:48
      country=IDK
      name="Spoof number 74"
  ;;
    "spoof75")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:49
      country=IDK
      name="Spoof number 75"
  ;;
    "spoof76")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:4A
      country=IDK
      name="Spoof number 76"
  ;;
    "spoof77")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:4B
      country=IDK
      name="Spoof number 77"
  ;;
    "spoof78")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:4C
      country=IDK
      name="Spoof number 78"
  ;;
    "spoof79")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:4D
      country=IDK
      name="Spoof number 79"
  ;;
    "spoof80")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:4E
      country=IDK
      name="Spoof number 80"
  ;;
    "spoof81")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:4F
      country=IDK
      name="Spoof number 81"
  ;;
    "spoof82")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:50
      country=IDK
      name="Spoof number 82"
  ;;
    "spoof83")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:51
      country=IDK
      name="Spoof number 83"
  ;;
    "spoof84")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:52
      country=IDK
      name="Spoof number 84"
  ;;
    "spoof85")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:53
      country=IDK
      name="Spoof number 85"
  ;;
    "spoof86")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:54
      country=IDK
      name="Spoof number 86"
  ;;
    "spoof87")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:55
      country=IDK
      name="Spoof number 87"
  ;;
    "spoof88")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:56
      country=IDK
      name="Spoof number 88"
  ;;
    "spoof89")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:57
      country=IDK
      name="Spoof number 89"
  ;;
    "spoof90")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:58
      country=IDK
      name="Spoof number 90"
  ;;
    "spoof91")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:59
      country=IDK
      name="Spoof number 91"
  ;;
    "spoof92")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:5A
      country=IDK
      name="Spoof number 92"
  ;;
    "spoof93")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:5B
      country=IDK
      name="Spoof number 93"
  ;;
    "spoof94")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:5C
      country=IDK
      name="Spoof number 94"
  ;;
    "spoof95")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:5D
      country=IDK
      name="Spoof number 95"
  ;;
    "spoof96")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:5E
      country=IDK
      name="Spoof number 96"
  ;;
    "spoof97")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:5F
      country=IDK
      name="Spoof number 97"
  ;;
    "spoof98")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:60
      country=IDK
      name="Spoof number 98"
  ;;
    "spoof99")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:61
      country=IDK
      name="Spoof number 99"
  ;;
    "spoof100")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:62
      country=IDK
      name="Spoof number 100"
  ;;
    "spoof101")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:63
      country=IDK
      name="Spoof number 101"
  ;;
    "spoof102")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:64
      country=IDK
      name="Spoof number 102"
  ;;
    "spoof103")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:65
      country=IDK
      name="Spoof number 103"
  ;;
    "spoof104")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:66
      country=IDK
      name="Spoof number 104"
  ;;
    "spoof105")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:67
      country=IDK
      name="Spoof number 105"
  ;;
    "spoof106")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:68
      country=IDK
      name="Spoof number 106"
  ;;
    "spoof107")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:69
      country=IDK
      name="Spoof number 107"
  ;;
    "spoof108")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:6A
      country=IDK
      name="Spoof number 108"
  ;;
    "spoof109")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:6B
      country=IDK
      name="Spoof number 109"
  ;;
    "spoof110")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:6C
      country=IDK
      name="Spoof number 110"
  ;;
    "spoof111")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:6D
      country=IDK
      name="Spoof number 111"
  ;;
    "spoof112")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:6E
      country=IDK
      name="Spoof number 112"
  ;;
    "spoof113")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:6F
      country=IDK
      name="Spoof number 113"
  ;;
    "spoof114")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:70
      country=IDK
      name="Spoof number 114"
  ;;
    "spoof115")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:71
      country=IDK
      name="Spoof number 115"
  ;;
    "spoof116")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:72
      country=IDK
      name="Spoof number 116"
  ;;
    "spoof117")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:73
      country=IDK
      name="Spoof number 117"
  ;;
    "spoof118")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:73
      country=IDK
      name="Spoof number 118"
  ;;
    "spoof119")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:75
      country=IDK
      name="Spoof number 119"
  ;;
    "spoof120")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:76
      country=IDK
      name="Spoof number 120"
  ;;
    "spoof121")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:77
      country=IDK
      name="Spoof number 121"
  ;;
    "spoof122")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:78
      country=IDK
      name="Spoof number 122"
  ;;
    "spoof123")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:79
      country=IDK
      name="Spoof number 123"
  ;;
    "spoof124")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:7A
      country=IDK
      name="Spoof number 124"
  ;;
    "spoof125")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:7B
      country=IDK
      name="Spoof number 125"
  ;;
    "spoof126")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:7C
      country=IDK
      name="Spoof number 126"
  ;;
    "spoof127")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:7D
      country=IDK
      name="Spoof number 127"
  ;;
    "spoof128")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:7E
      country=IDK
      name="Spoof number 128"
  ;;
    "spoof129")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:7F
      country=IDK
      name="Spoof number 129"
  ;;
    "spoof130")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:80
      country=IDK
      name="Spoof number 130"
  ;;
    "spoof131")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:81
      country=IDK
      name="Spoof number 131"
  ;;
    "spoof132")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:82
      country=IDK
      name="Spoof number 132"
  ;;
    "spoof133")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:83
      country=IDK
      name="Spoof number 133"
  ;;
    "spoof134")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:84
      country=IDK
      name="Spoof number 134"
  ;;
    "spoof135")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:85
      country=IDK
      name="Spoof number 135"
  ;;
    "spoof136")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:86
      country=IDK
      name="Spoof number 136"
  ;;
    "spoof137")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:87
      country=IDK
      name="Spoof number 137"
  ;;
    "spoof138")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:88
      country=IDK
      name="Spoof number 138"
  ;;
    "spoof139")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:89
      country=IDK
      name="Spoof number 139"
  ;;
    "spoof140")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:8A
      country=IDK
      name="Spoof number 140"
  ;;
    "spoof141")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:8B
      country=IDK
      name="Spoof number 141"
  ;;
    "spoof142")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:8C
      country=IDK
      name="Spoof number 142"
  ;;
    "spoof143")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:8D
      country=IDK
      name="Spoof number 143"
  ;;
    "spoof144")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:8E
      country=IDK
      name="Spoof number 144"
  ;;
    "spoof145")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:8F
      country=IDK
      name="Spoof number 145"
  ;;
    "spoof146")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:90
      country=IDK
      name="Spoof number 146"
  ;;
    "spoof147")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:91
      country=IDK
      name="Spoof number 147"
  ;;
    "spoof148")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:92
      country=IDK
      name="Spoof number 148"
  ;;
    "spoof149")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:93
      country=IDK
      name="Spoof number 149"
  ;;
    "spoof150")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:94
      country=IDK
      name="Spoof number 150"
  ;;
    "spoof151")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:95
      country=IDK
      name="Spoof number 151"
  ;;
    "spoof152")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:96
      country=IDK
      name="Spoof number 152"
  ;;
    "spoof153")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:97
      country=IDK
      name="Spoof number 153"
  ;;
    "spoof154")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:98
      country=IDK
      name="Spoof number 154"
  ;;
    "spoof155")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:99
      country=IDK
      name="Spoof number 155"
  ;;
    "spoof156")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:9A
      country=IDK
      name="Spoof number 156"
  ;;
    "spoof157")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:9B
      country=IDK
      name="Spoof number 157"
  ;;
    "spoof158")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:9C
      country=IDK
      name="Spoof number 158"
  ;;
    "spoof159")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:9D
      country=IDK
      name="Spoof number 159"
  ;;
    "spoof160")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:9E
      country=IDK
      name="Spoof number 160"
  ;;
    "spoof161")
      ssid="attwifi"
      mac=4E:53:50:4F:4F:9F
      country=IDK
      name="Spoof number 161"
  ;;
#MrLeb Changes end here
  esac
}

# networkmanager often leaves a lock on the wireless hardware, remove it
rfkill unblock wifi

# set up parameters
InitZone $1

# give our wifi device a static IP address in the correct range so hostapd can associate with it
/sbin/ifconfig $zone hw ether $mac
/sbin/ifconfig $zone 192.168.23.1 up

# start dnsmasq
dnsmasq -i $zone --dhcp-range=192.168.23.50,192.168.23.150,255.255.255.0,12h

# enable IP forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward

# set basic routes so that our associated devices can reach the web
iptables --flush
iptables --table nat --flush
iptables --delete-chain
iptables --table nat --delete-chain
iptables --table nat --append POSTROUTING --out-interface $world -j MASQUERADE
iptables --append FORWARD --in-interface $zone -j ACCEPT

sysctl -w net.ipv4.ip_forward=1

# start hostapd, spawn a temporary file
TMPDIR=`mktemp -d`
tmpfile=$TMPDIR/nztmp
echo $tmpfile
trap "rm -rf $TMPDIR" EXIT

echo "interface=${zone}" >> $tmpfile
echo "driver=nl80211" >> $tmpfile
echo "channel=1" >> $tmpfile
echo "ssid=${ssid}" >> $tmpfile
echo "auth_algs=1" >> $tmpfile
echo "wpa=0" >> $tmpfile
echo "country_code=${country}" >> $tmpfile
# uncomment the following two lines if you want MAC filtering
#echo "macaddr_acl=1" >> $tmpfile
#echo "accept_mac_file=/home/ms/hostapd/hostapd_mac_file" >> $tmpfile

echo "Starting Nintendo Zone hotspot, using config ''${name}''"
echo "SSID: ${ssid}"
echo "Country: ${country}"

hostapd $tmpfile -B -d > /dev/null 2> /dev/null

rm -rf $TMPDIR
