Finished implementation of airmon-ng independence.
This commit is contained in:
parent
dd33314fa8
commit
75d015af5c
70
fluxion.sh
70
fluxion.sh
|
@ -40,6 +40,7 @@ FLUXIONPrompt="$CRed[${CBlu}fluxion$CYel@$CClr$HOSTNAME$CRed]-[$CYel~$CRed]$CClr
|
||||||
FLUXIONVLine="$CRed[$CYel*$CRed]$CClr"
|
FLUXIONVLine="$CRed[$CYel*$CRed]$CClr"
|
||||||
|
|
||||||
################################# < Library Includes > #################################
|
################################# < Library Includes > #################################
|
||||||
|
source lib/InterfaceUtils.sh
|
||||||
source lib/SandboxUtils.sh
|
source lib/SandboxUtils.sh
|
||||||
source lib/FormatUtils.sh
|
source lib/FormatUtils.sh
|
||||||
source lib/IOUtils.sh
|
source lib/IOUtils.sh
|
||||||
|
@ -48,6 +49,8 @@ source lib/HashUtils.sh
|
||||||
source language/English.lang
|
source language/English.lang
|
||||||
|
|
||||||
################################ < Library Parameters > ################################
|
################################ < Library Parameters > ################################
|
||||||
|
InterfaceUtilsOutputDevice="$FLUXIONOutputDevice"
|
||||||
|
|
||||||
SandboxWorkspacePath="$FLUXIONWorkspacePath"
|
SandboxWorkspacePath="$FLUXIONWorkspacePath"
|
||||||
SandboxOutputDevice="$FLUXIONOutputDevice"
|
SandboxOutputDevice="$FLUXIONOutputDevice"
|
||||||
|
|
||||||
|
@ -98,7 +101,7 @@ function exitmode() {
|
||||||
|
|
||||||
if [ "$WIMonitor" ]; then
|
if [ "$WIMonitor" ]; then
|
||||||
echo -e "$CWht[$CRed-$CWht] $FLUXIONDisablingMonitorNotice$CGrn $WIMonitor$CClr"
|
echo -e "$CWht[$CRed-$CWht] $FLUXIONDisablingMonitorNotice$CGrn $WIMonitor$CClr"
|
||||||
airmon-ng stop $WIMonitor &> $FLUXIONOutputDevice
|
interface_set_mode "$WIMonitor" "managed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "$CWht[$CRed-$CWht] $FLUXIONRestoringTputNotice$CClr"
|
echo -e "$CWht[$CRed-$CWht] $FLUXIONRestoringTputNotice$CClr"
|
||||||
|
@ -443,11 +446,12 @@ function unset_interface() {
|
||||||
# Remove all monitor-mode & all AP interfaces.
|
# Remove all monitor-mode & all AP interfaces.
|
||||||
echo -e "$FLUXIONVLine $FLUXIONRemovingExtraWINotice"
|
echo -e "$FLUXIONVLine $FLUXIONRemovingExtraWINotice"
|
||||||
if [ ${#WIMonitors[@]} -gt 0 ]; then
|
if [ ${#WIMonitors[@]} -gt 0 ]; then
|
||||||
|
local monitor
|
||||||
for monitor in ${WIMonitors[@]}; do
|
for monitor in ${WIMonitors[@]}; do
|
||||||
# Replace interface's mon with ap & remove interface.
|
# 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.
|
# Remove monitoring interface after AP interface.
|
||||||
airmon-ng stop $monitor > $FLUXIONOutputDevice
|
interface_set_mode "$monitor" "managed"
|
||||||
|
|
||||||
if [ $FLUXIONDebug ]; then
|
if [ $FLUXIONDebug ]; then
|
||||||
echo -e "Stopped $monitor."
|
echo -e "Stopped $monitor."
|
||||||
|
@ -468,35 +472,38 @@ function set_interface() {
|
||||||
# Gather candidate interfaces.
|
# Gather candidate interfaces.
|
||||||
echo -e "$FLUXIONVLine $FLUXIONFindingWINotice"
|
echo -e "$FLUXIONVLine $FLUXIONFindingWINotice"
|
||||||
|
|
||||||
# Create an array with the list of all available wireless network interfaces.
|
# List of all available wireless network interfaces.
|
||||||
local WIAvailableData
|
# These will be stored in our array right below.
|
||||||
readarray -t WIAvailableData < <(airmon-ng | grep -P 'wl(an\d+|\w+)' | sed -r 's/[ ]{2,}|\t+/:_:/g')
|
interface_list_wireless
|
||||||
local WIAvailableDataCount=${#WIAvailableData[@]}
|
|
||||||
local WIAvailable=()
|
local WIAvailable=("${InterfaceListWireless[@]}")
|
||||||
local WIAvailableInfo=()
|
local WIAvailableInfo=()
|
||||||
local WIAvailableColor=()
|
local WIAvailableColor=()
|
||||||
|
|
||||||
for (( i = 0; i < WIAvailableDataCount; i++ )); do
|
local wiCandidate
|
||||||
local data="${WIAvailableData[i]}"
|
for wiCandidate in "${WIAvailable[@]}"; do
|
||||||
WIAvailable[i]=$(echo "$data" | awk -F':_:' '{print $2}')
|
interface_chipset "$wiCandidate"
|
||||||
WIAvailableInfo[i]=$(echo "$data" | awk -F':_:' '{print $4}')
|
WIAvailableInfo+=("$InterfaceChipset")
|
||||||
if [ "`ifconfig ${WIAvailable[i]} | grep "RUNNING"`" ]; then
|
|
||||||
WIAvailableColor[i]="$CPrp"
|
interface_state "$wiCandidate"
|
||||||
WIAvailableState[i]="-"
|
|
||||||
else
|
if [ "$InterfaceState" = "up" ]
|
||||||
WIAvailableColor[i]="$CClr"
|
then WIAvailableColor+=("$CPrp"); WIAvailableState+=("-")
|
||||||
WIAvailableState[i]="+"
|
else WIAvailableColor+=("$CClr"); WIAvailableState+=("+")
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
WIAvailable[${#WIAvailable[@]}]="$FLUXIONGeneralRepeatOption"
|
# We'll add an extra option here, the back command.
|
||||||
WIAvailableColor[${#WIAvailableColor[@]}]="$CClr" # (Increases record count)
|
# Color must be incresed since it's the first array,
|
||||||
WIAvailableState[${#WIAvailableState[@]}]="x"
|
# and the io function checks only the first's size.
|
||||||
|
WIAvailableColor+=("$CClr") # (Increases record count)
|
||||||
|
WIAvailable+=("$FLUXIONGeneralRepeatOption")
|
||||||
|
WIAvailableState+=("x")
|
||||||
|
|
||||||
local WISelected
|
local WISelected
|
||||||
local WISelectedState
|
local WISelectedState
|
||||||
if [ $WIAvailableDataCount -ge 1 -a ${WIAvailableState[0]} = "+" -a \
|
if [ ${#WIAvailable[@]} -ge 1 -a ${WIAvailableState[0]} = "+" -a \
|
||||||
$WIAvailableDataCount -eq 1 -o "$FLUXIONAuto" ]; then
|
${#WIAvailable[@]} -eq 1 -o "$FLUXIONAuto" ]; then
|
||||||
WISelected="${WIAvailable[0]}"
|
WISelected="${WIAvailable[0]}"
|
||||||
WISelectedState="+" # It passed the condition, it must be +
|
WISelectedState="+" # It passed the condition, it must be +
|
||||||
else
|
else
|
||||||
|
@ -524,7 +531,8 @@ function set_interface() {
|
||||||
if [ $FLUXIONDropNet ]; then
|
if [ $FLUXIONDropNet ]; then
|
||||||
# Get selected interface's driver details/info-descriptor.
|
# Get selected interface's driver details/info-descriptor.
|
||||||
echo -e "$FLUXIONVLine $FLUXIONGatheringWIInfoNotice"
|
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.
|
# I'm not really sure about this conditional here.
|
||||||
# FLUXION 2 had the conditional so I kept it there.
|
# FLUXION 2 had the conditional so I kept it there.
|
||||||
|
@ -534,6 +542,7 @@ function set_interface() {
|
||||||
|
|
||||||
# Get list of potentially troublesome programs.
|
# Get list of potentially troublesome programs.
|
||||||
echo -e "$FLUXIONVLine $FLUXIONFindingConflictingProcessesNotice"
|
echo -e "$FLUXIONVLine $FLUXIONFindingConflictingProcessesNotice"
|
||||||
|
# This shit has to go reeeeeal soon (airmon-ng)...
|
||||||
ConflictPrograms=($(airmon-ng check | awk 'NR>6{print $2}'))
|
ConflictPrograms=($(airmon-ng check | awk 'NR>6{print $2}'))
|
||||||
|
|
||||||
# Kill potentially troublesome programs.
|
# Kill potentially troublesome programs.
|
||||||
|
@ -559,15 +568,16 @@ function set_interface() {
|
||||||
function run_interface() {
|
function run_interface() {
|
||||||
# Activate wireless interface monitor mode and save identifier.
|
# Activate wireless interface monitor mode and save identifier.
|
||||||
echo -e "$FLUXIONVLine $FLUXIONStartingWIMonitorNotice"
|
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.
|
# Create an identifier for the access point, AP virtual interface.
|
||||||
# The identifier will follow this structure: wlanXap, where X is
|
# The identifier will follow this structure: wl[identifier]FluxAP
|
||||||
# the integer assigned to the original interface, wlanXmon.
|
WIAccessPoint="${WIMonitor}FXap"
|
||||||
# In alternative systems, the strcture is: wl*ap and wl*mon.
|
|
||||||
WIAccessPoint=${WIMonitor/mon/ap}
|
|
||||||
|
|
||||||
# Create the new virtual interface with the generated identifier.
|
# Create the new virtual interface with the generated identifier.
|
||||||
echo -e "$FLUXIONVLine $FLUXIONStartingWIAccessPointNotice"
|
echo -e "$FLUXIONVLine $FLUXIONStartingWIAccessPointNotice"
|
||||||
|
|
|
@ -97,3 +97,22 @@ function interface_chipset() {
|
||||||
esac
|
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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue