modularize code, add non-interactive mode, update README, add --help

This commit is contained in:
Christopher Roy Bratusek 2016-07-24 12:36:02 +02:00
parent b8b9b326b2
commit 2d5881e6c3
2 changed files with 105 additions and 53 deletions

8
README
View File

@ -8,7 +8,7 @@ Requirements:
* Gtk+ 3 * Gtk+ 3
* sudo * sudo
Usage: Usage (interactive mode):
* run script * run script
* select wifi device * select wifi device
* select game version * select game version
@ -16,3 +16,9 @@ Usage:
* enter your password in terminal * enter your password in terminal
* in game go to Smash > Group * in game go to Smash > Group
* ... profit? * ... profit?
Usage (non-interactive mode):
* smashbroshaxer <wifi-device> <pcap-file>
* enter your password in terminal
* in game go to Smash > Group
* ... profit?

View File

@ -3,6 +3,9 @@
basedir=$(readlink -m "${BASH_SOURCE[0]}") basedir=$(readlink -m "${BASH_SOURCE[0]}")
basedir=$(dirname ${basedir}) basedir=$(dirname ${basedir})
reldate="2016/07/24"
version="2.0"
if [[ $(uname -m) == "x86_64" ]]; then if [[ $(uname -m) == "x86_64" ]]; then
YAD=${basedir}/bin/yad.64 YAD=${basedir}/bin/yad.64
AIREPLAY=${basedir}/bin/aireplay-ng.64 AIREPLAY=${basedir}/bin/aireplay-ng.64
@ -10,21 +13,46 @@ else YAD=${basedir}/bin/yad.32
AIREPLAY=${basedir}/bin/aireplay-ng.32 AIREPLAY=${basedir}/bin/aireplay-ng.32
fi fi
wireless="" smash_my_hax () {
for device in /sys/class/net/*; do
x-terminal-emulator -e /bin/bash -c \
"sudo ifconfig ${device} down && \
sudo iwconfig ${device} mode monitor && \
sudo ifconfig ${device} up && \
yes | sudo ${AIREPLAY} \
--interactive \
-r ${replay} \
-h 59:ee:3f:2a:37:e0 \
-x 20 \
${device}"
}
open_3ds_homebrew () {
xdg-open "https://smealum.github.io/3ds/"
}
open_smashbroshax () {
xdg-open "https://github.com/yellows8/3ds_smashbroshax"
}
interactive_mode () {
wireless=""
for device in /sys/class/net/*; do
[[ -e ${device}/wireless ]] && \ [[ -e ${device}/wireless ]] && \
wireless+="$(basename ${device})," wireless+="$(basename ${device}),"
done done
pcaps="" pcaps=""
for pcap in ${basedir}/pcap/*.pcap; do for pcap in ${basedir}/pcap/*.pcap; do
pcaps+="$(basename ${pcap})," pcaps+="$(basename ${pcap}),"
done done
wireless="${wireless%"${wireless##*[!,]}"}" wireless="${wireless%"${wireless##*[!,]}"}"
pcaps="${pcaps%"${pcaps##*[!,]}"}" pcaps="${pcaps%"${pcaps##*[!,]}"}"
array=($(${YAD} \ array=($(${YAD} \
--title="smashbroshax Helper" \ --title="smashbroshax Helper" \
--form \ --form \
--item-separator=, \ --item-separator=, \
@ -38,42 +66,60 @@ array=($(${YAD} \
--field="1. Select WiFi Device to use:CB" "${wireless}" \ --field="1. Select WiFi Device to use:CB" "${wireless}" \
--field="2. Select your Game version:CB" "${pcaps}" \ --field="2. Select your Game version:CB" "${pcaps}" \
--field=" --field="
3. Start game, click 'hax my smash', then to go Smash > Group 3. Start game, click 'hax my smash', then to go Smash > Group
:LBL" " "\ :LBL" " "\
--button="! hax my smash:0" \ --button="! hax my smash:0" \
--button="x cancel:1" \ --button="x cancel:1" \
--button="? 3DS Homebrew:2" \ --button="? 3DS Homebrew:2" \
--button="? smashbroshax:3")) --button="? smashbroshax:3"))
ret=$? ret=$?
device=${array[0]} device=${array[0]}
replay=${array[1]} replay=${basedir}/pcap/${array[1]}
case ${ret} in case ${ret} in
0 ) smash_my_hax ;;
0 ) 2 ) open_3ds_homebrew ;;
x-terminal-emulator -e /bin/bash -c \
"sudo ifconfig ${device} down && \
sudo iwconfig ${device} mode monitor && \
sudo ifconfig ${device} up && \
yes | sudo ${AIREPLAY} \
--interactive \
-r ${basedir}/pcap/${replay} \
-h 59:ee:3f:2a:37:e0 \
-x 20 \
${device}"
;;
2 ) 3 ) open_smashbroshax ;;
xdg-open "https://smealum.github.io/3ds/"
;;
3 ) 1 ) echo -e "\n cancelled by user \n"
xdg-open "https://github.com/yellows8/3ds_smashbroshax"
;;
1 )
echo -e "\n cancelled by user \n"
exit 1 exit 1
;;
esac
}
case ${1} in
--help )
echo -e "
smashbroshaxer version ${version} (${reldate})
usage:
smashbroshaxer | interactive (UI) mode
smashbrosaxer <wifi> <pcap> | non-interactive mode
"
;;
"" )
interactive_mode
;;
* )
if [[ -e /sys/class/net/${1}/wireless ]]; then
device=${1}
else echo -e "\nspecified device ${1} is not a wireless device!\n"
exit 1
fi
if [[ -f ${2} ]]; then
replay=$(readlink -m ${2})
else echo -e "\nspecified replay ${2} is not a pcap replay!\n"
exit 1
fi
smash_my_hax
;;
esac esac