From ea1824b5cad2a3d4230bce3d9a2329a28cd58d84 Mon Sep 17 00:00:00 2001 From: Matias Barcenas Date: Thu, 17 Aug 2017 17:37:44 -0500 Subject: [PATCH 1/9] Started implementing airmon-ng independence. --- lib/InterfaceUtils.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lib/InterfaceUtils.sh diff --git a/lib/InterfaceUtils.sh b/lib/InterfaceUtils.sh new file mode 100644 index 0000000..3b1ddfc --- /dev/null +++ b/lib/InterfaceUtils.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# The methods used in this script are taken from airmon-ng. +# This is all thanks for the airmon-ng authors, thanks guys. + +function interface_list_all() { + InterfaceListAll=($(ls -1 /sys/class/net)) +} + +function interface_list_wireless() { + InterfaceListWireless=() + interface_list_all + local __interface_list_wireless__candidate + for __interface_list_wireless__candidate in "${InterfaceListAll[@]}"; do + if grep -q "DEVTYPE=wlan" /sys/class/net/$__interface_list_wireless__candidate/uevent 2> /dev/null + then InterfaceListWireless+=("$__interface_list_wireless__candidate") + fi + done +} From 4092d969f7a8e7fa4a26946edcab7d396aa0909f Mon Sep 17 00:00:00 2001 From: Matias Barcenas Date: Thu, 17 Aug 2017 17:45:48 -0500 Subject: [PATCH 2/9] Suppressed grep file not found error. --- lib/InterfaceUtils.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/InterfaceUtils.sh b/lib/InterfaceUtils.sh index 3b1ddfc..73743a1 100644 --- a/lib/InterfaceUtils.sh +++ b/lib/InterfaceUtils.sh @@ -12,7 +12,7 @@ function interface_list_wireless() { interface_list_all local __interface_list_wireless__candidate for __interface_list_wireless__candidate in "${InterfaceListAll[@]}"; do - if grep -q "DEVTYPE=wlan" /sys/class/net/$__interface_list_wireless__candidate/uevent 2> /dev/null + if grep -qs "DEVTYPE=wlan" /sys/class/net/$__interface_list_wireless__candidate/uevent then InterfaceListWireless+=("$__interface_list_wireless__candidate") fi done From 21ae874efbacca4e1bc012075ce95414ce76fb47 Mon Sep 17 00:00:00 2001 From: Matias Barcenas Date: Thu, 17 Aug 2017 18:01:17 -0500 Subject: [PATCH 3/9] Added driver finder method (thanks to Guilles@stackoverflow). --- lib/InterfaceUtils.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/InterfaceUtils.sh b/lib/InterfaceUtils.sh index 73743a1..0ef16a4 100644 --- a/lib/InterfaceUtils.sh +++ b/lib/InterfaceUtils.sh @@ -17,3 +17,11 @@ function interface_list_wireless() { fi done } + +function interface_driver() { + InterfaceDriver=$(basename $(readlink /sys/class/net/$1/device/driver)) +} + +function interface_chipset() { + echo +} From e6058201cb2871a78b6f4e95bf6fcd2fe036dea3 Mon Sep 17 00:00:00 2001 From: Matias Barcenas Date: Thu, 17 Aug 2017 23:11:21 -0500 Subject: [PATCH 4/9] Implemented physical, hardware & chipset for InterfaceUtils. --- lib/InterfaceUtils.sh | 76 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 74 insertions(+), 2 deletions(-) diff --git a/lib/InterfaceUtils.sh b/lib/InterfaceUtils.sh index 0ef16a4..b1ebd32 100644 --- a/lib/InterfaceUtils.sh +++ b/lib/InterfaceUtils.sh @@ -3,6 +3,16 @@ # The methods used in this script are taken from airmon-ng. # This is all thanks for the airmon-ng authors, thanks guys. +InterfaceUtilsOutputDevice="/dev/stdout" + +if [ -d /sys/bus/usb ] # && hash lsusb +then InterfaceUSBBus=1 +fi + +if [ -d /sys/bus/pci ] || [ -d /sys/bus/pci_express ] || [ -d /proc/bus/pci ] # && hash lspci +then InterfacePCIBus=1 +fi + function interface_list_all() { InterfaceListAll=($(ls -1 /sys/class/net)) } @@ -22,6 +32,68 @@ function interface_driver() { InterfaceDriver=$(basename $(readlink /sys/class/net/$1/device/driver)) } -function interface_chipset() { - echo +function interface_physical() { + if [ ! "$1" ]; then return 1; fi + + unset InterfacePhysical + + local -r interface_physical_path="/sys/class/net/$1/phy80211" + + if [ -d "$interface_physical_path" ]; then + if [ -r "$interface_physical_path/name" ] + then InterfacePhysical="`cat "$interface_physical_path/name"`" + else InterfacePhysical="`ls -l "$interface_physical_path" | sed 's/^.*\/\([a-zA-Z0-9_-]*\)$/\1/'`" + fi + fi + + if [ ! "$InterfacePhysical" ]; then return 2; fi } + +function interface_hardware() { + if [ ! "$1" ]; then return 1; fi + + local __interface_hardware__device="/sys/class/net/$1/device" + local __interface_hardware__hwinfo="$__interface_hardware__device/modalias" + + InterfaceHardwareBus="`cut -d ":" -f 1 "$__interface_chipset__hwinfo" 2> $InterfaceUtilsOutputDevice`" + + case "$InterfaceHardwareBus" in + "usb") # Wanted to replace the line below with awk, but i'll probably just add complexity & issues (mawk vs gawk). + InterfaceHardwareID="`cut -d ":" -f 2 $__interface_chipset__hwinfo | cut -b 1-10 | sed 's/^.//;s/p/:/'`";; + "pci" | "pcmcia" | "sdio") + InterfaceHardwareID="`cat "$__interface_hardware__device/vendor" 2> $InterfaceUtilsOutputDevice`:`cat "$__interface_hardware__device/device" 2> $InterfaceUtilsOutputDevice`";; + default) # The following will only work for USB devices. + InterfaceHardwareID="`cat "$__interface_hardware__device/idVendor" 2> $InterfaceUtilsOutputDevice`:`cat "$__interface_hardware__device/idProduct" 2> $InterfaceUtilsOutputDevice`";; + InterfaceHardwareBus="usb" # This will be reset below if InterfaceHardwareID is invalid. + esac + + # Check for invalid InterfaceHardwareID (starts or ends with :) .. not a happy face, still won't quote it. + if echo "$InterfaceHardwareID" | egrep -q "^:|:$"; then + unset InterfaceHardwareID + unset InterfaceHardwareBus + return 2 + fi +} + +function interface_chipset() { + if [ ! "$1" ]; then return 1; fi + + if ! interface_hardware "$1"; then return 2; fi + + case "$InterfaceHardwareBus" in + "usb") + if [ ! "$InterfaceUSBBus" ]; then return 3; fi + InterfaceChipset="`lsusb -d "$InterfaceHardwareID" | head -n1 - | cut -f3- -d ":" | sed 's/^....//;s/ Network Connection//g;s/ Wireless Adapter//g;s/^ //'`" + "pci" | "pcmcia") + if [ ! "$InterfacePCIBus" ]; then return 4; fi + InterfaceChipset="$(lspci -d $InterfaceHardwareID | cut -f3- -d ":" | sed 's/Wireless LAN Controller //g;s/ Network Connection//g;s/ Wireless Adapter//;s/^ //')" + "sdio") + if [[ "${InterfaceHardwareID,,}" = "0x02d0"* ]] + then InterfaceChipset=$(printf "Broadcom %d" ${InterfaceHardwareID:7}) + else InterfaceChipset="Unknown chipset for SDIO device." + fi;; + default) + InterfaceChipset="Unknown device chipset & device bus." + esac +} + From dd33314fa832142f979715a965a17e56715a0923 Mon Sep 17 00:00:00 2001 From: Matias Barcenas Date: Thu, 17 Aug 2017 23:24:29 -0500 Subject: [PATCH 5/9] Fixed minor bugs affecting InterfaceUtils. --- lib/InterfaceUtils.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/InterfaceUtils.sh b/lib/InterfaceUtils.sh index b1ebd32..95e1eb7 100644 --- a/lib/InterfaceUtils.sh +++ b/lib/InterfaceUtils.sh @@ -55,16 +55,16 @@ function interface_hardware() { local __interface_hardware__device="/sys/class/net/$1/device" local __interface_hardware__hwinfo="$__interface_hardware__device/modalias" - InterfaceHardwareBus="`cut -d ":" -f 1 "$__interface_chipset__hwinfo" 2> $InterfaceUtilsOutputDevice`" + InterfaceHardwareBus="`cut -d ":" -f 1 "$__interface_hardware__hwinfo" 2> $InterfaceUtilsOutputDevice`" case "$InterfaceHardwareBus" in "usb") # Wanted to replace the line below with awk, but i'll probably just add complexity & issues (mawk vs gawk). - InterfaceHardwareID="`cut -d ":" -f 2 $__interface_chipset__hwinfo | cut -b 1-10 | sed 's/^.//;s/p/:/'`";; + InterfaceHardwareID="`cut -d ":" -f 2 $__interface_hardware__hwinfo | cut -b 1-10 | sed 's/^.//;s/p/:/'`";; "pci" | "pcmcia" | "sdio") InterfaceHardwareID="`cat "$__interface_hardware__device/vendor" 2> $InterfaceUtilsOutputDevice`:`cat "$__interface_hardware__device/device" 2> $InterfaceUtilsOutputDevice`";; default) # The following will only work for USB devices. - InterfaceHardwareID="`cat "$__interface_hardware__device/idVendor" 2> $InterfaceUtilsOutputDevice`:`cat "$__interface_hardware__device/idProduct" 2> $InterfaceUtilsOutputDevice`";; - InterfaceHardwareBus="usb" # This will be reset below if InterfaceHardwareID is invalid. + InterfaceHardwareID="`cat "$__interface_hardware__device/idVendor" 2> $InterfaceUtilsOutputDevice`:`cat "$__interface_hardware__device/idProduct" 2> $InterfaceUtilsOutputDevice`" + InterfaceHardwareBus="usb";; # This will be reset below if InterfaceHardwareID is invalid. esac # Check for invalid InterfaceHardwareID (starts or ends with :) .. not a happy face, still won't quote it. @@ -83,10 +83,10 @@ function interface_chipset() { case "$InterfaceHardwareBus" in "usb") if [ ! "$InterfaceUSBBus" ]; then return 3; fi - InterfaceChipset="`lsusb -d "$InterfaceHardwareID" | head -n1 - | cut -f3- -d ":" | sed 's/^....//;s/ Network Connection//g;s/ Wireless Adapter//g;s/^ //'`" + InterfaceChipset="`lsusb -d "$InterfaceHardwareID" | head -n1 - | cut -f3- -d ":" | sed 's/^....//;s/ Network Connection//g;s/ Wireless Adapter//g;s/^ //'`";; "pci" | "pcmcia") if [ ! "$InterfacePCIBus" ]; then return 4; fi - InterfaceChipset="$(lspci -d $InterfaceHardwareID | cut -f3- -d ":" | sed 's/Wireless LAN Controller //g;s/ Network Connection//g;s/ Wireless Adapter//;s/^ //')" + InterfaceChipset="$(lspci -d $InterfaceHardwareID | cut -f3- -d ":" | sed 's/Wireless LAN Controller //g;s/ Network Connection//g;s/ Wireless Adapter//;s/^ //')";; "sdio") if [[ "${InterfaceHardwareID,,}" = "0x02d0"* ]] then InterfaceChipset=$(printf "Broadcom %d" ${InterfaceHardwareID:7}) From 75d015af5c9b2e1cefa4a7fa91f5e6fd0a6408a5 Mon Sep 17 00:00:00 2001 From: Matias Barcenas Date: Fri, 18 Aug 2017 01:52:51 -0500 Subject: [PATCH 6/9] Finished implementation of airmon-ng independence. --- fluxion.sh | 72 ++++++++++++++++++++++++------------------- lib/InterfaceUtils.sh | 19 ++++++++++++ 2 files changed, 60 insertions(+), 31 deletions(-) diff --git a/fluxion.sh b/fluxion.sh index 284bf15..4004ffb 100755 --- a/fluxion.sh +++ b/fluxion.sh @@ -40,6 +40,7 @@ FLUXIONPrompt="$CRed[${CBlu}fluxion$CYel@$CClr$HOSTNAME$CRed]-[$CYel~$CRed]$CClr FLUXIONVLine="$CRed[$CYel*$CRed]$CClr" ################################# < Library Includes > ################################# +source lib/InterfaceUtils.sh source lib/SandboxUtils.sh source lib/FormatUtils.sh source lib/IOUtils.sh @@ -48,6 +49,8 @@ source lib/HashUtils.sh source language/English.lang ################################ < Library Parameters > ################################ +InterfaceUtilsOutputDevice="$FLUXIONOutputDevice" + SandboxWorkspacePath="$FLUXIONWorkspacePath" SandboxOutputDevice="$FLUXIONOutputDevice" @@ -98,7 +101,7 @@ function exitmode() { if [ "$WIMonitor" ]; then echo -e "$CWht[$CRed-$CWht] $FLUXIONDisablingMonitorNotice$CGrn $WIMonitor$CClr" - airmon-ng stop $WIMonitor &> $FLUXIONOutputDevice + interface_set_mode "$WIMonitor" "managed" fi echo -e "$CWht[$CRed-$CWht] $FLUXIONRestoringTputNotice$CClr" @@ -443,11 +446,12 @@ function unset_interface() { # Remove all monitor-mode & all AP interfaces. echo -e "$FLUXIONVLine $FLUXIONRemovingExtraWINotice" if [ ${#WIMonitors[@]} -gt 0 ]; then + local monitor for monitor in ${WIMonitors[@]}; do # Replace interface's mon with ap & remove interface. - iw dev ${monitor/mon/ap} del 2> $FLUXIONOutputDevice + iw dev "${monitor}FXap" del 2> $FLUXIONOutputDevice # Remove monitoring interface after AP interface. - airmon-ng stop $monitor > $FLUXIONOutputDevice + interface_set_mode "$monitor" "managed" if [ $FLUXIONDebug ]; then echo -e "Stopped $monitor." @@ -468,35 +472,38 @@ function set_interface() { # Gather candidate interfaces. echo -e "$FLUXIONVLine $FLUXIONFindingWINotice" - # Create an array with the list of all available wireless network interfaces. - local WIAvailableData - readarray -t WIAvailableData < <(airmon-ng | grep -P 'wl(an\d+|\w+)' | sed -r 's/[ ]{2,}|\t+/:_:/g') - local WIAvailableDataCount=${#WIAvailableData[@]} - local WIAvailable=() + # List of all available wireless network interfaces. + # These will be stored in our array right below. + interface_list_wireless + + local WIAvailable=("${InterfaceListWireless[@]}") local WIAvailableInfo=() local WIAvailableColor=() - for (( i = 0; i < WIAvailableDataCount; i++ )); do - local data="${WIAvailableData[i]}" - WIAvailable[i]=$(echo "$data" | awk -F':_:' '{print $2}') - WIAvailableInfo[i]=$(echo "$data" | awk -F':_:' '{print $4}') - if [ "`ifconfig ${WIAvailable[i]} | grep "RUNNING"`" ]; then - WIAvailableColor[i]="$CPrp" - WIAvailableState[i]="-" - else - WIAvailableColor[i]="$CClr" - WIAvailableState[i]="+" + local wiCandidate + for wiCandidate in "${WIAvailable[@]}"; do + interface_chipset "$wiCandidate" + WIAvailableInfo+=("$InterfaceChipset") + + interface_state "$wiCandidate" + + if [ "$InterfaceState" = "up" ] + then WIAvailableColor+=("$CPrp"); WIAvailableState+=("-") + else WIAvailableColor+=("$CClr"); WIAvailableState+=("+") fi done - WIAvailable[${#WIAvailable[@]}]="$FLUXIONGeneralRepeatOption" - WIAvailableColor[${#WIAvailableColor[@]}]="$CClr" # (Increases record count) - WIAvailableState[${#WIAvailableState[@]}]="x" + # We'll add an extra option here, the back command. + # Color must be incresed since it's the first array, + # and the io function checks only the first's size. + WIAvailableColor+=("$CClr") # (Increases record count) + WIAvailable+=("$FLUXIONGeneralRepeatOption") + WIAvailableState+=("x") local WISelected local WISelectedState - if [ $WIAvailableDataCount -ge 1 -a ${WIAvailableState[0]} = "+" -a \ - $WIAvailableDataCount -eq 1 -o "$FLUXIONAuto" ]; then + if [ ${#WIAvailable[@]} -ge 1 -a ${WIAvailableState[0]} = "+" -a \ + ${#WIAvailable[@]} -eq 1 -o "$FLUXIONAuto" ]; then WISelected="${WIAvailable[0]}" WISelectedState="+" # It passed the condition, it must be + else @@ -524,7 +531,8 @@ function set_interface() { if [ $FLUXIONDropNet ]; then # Get selected interface's driver details/info-descriptor. echo -e "$FLUXIONVLine $FLUXIONGatheringWIInfoNotice" - WIDriver=$(airmon-ng | grep $WISelected | awk '{print $3}') + interface_driver "$WISelected" + WIDriver="$InterfaceDriver" # I'm not really sure about this conditional here. # FLUXION 2 had the conditional so I kept it there. @@ -534,6 +542,7 @@ function set_interface() { # Get list of potentially troublesome programs. echo -e "$FLUXIONVLine $FLUXIONFindingConflictingProcessesNotice" + # This shit has to go reeeeeal soon (airmon-ng)... ConflictPrograms=($(airmon-ng check | awk 'NR>6{print $2}')) # Kill potentially troublesome programs. @@ -559,16 +568,17 @@ function set_interface() { function run_interface() { # Activate wireless interface monitor mode and save identifier. echo -e "$FLUXIONVLine $FLUXIONStartingWIMonitorNotice" - WIMonitor=$(airmon-ng start $WISelected | awk -F'\[phy[0-9]+\]|\)' '$0~/monitor .* enabled/{print $3}' 2> /dev/null) + if interface_set_mode "$WISelected" "monitor" + then echo -e "$FLUXIONVLine ${CGrn}Interface successfully switched to monitor mode."; sleep 3 + else echo -e "$FLUXIONVLine ${CRed}Interface failed to switch to monitor mode!"; sleep 5; return 1 + fi - # TODO: Verify the monitor interface was successfully created. + WIMonitor=$WISelected # Create an identifier for the access point, AP virtual interface. - # The identifier will follow this structure: wlanXap, where X is - # the integer assigned to the original interface, wlanXmon. - # In alternative systems, the strcture is: wl*ap and wl*mon. - WIAccessPoint=${WIMonitor/mon/ap} - + # The identifier will follow this structure: wl[identifier]FluxAP + WIAccessPoint="${WIMonitor}FXap" + # Create the new virtual interface with the generated identifier. echo -e "$FLUXIONVLine $FLUXIONStartingWIAccessPointNotice" if [ `iw dev $WIMonitor interface add $WIAccessPoint type monitor` ]; then diff --git a/lib/InterfaceUtils.sh b/lib/InterfaceUtils.sh index 95e1eb7..1ae01cf 100644 --- a/lib/InterfaceUtils.sh +++ b/lib/InterfaceUtils.sh @@ -97,3 +97,22 @@ function interface_chipset() { esac } +function interface_state() { + if [ ! "$1" ]; then return 1; fi + local __interface_state__stateFile="/sys/class/net/$1/operstate" + + if [ ! -f "$__interface_state__stateFile" ]; then return 2; fi + InterfaceState=$(cat "$__interface_state__stateFile") +} + +function interface_set_state() { + if [ "${#@}" -ne 2 ]; then return 1; fi + ip link set "$1" "$2" +} + +function interface_set_mode() { + if [ "${#@}" -ne 2 ]; then return 1; fi + if ! interface_set_state "$1" "down"; then return 2; fi + if ! iwconfig "$1" mode "$2" &> $InterfaceUtilsOutputDevice; then return 3; fi + if ! interface_set_state "$1" "up"; then return 4; fi +} From bf388e526023b093fda0078d5f3801e1df3ab518 Mon Sep 17 00:00:00 2001 From: Matias Barcenas Date: Fri, 18 Aug 2017 02:39:52 -0500 Subject: [PATCH 7/9] Fixed a bug with xterm's background color. --- attacks/Captive Portal/attack.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/attacks/Captive Portal/attack.sh b/attacks/Captive Portal/attack.sh index d4da3e5..49327b2 100644 --- a/attacks/Captive Portal/attack.sh +++ b/attacks/Captive Portal/attack.sh @@ -74,7 +74,7 @@ function captive_portal_set_auth() { } function captive_portal_run_certificate_generator() { - xterm -title "Generating Self-Signed SSL Certificate" -e openssl req -subj '/CN=captive.router.lan/O=CaptivePortal/OU=Networking/C=US' -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout "$FLUXIONWorkspacePath/server.pem" -out "$FLUXIONWorkspacePath/server.pem" # more details there https://www.openssl.org/docs/manmaster/apps/openssl.html + xterm -bg "#000000" -fg "#CCCCCC" -title "Generating Self-Signed SSL Certificate" -e openssl req -subj '/CN=captive.router.lan/O=CaptivePortal/OU=Networking/C=US' -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout "$FLUXIONWorkspacePath/server.pem" -out "$FLUXIONWorkspacePath/server.pem" # more details there https://www.openssl.org/docs/manmaster/apps/openssl.html chmod 400 "$FLUXIONWorkspacePath/server.pem" } @@ -835,7 +835,7 @@ function start_attack() { xterm $FLUXIONHoldXterm $BOTTOMRIGHT -bg "#000000" -fg "#FF0009" -title "FLUXION AP Jammer [mdk3] $APTargetSSID" -e mdk3 $WIMonitor d -b "$FLUXIONWorkspacePath/mdk3_blacklist.lst" -c $APTargetChannel & echo -e "$FLUXIONVLine $CaptivePortalStartingAuthenticatorServiceNotice" - xterm -hold $TOPRIGHT -title "FLUXION AP Authenticator" -e "$FLUXIONWorkspacePath/captive_portal_authenticator.sh" & + xterm -hold $TOPRIGHT -bg "#000000" -fg "#CCCCCC" -title "FLUXION AP Authenticator" -e "$FLUXIONWorkspacePath/captive_portal_authenticator.sh" & } # FLUXSCRIPT END From ebcc1e4b6dd2bb88173e8fe2637aeabb9e7bcfa7 Mon Sep 17 00:00:00 2001 From: Matias Barcenas Date: Fri, 18 Aug 2017 11:12:38 -0500 Subject: [PATCH 8/9] Fixed a bug with authenticator's signal handlers. --- attacks/Captive Portal/attack.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/attacks/Captive Portal/attack.sh b/attacks/Captive Portal/attack.sh index 49327b2..21ac815 100644 --- a/attacks/Captive Portal/attack.sh +++ b/attacks/Captive Portal/attack.sh @@ -357,6 +357,7 @@ if __name__ == '__main__': function signal_stop_attack() { kill -s SIGABRT $$ # Signal STOP ATTACK + handle_abort_authenticator } function handle_abort_authenticator() { From 2a16e9dafcbce6b8e070547ed474bb5c4e3a366b Mon Sep 17 00:00:00 2001 From: Matias Barcenas Date: Fri, 18 Aug 2017 15:15:55 -0500 Subject: [PATCH 9/9] Added airmon-ng as optional monitor-mode switcher. --- fluxion.sh | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/fluxion.sh b/fluxion.sh index 4004ffb..864f4bb 100755 --- a/fluxion.sh +++ b/fluxion.sh @@ -60,6 +60,9 @@ IOUtilsPrompt="$FLUXIONPrompt" HashOutputDevice="$FLUXIONOutputDevice" +################################# < User Preferences > ################################# +if [ -x "$FLUXIONPath/preferences.sh" ]; then source "$FLUXIONPath/preferences.sh"; fi + ######################################################################################## if [[ $EUID -ne 0 ]]; then echo -e "${CRed}You don't have admin privilegies, execute the script as root.$CClr" @@ -101,7 +104,10 @@ function exitmode() { if [ "$WIMonitor" ]; then echo -e "$CWht[$CRed-$CWht] $FLUXIONDisablingMonitorNotice$CGrn $WIMonitor$CClr" - interface_set_mode "$WIMonitor" "managed" + if [ "$FLUXIONAirmonNG" ] + then airmon-ng stop "$WIMonitor" &> $FLUXIONOutputDevice + else interface_set_mode "$WIMonitor" "managed" + fi fi echo -e "$CWht[$CRed-$CWht] $FLUXIONRestoringTputNotice$CClr" @@ -210,7 +216,6 @@ function handle_exit() { # to execute cleanup and reset commands. trap handle_exit SIGINT SIGHUP -# Design function fluxion_header() { format_apply_autosize "[%*s]\n" local verticalBorder=$FormatApplyAutosize @@ -448,10 +453,14 @@ function unset_interface() { if [ ${#WIMonitors[@]} -gt 0 ]; then local monitor for monitor in ${WIMonitors[@]}; do - # Replace interface's mon with ap & remove interface. - iw dev "${monitor}FXap" del 2> $FLUXIONOutputDevice + # Remove any previously created fluxion AP interfaces. + iw dev "${monitor}FLXap" del 2> $FLUXIONOutputDevice + # Remove monitoring interface after AP interface. - interface_set_mode "$monitor" "managed" + if [[ "$monitor" = *"mon" ]] + then airmon-ng stop "$monitor" > $FLUXIONOutputDevice + else interface_set_mode "$monitor" "managed" + fi if [ $FLUXIONDebug ]; then echo -e "Stopped $monitor." @@ -568,16 +577,24 @@ function set_interface() { function run_interface() { # Activate wireless interface monitor mode and save identifier. echo -e "$FLUXIONVLine $FLUXIONStartingWIMonitorNotice" - if interface_set_mode "$WISelected" "monitor" - then echo -e "$FLUXIONVLine ${CGrn}Interface successfully switched to monitor mode."; sleep 3 - else echo -e "$FLUXIONVLine ${CRed}Interface failed to switch to monitor mode!"; sleep 5; return 1 + if [ "$FLUXIONAirmonNG" ]; then + # TODO: Need to check weather switching to monitor mode below failed. + WIMonitor=$(airmon-ng start $WISelected | awk -F'\[phy[0-9]+\]|\)' '$0~/monitor .* enabled/{print $3}' 2> /dev/null) + else + if interface_set_mode "$WISelected" "monitor" + then WIMonitor=$WISelected + else WIMonitor="" + fi fi - WIMonitor=$WISelected + if [ "$WIMonitor" ] + then echo -e "$FLUXIONVLine ${CGrn}Interface monitor mode switch succeeded."; sleep 3 + else echo -e "$FLUXIONVLine ${CRed}Interface monitor mode switch failed!"; sleep 3; return 1 + fi # Create an identifier for the access point, AP virtual interface. - # The identifier will follow this structure: wl[identifier]FluxAP - WIAccessPoint="${WIMonitor}FXap" + # The identifier will follow this structure: wl[identifier]FLXap + WIAccessPoint="${WISelected}FLXap" # Create the new virtual interface with the generated identifier. echo -e "$FLUXIONVLine $FLUXIONStartingWIAccessPointNotice"