From c288943f668ed3ddbbffabc8f17f4ef2609f5c57 Mon Sep 17 00:00:00 2001 From: Matias Barcenas Date: Thu, 3 May 2018 18:30:56 -0500 Subject: [PATCH] Fixed two bugs related to interface allocation. Allocated interfaces were being identified with indexes in intervals of two. Reidentification failures were potentially not being detected. --- fluxion.sh | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/fluxion.sh b/fluxion.sh index f3edf8f..564462a 100755 --- a/fluxion.sh +++ b/fluxion.sh @@ -871,11 +871,15 @@ fluxion_allocate_interface() { # Reserve interfaces # Prevent interface-snatching by renaming the interface. if [ $allocatingWirelessInterface ]; then - interface_reidentify $identifier fluxwl${#FluxionInterfaces[@]} + # Get next wireless interface to add to FluxionInterfaces global. + fluxion_next_assignable_interface fluxwl else - interface_reidentify $identifier fluxet${#FluxionInterfaces[@]} + # Get next ethernet interface to add to FluxionInterfaces global. + fluxion_next_assignable_interface fluxet fi + interface_reidentify $identifier $FluxionNextAssignableInterface + if [ $? -ne 0 ]; then # If reidentifying failed, abort immediately. return 4 fi @@ -900,12 +904,12 @@ fluxion_allocate_interface() { # Reserve interfaces ) else # Attempt activating monitor mode on the interface. - if interface_set_mode fluxwl${#FluxionInterfaces[@]} monitor; then + if interface_set_mode $FluxionNextAssignableInterface monitor; then # Register the new identifier upon consecutive successes. - local -r newIdentifier=fluxwl${#FluxionInterfaces[@]} + local -r newIdentifier=$FluxionNextAssignableInterface else # If monitor-mode switch fails, undo rename and abort. - interface_reidentify fluxwl${#FluxionInterfaces[@]} $identifier + interface_reidentify $FluxionNextAssignableInterface $identifier fi fi fi @@ -930,6 +934,19 @@ fluxion_allocate_interface() { # Reserve interfaces # as the key for the global FluxionInterfaces hash/map/dictionary. } +# Parameters: +# Description: Prints next available assignable interface name. +# ------------------------------------------------------------ # +fluxion_next_assignable_interface() { + # Find next available interface by checking global. + readonly prefix=$1 + local index=0 + while [ "${FluxionInterfaces[$prefix$index]}" ]; do + let index++ + done + FluxionNextAssignableInterface="$prefix$index" +} + # Parameters: [] # Note: The interfaces lambda must print an interface per line. # ------------------------------------------------------------ #