First off, I know its not programming, it's scripting, but I'm learning so cut me some slack.

Anyway, I've got four scripts I'd like to share. These are working on BackTrack 4 beta, haven't had a chance to compare with 4 prerelease, but I'm sure it can be adapted. I use these in specific with an Atheros based chipset (as they are for athX madwifi VAPs). To use these scripts, simply open Kate and copy the code, save to correct dir, then use console to
Code:
root@bt:~# chmod 1777 /usr/sbin/xxxx-sc.sh
for each script. After this has been done, these scripts can be run from konsole root as xxxx-sc-sh. Makes things convienent.

I also use an array in my script, utilizing both monitor + connectivity modes on ath0 and ath1. Ath0 is designated as the monitor, and ath1 is used for connect. The only trick with this script is that the card's modes are bound together by channel, so if you connect on channel 6 you can only monitor on channel 6. If you are monitoring and channel hopping, you will have a hard time associating.
/usr/sbin/dual-sc.sh
Code:
killall wpa_supplicant
killall NetworkManger
killall knetworkmanager
airmon-ng stop ath0
airmon-ng stop ath1
ifconfig wifi0 down
macchanger --mac 00:10:24:00:13:37
ifconfig wifi0 up
airmon-ng start wifi0
wlanconfig ath1 create wlandev wifi0 wlanmode sta -uniquebssid
NetworkManager start
knetworkmanager
This one sets the wifi card in to strictly monitor/passive mode.
/usr/sbin/mon-sc.sh
Code:
airmon-ng stop ath0
airmon-ng stop ath1
killall wpa_supplicant
killall NetworkManager
killall knetworkmanager
ifconfig wifi0 down
macchanger --mac 00:11:22:33:44:55 wifi0
ifconfig wifi0 up
airmon-ng start wifi0
airodump-ng ath0
This sets the wifi card into strictly internet/connectivity mode.
/usr/sbin/con-sc.sh
Code:
airmon-ng stop ath0
airmon-ng stop ath1
ifconfig wifi0 down
macchanger --mac 00:10:24:00:13:37 wifi0
ifconfig wifi0 up
wlanconfig ath0 create wlandev wifi0 wlanmode sta -uniquebssid
NetworkManager start
knetworkmanager
Finally, to flush all wifi connections into the "down" mode.
/usr/sbin/netdown-sc.sh
Code:
killall wpa_supplicant
killall NetworkManger
killall knetworkmanager
airmon-ng stop ath0
airmon-ng stop ath1
Any criticism or comments welcome! Lemme know what you guys think.