Global targetting & framework bug fixes.

Targetting is now done via either "visual" interface or CLI flags.
Fixed bugs with the undo sequencing in the sequencing framework.
This commit is contained in:
Matias Barcenas 2018-01-16 23:09:09 -06:00
parent fb70dc0158
commit 7c0af05860
1 changed files with 113 additions and 29 deletions

126
fluxion
View File

@ -78,8 +78,8 @@ source lib/HashUtils.sh
# =================== < Parse Parameters > =================== # # =================== < Parse Parameters > =================== #
# ============================================================ # # ============================================================ #
if ! FLUXIONCLIArguments=$( if ! FLUXIONCLIArguments=$(
getopt --options="vdkrnmtl:a:" \ getopt --options="vdkrnmtb:e:c:l:a:" \
--longoptions="debug,version,killer,reloader,airmon-ng,multiplexer,target,test,language:,attack:" \ --longoptions="debug,version,killer,reloader,airmon-ng,multiplexer,target,test,bssid:,essid:,channel:,language:,attack:" \
--name="FLUXION V$FLUXIONVersion.$FLUXIONRevision" -- "$@" --name="FLUXION V$FLUXIONVersion.$FLUXIONRevision" -- "$@"
); then ); then
echo -e "${CRed}Aborted$CClr, parameter error detected..."; exit 5 echo -e "${CRed}Aborted$CClr, parameter error detected..."; exit 5
@ -105,6 +105,9 @@ while [ "$1" != "--" ]; do
-r|--reloader) declare -r FLUXIONWIReloadDriver=1;; -r|--reloader) declare -r FLUXIONWIReloadDriver=1;;
-n|--airmon-ng) declare -r FLUXIONAirmonNG=1;; -n|--airmon-ng) declare -r FLUXIONAirmonNG=1;;
-m|--multiplexer) declare -r FLUXIONTMux=1;; -m|--multiplexer) declare -r FLUXIONTMux=1;;
-b|--bssid) FluxionTargetMAC=$2; shift;;
-e|--essid) FluxionTargetSSID=$2; shift;;
-c|--channel) FluxionTargetChannel=$2; shift;;
-l|--language) FluxionLanguage=$2; shift;; -l|--language) FluxionLanguage=$2; shift;;
-a|--attack) FluxionAttack=$2; shift;; -a|--attack) FluxionAttack=$2; shift;;
esac esac
@ -473,6 +476,8 @@ fluxion_do() {
local -r __fluxion_do__namespace=$1 local -r __fluxion_do__namespace=$1
local -r __fluxion_do__identifier=$2 local -r __fluxion_do__identifier=$2
# Notice, the instruction will be adde to the Do Log
# regardless of whether it succeeded or failed to execute.
eval FXDLog_$__fluxion_do__namespace+=\("$__fluxion_do__identifier"\) eval FXDLog_$__fluxion_do__namespace+=\("$__fluxion_do__identifier"\)
eval ${__fluxion_do__namespace}_$__fluxion_do__identifier "${@:3}" eval ${__fluxion_do__namespace}_$__fluxion_do__identifier "${@:3}"
return $? return $?
@ -487,6 +492,9 @@ fluxion_undo() {
# I've reported the bug, we can add it when fixed. # I've reported the bug, we can add it when fixed.
eval local __fluxion_undo__history=\("\${FXDLog_$__fluxion_undo__namespace[@]}"\) eval local __fluxion_undo__history=\("\${FXDLog_$__fluxion_undo__namespace[@]}"\)
eval echo \$\{FXDLog_$__fluxion_undo__namespace[@]\} \
> $FLUXIONOutputDevice
local __fluxion_undo__i local __fluxion_undo__i
for (( __fluxion_undo__i=${#__fluxion_undo__history[@]}; \ for (( __fluxion_undo__i=${#__fluxion_undo__history[@]}; \
__fluxion_undo__i > 0; __fluxion_undo__i-- )); do __fluxion_undo__i > 0; __fluxion_undo__i-- )); do
@ -494,8 +502,13 @@ fluxion_undo() {
local __fluxion_undo__command=${__fluxion_undo__instruction%%_*} local __fluxion_undo__command=${__fluxion_undo__instruction%%_*}
local __fluxion_undo__identifier=${__fluxion_undo__instruction#*_} local __fluxion_undo__identifier=${__fluxion_undo__instruction#*_}
if ! eval ${__fluxion_undo__namespace}_${FLUXIONUndoable["$__fluxion_undo__command"]}_$__fluxion_undo__identifier; then echo "Do ${FLUXIONUndoable["$__fluxion_undo__command"]}_$__fluxion_undo__identifier" \
> $FLUXIONOutputDevice
if eval ${__fluxion_undo__namespace}_${FLUXIONUndoable["$__fluxion_undo__command"]}_$__fluxion_undo__identifier; then
echo "Undo-chain succeded." > $FLUXIONOutputDevice
eval FXDLog_$__fluxion_undo__namespace=\("${__fluxion_undo__history[@]::$__fluxion_undo__i}"\) eval FXDLog_$__fluxion_undo__namespace=\("${__fluxion_undo__history[@]::$__fluxion_undo__i}"\)
eval echo History\: \$\{FXDLog_$__fluxion_undo__namespace[@]\} \
> $FLUXIONOutputDevice
return 0 return 0
fi fi
done done
@ -542,30 +555,36 @@ fluxion_do_sequence() {
local -A __fluxion_do_sequence__index=() local -A __fluxion_do_sequence__index=()
local i local i
for i in $(seq ${#__fluxion_do_sequence__sequence[@]}); do for i in $(seq 0 $((${#__fluxion_do_sequence__sequence[@]} - 1))); do
__fluxion_do_sequence__index["${__fluxion_do_sequence__sequence[i-1]}"]=$i __fluxion_do_sequence__index["${__fluxion_do_sequence__sequence[i]}"]=$i
done done
# Start sequence with the first instruction available. # Start sequence with the first instruction available.
local __fluxion_do_sequence__instructionIndex=0
local __fluxion_do_sequence__instruction=${__fluxion_do_sequence__sequence[0]} local __fluxion_do_sequence__instruction=${__fluxion_do_sequence__sequence[0]}
while [ "$__fluxion_do_sequence__instruction" ]; do while [ "$__fluxion_do_sequence__instruction" ]; do
if ! fluxion_do $__fluxion_do_sequence__namespace $__fluxion_do_sequence__instruction; then if ! fluxion_do $__fluxion_do_sequence__namespace $__fluxion_do_sequence__instruction; then
if ! fluxion_undo $__fluxion_do_sequence__namespace; then $__fluxion_do_sequence__namespace if ! fluxion_undo $__fluxion_do_sequence__namespace; then
break break
fi fi
fi
# Synchronize the current instruction's index by checking last.
if ! fluxion_done $__fluxion_do_sequence__namespace; then if ! fluxion_done $__fluxion_do_sequence__namespace; then
return -3; return -3;
fi fi
local __fluxion_do_sequence__instructionIndex=${__fluxion_do_sequence__index["$FluxionDone"]} __fluxion_do_sequence__instructionIndex=${__fluxion_do_sequence__index["$FluxionDone"]}
if [ ! "$__fluxion_do_sequence__instructionIndex" ]; then if [ ! "$__fluxion_do_sequence__instructionIndex" ]; then
return -4 return -4
fi fi
else
let __fluxion_do_sequence__instructionIndex++
fi
__fluxion_do_sequence__instruction=${__fluxion_do_sequence__sequence["$__fluxion_do_sequence__instructionIndex"]} __fluxion_do_sequence__instruction=${__fluxion_do_sequence__sequence[$__fluxion_do_sequence__instructionIndex]}
echo "Next Instruction: $__fluxion_do_sequence__instruction" \
> $FLUXIONOutputDevice
done done
} }
@ -1332,7 +1351,9 @@ fluxion_hash_get() {
# ================== < Attack Subroutines > ================== # # ================== < Attack Subroutines > ================== #
fluxion_unset_attack() { fluxion_unset_attack() {
local -r attackWasSet=${FluxionAttack:+1}
FluxionAttack="" FluxionAttack=""
if [ ! "$attackWasSet" ]; then return 1; fi
} }
fluxion_set_attack() { fluxion_set_attack() {
@ -1386,6 +1407,78 @@ fluxion_set_attack() {
FluxionAttack=${IOQueryFormatFields[0]} FluxionAttack=${IOQueryFormatFields[0]}
} }
fluxion_unset_attack_target() {
FluxionTargetMAC=""
FluxionTargetSSID=""
FluxionTargetChannel=""
FluxionTargetEncryption=""
FluxionTargetMakerID=""
FluxionTargetMaker=""
FluxionTargetSSIDClean=""
FluxionTargetRogueMAC=""
return 1 # To trigger undo-chain.
}
fluxion_set_attack_target() {
# Check if attack is targetted & set the attack target if so.
if ! type -t attack_targetting_interfaces &> /dev/null; then
return 1
fi
if [ \
"$FluxionTargetSSID" -a \
"$FluxionTargetMAC" -a \
"$FluxionTargetChannel" \
]; then
fluxion_header
fluxion_target_show
echo
echo -e "$FLUXIONVLine $FLUXIONTargettingAccessPointAboveNotice"
# TODO: This doesn't translate choices to the selected language.
while ! echo "$choice" | grep -q "^[ynYN]$" &> /dev/null; do
echo -ne "$FLUXIONVLine $FLUXIONContinueWithTargetQuery [Y/n] "
local choice
read choice
if [ ! "$choice" ]; then break; fi
done
echo -ne "\n\n"
if [ "${choice,,}" != "n" ]; then
return 0
fi
elif [ \
"$FluxionTargetSSID" -o \
"$FluxionTargetMAC" -o \
"$FluxionTargetChannel" \
]; then
# TODO: Survey environment here to autofill missing fields.
# In other words, if a user gives incomplete information, scan
# the environment based on either the ESSID or BSSID, & autofill.
echo -e "$FLUXIONVLine $FLUXIONIncompleteTargettingInfoNotice"
sleep 3
fi
if ! fluxion_get_interface attack_targetting_interfaces; then
return 2
fi
if ! fluxion_allocate_interface $FluxionInterfaceSelected; then
return 3
fi
if ! fluxion_get_target \
${FluxionInterfaces[$FluxionInterfaceSelected]}; then
return 4
fi
}
fluxion_unprep_attack() { fluxion_unprep_attack() {
if type -t unprep_attack &> /dev/null; then if type -t unprep_attack &> /dev/null; then
unprep_attack unprep_attack
@ -1408,21 +1501,12 @@ fluxion_prep_attack() {
source "$path/language/$FluxionLanguage.sh" source "$path/language/$FluxionLanguage.sh"
source "$path/attack.sh" source "$path/attack.sh"
# Check if attack is targetted & set the attack target. # Check if attack is targetted & set the attack target if so.
if type -t attack_targetting_interfaces &> /dev/null; then if type -t attack_targetting_interfaces &> /dev/null; then
if ! fluxion_get_interface attack_targetting_interfaces; then if ! fluxion_set_attack_target; then return 3; fi
return 3
fi
if ! fluxion_allocate_interface $FluxionInterfaceSelected; then
return 4
fi
if ! fluxion_get_target \
${FluxionInterfaces[$FluxionInterfaceSelected]}; then
return 5
fi
fi fi
if ! prep_attack "$@"; then return 6; fi if ! prep_attack "$@"; then return 4; fi
} }
fluxion_run_attack() { fluxion_run_attack() {