I'm new to shell scripts and all, and wanted to write a script that would automatically perform this command for me:
sudo aireplay-ng -0 (given number) -a (Router MAC Address) -c (Target MAC address) wlx000f60071636
The script would ask for user input, then perform the command with the input of the user.
So, I referenced these pages:
http://www.aircrack-ng.org/doku.php?id=deauthentication - For Aircrack Structure
http://www.tutorialspoint.com/unix/unix-shell-functions.htm - For designing functions which would allow for different numbers instead of -0, resulting in varied commands
https://stackoverflow.com/questions/226703/how-do-i-prompt-for-input-in-a-linux-shell-script - For user input
http://www.tutorialspoint.com/unix/unix-using-variables.htm - For Variables
And using these pages, I wrote this script:
#!/bin/sh ROUTER="(my router MAC)" echo "Perform a wifi command?" select yn in "Yes" "No"; do case $yn in Yes ) Deauth; break;; No ) exit;; esac done Deauth () { sudo airmon-ng start wlx000f60071636 sudo airmon-ng check kill echo "Please specify device MAC:" read dmac echo "Number of commands to send, with 0 being unlimited:" read numts sudo aireplay-ng -0 $numts -a $ROUTER -c $dmac wlx000f60071636 }
However, after running
chmod +x wificommand.sh
and
sh wificommand.sh
I receive an error message of
wificommand.sh: 4: wificommand.sh: select: not found wificommand.sh: 9: wificommand.sh: Syntax error: "done" unexpected
What is wrong with my code? Is select unavailable to use? Why should done not be there? Is this the correct way to run a command with user input?
sh
is notbash
on your system? see for example DashAsBinSh