PDA

View Full Version : WPA - Connect Script



txt3rob
04-02-2007, 02:04 PM
can you include the script from the newbiews area?

#!/usr/bin/bash

iwconfig eth0 mode managed essid "linksys"
printf "* - Configured interface\n"
ifconfig eth0 up
printf "* - Interface up\n"
wpa_supplicant -B -Dwext -ieth0 -c/etc/wpa_supplicant.conf
printf "* - wpa_supplicant running, sleeping for 5...\n"
sleep 5
printf "* - Running dhcpcd\n"
dhcpcd eth0
ifconfig eth0 | grep inet

something like that so it make it easy to connect to WPA networks instead of having to go thru all that please

thorin
04-02-2007, 02:13 PM
Why not just make the script you need for your system and create a custom ISO with MySLAX creator which adds it with the rootcopy functionality?

They can't really include the script because they don't know the details of your network (ie: essid, which interface to bring up, etc etc.....)

hobbes
04-03-2007, 05:00 AM
I whipped up a new version of that script, and if anybody wants to help beta test it please feel free. Just save it to a fresh document and make it executable (chmod +x SCRIPT_NAME).


#!/usr/bin/bash

#wpa_connect script by Hobz of #remote-exploit
#Currently in beta, needs testing
#April 2, 2007

INT=$1
ESSID=$2

if [ -z "$2" ]; then
printf "Usage: $0 [interface] [ESSID]\n"
printf "$0 will create a /etc/wpa_supplicant.conf file if none exists"
printf "Default driver: wext\n"
exit
fi

function connect {
ifconfig $INT down
iwconfig $INT mode managed essid "$ESSID"
printf "* - Configured interface\n"
ifconfig $INT up
printf "* - Interface up\n"
wpa_supplicant -B -Dwext -i$INT -c/etc/wpa_supplicant.conf
printf "* - wpa_supplicant running, sleeping for 10...\n"
sleep 10
printf "* - Running dhcpcd\n"
dhcpcd $INT
ifconfig $INT | grep inet
}

function conf_create {
printf "What is your passphrase?\n"
read "PASSPHRASE"
printf "* - running wpa_passphrase\n"
wpa_passphrase "$ESSID" "$PASSPHRASE" > /etc/wpa_supplicant.conf
printf "* - done. Starting to connect...\n"
}

if [ -f /etc/wpa_supplicant.conf ]; then
connect
else
conf_create
connect
fi

on3qrt
04-05-2007, 09:20 PM
tested it and approved it :-)

works like a charm

Hacker
04-13-2007, 03:10 AM
thanks alot

buggs187
04-13-2007, 07:09 AM
works perfect here also. Thanks

DHCP-Tom
04-30-2007, 08:42 AM
BT ~ # chmd +x wpa.sh

BT ~ # ./wpa.sh

Error:
-bash: ./wpa.sh: /usr/bin/bash^M: bad interpreter: No such file or directory

:confused:

hobbes
05-01-2007, 04:52 AM
Error:
-bash: ./wpa.sh: /usr/bin/bash^M: bad interpreter: No such file or directory


I'm not sure where that's coming from. Try copying the script over again. Or, you can test out the new version for me.



#!/usr/bin/bash

#wpa_connect script for BT2 by Hobz of #remote-exploit
#April 2, 2007
#
#
#CHANGE LOG
#
#Modified April 22 by Hobz
#added pingcheck function using ping -f flag
###

INT=$1
ESSID=$2

if [ $1 = "P" ]; then
pingcheck
exit
fi

if [ -z "$2" ]; then
printf "Usage: $0 [interface] [ESSID] <P>\n"
printf "$0 will create a /etc/wpa_supplicant.conf file if none exists\n"
printf "Default driver: wext\n"
printf "Optional: use 'P' to check signal, one dot '.' = one dropped packet\n"
printf "More dots means worse signal."
exit
fi

function connect {
ifconfig $INT down
iwconfig $INT mode managed essid "$ESSID"
printf "* - Configured interface\n"
ifconfig $INT up
printf "* - Interface up\n"
wpa_supplicant -B -Dwext -i$INT -c/etc/wpa_supplicant.conf
printf "* - wpa_supplicant running, sleeping for 10...\n"
sleep 10
printf "* - Running dhcpcd\n"
dhcpcd $INT
ifconfig $INT | grep inet
}

function conf_create {
printf "What is your passphrase?\n"
read "PASSPHRASE"
printf "* - running wpa_passphrase\n"
wpa_passphrase "$ESSID" "$PASSPHRASE" > /etc/wpa_supplicant.conf
printf "* - done. Starting to connect...\n"
}

function pingcheck {
echo "Enter host to ping, or press Enter to use default gateway: "
read "HOST"
if [ -z "$HOST" ]; then
route | grep "default" | awk '{ system("ping -w 10 -f " $2) }'
else
ping -w 10 -f $HOST
fi
}

if [ -f /etc/wpa_supplicant.conf ]; then
connect
if [ "$3" = "P" ]; then
pingcheck
fi
else
conf_create
connect
if [ "$3" = "P" ]; then
pingcheck
fi
fi

armedpilot
05-01-2007, 11:00 AM
I think that happens when you use certain Windows editors to paste and save from. In any case, check out this link http://www.freebsddiary.org/control-m.php

BT ~ # chmd +x wpa.sh

BT ~ # ./wpa.sh

Error:
-bash: ./wpa.sh: /usr/bin/bash^M: bad interpreter: No such file or directory

:confused:

DHCP-Tom
05-02-2007, 10:23 AM
Thank You !!

Paton
05-22-2007, 11:49 PM
Very nice script... well sort of....

I'm using it on a wg511t/wrt54gl setup and It runs and works fine but Klanass keeps breaking and establishing? Is tht common.

Also, Trying it on my BC4306 internal.... It connects to the router, But won't get past that... Also, don't have the intermitance issues as the 511 has.

I'm thing the BC is due to the wext Driver, but not sure how BT2 sets it up.

The 511 issue, has me, then again.. i'm not that smart in this so.

Any help would be great.

Again, nice script.

alacityathome
05-23-2007, 03:21 AM
Paton,

Breaking and establishing was common for me as well until I did one of the following (either one works):

When the error panel comes up about not connecting...ignore...and just x it out. Then, no connect and reconnects taking place.

Or, use the new wlassitant-0.5.7.1 with wpa included.

Alacrity

Paton
05-23-2007, 04:13 PM
Thanks....

Thats my next step... BT2 is miles ahead of 1 for wireless support...

Lovely job.

************EDIT****************

Odd, Today EVERYTHING is a okay!

Itssid
05-23-2007, 05:46 PM
Thanks for the script. will try when i get home and post.

shamanvirtuel
05-26-2007, 10:11 PM
sid just one word...Could you shrinken your signature ??? it's really aggressive like this with big red Fonts....

thx guy.....