#!/usr/bin/perl -w # # Version 1.3 # # Another in a long line of stupid scripts # ...This one to connect to open or WEP "secured" AP's # ChangeLog: 7 Jun, 07 - added static IP choice # 29MAY08 - added WPA capability # 30JAN09 - added ndiswrapper capability # # Coded by a poo flinging monkey in the bowels of the cybersniper research labs # printf "\nCoded by pfm\@cybersniper research labs...\n\n"; printf "\nEnter the ESSID you want to connect to: "; $ap = ; chomp($ap); printf "\nEnter the channel the AP is operating on: "; $ch = ; chomp($ch); printf "\nEnter your local wireless interface [ex: ath0, wlan0]: "; $int = ; chomp($int); printf "\nDo you need WEP\/WPA [ Y or N]: "; $wep = uc; chomp($wep); if ($wep eq "N") { printf "\nUnprotected? Excellent...release the hounds!\n"; nowep(); } else { printf "\nSelect [1] WEP or [2] WPA: "; $sel = ; chomp($sel); #} if ($sel eq "1") { printf "\nEnter your WEP key: "; $key = ; chomp($key); wep(); } else { wpa(); } } # Sub sections to do stuff below here sub wep { system "iwconfig $int channel $ch"; system "iwconfig $int essid $ap"; system "iwconfig $int key $key"; dhcp(); } sub nowep { system "iwconfig $int key off"; system "iwconfig $int essid $ap"; system "iwconfig $int channel $ch"; dhcp(); } # static called by dhcp below sub static { printf "enter your static IP address: "; $stat = ; chomp($stat); system "ifconfig $int $stat"; } sub wpa { my $MODULE = `lsmod | grep r8187 | head -n 1 | awk {'print \$1'}`; for ($MODULE) { s/\s+$//; } if ($MODULE eq "r8187") { r8187(); } else { printf "\nIf wpa_supplicant is running we will kill it\n"; system "killall -9 wpa_supplicant"; system "iwconfig $int channel $ch"; printf "\nReading from your /etc/wpa_supplicant.conf file\n"; printf "if this is not the correct file or you need to make changes to it\n"; printf "CTRL-C to abort, else hit ENTER to continue\n\n"; $junk = ; $conf = "/etc/wpa_supplicant.conf"; system "ifconfig $int up"; system "wpa_supplicant -B -Dwext -i$int -c$conf"; dhcp(); } } sub r8187 { system "modprobe -r r8187"; printf "\nLoading the correct module\n"; system "cp /tmp/auto-ndis/ndiswrapper /etc/modprobe.d/ndiswrapper"; system "modprobe ndiswrapper"; printf "\nIf wpa_supplicant is running we will kill it\n"; system "killall -9 wpa_supplicant"; system "iwconfig $int channel $ch"; printf "\nReading from your /etc/wpa_supplicant.conf file\n"; printf "if this is not the correct file or you need to make changes to it\n"; printf "CTRL-C to abort, else hit ENTER to continue\n\n"; $junk = ; $conf = "/etc/wpa_supplicant.conf"; system "ifconfig $int up"; system "wpa_supplicant -B -Dwext -i$int -c$conf"; system "rm /etc/modprobe.d/ndiswrapper"; dhcp(); } sub dhcp { printf "\nWhat is your DHCP Client?\n"; printf "1. dhclient - Found in debian, knoppix and others\n"; printf "2. dhcpcd - Slackware & Backtrack among others\n"; printf "3. Static - I'll add my own IP!\n"; printf "Enter your choice: "; $dc = ; chomp($dc); if ($dc == 1) { $dc = "dhclient"; } elsif ($dc == 3) { static(); exit 0; } else { system "dhcpcd -k $int"; $dc = "dhcpcd"; } printf "sleeping 2 seconds to allow the connection to take...\n"; sleep(2); system "$dc $int"; } exit