2018-05-02 12:50:31 -06:00
|
|
|
#!/usr/bin/env bash
|
2018-01-05 17:32:57 -07:00
|
|
|
|
|
|
|
# ============================================================ #
|
|
|
|
# ================== < FLUXION Parameters > ================== #
|
|
|
|
# ============================================================ #
|
|
|
|
# Path to directory containing the FLUXION executable script.
|
2018-07-10 16:41:38 -06:00
|
|
|
readonly FLUXIONPath=$(dirname $(readlink -f "$0"))
|
2018-05-24 17:44:53 -06:00
|
|
|
|
|
|
|
# Path to directory containing the FLUXION library (scripts).
|
|
|
|
readonly FLUXIONLibPath="$FLUXIONPath/lib"
|
2018-01-05 17:32:57 -07:00
|
|
|
|
|
|
|
# Path to the temp. directory available to FLUXION & subscripts.
|
2018-01-31 05:53:13 -07:00
|
|
|
readonly FLUXIONWorkspacePath="/tmp/fluxspace"
|
2018-02-01 08:22:40 -07:00
|
|
|
readonly FLUXIONIPTablesBackup="$FLUXIONPath/iptables-rules"
|
2018-01-05 17:32:57 -07:00
|
|
|
|
|
|
|
# Path to FLUXION's preferences file, to be loaded afterward.
|
2018-03-13 12:37:45 -06:00
|
|
|
readonly FLUXIONPreferencesFile="$FLUXIONPath/preferences/preferences.conf"
|
2018-01-05 17:32:57 -07:00
|
|
|
|
|
|
|
# Constants denoting the reference noise floor & ceiling levels.
|
|
|
|
# These are used by the the wireless network scanner visualizer.
|
2018-01-31 05:53:13 -07:00
|
|
|
readonly FLUXIONNoiseFloor=-90
|
|
|
|
readonly FLUXIONNoiseCeiling=-60
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-01-31 05:53:13 -07:00
|
|
|
readonly FLUXIONVersion=4
|
2018-07-11 23:04:26 -06:00
|
|
|
readonly FLUXIONRevision=14
|
2018-01-31 05:53:13 -07:00
|
|
|
|
|
|
|
# Declare window ration bigger = smaller windows
|
|
|
|
FLUXIONWindowRatio=4
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-05-29 16:47:13 -06:00
|
|
|
# Allow to skip dependencies if required, not recommended
|
|
|
|
FLUXIONSkipDependencies=0
|
|
|
|
|
2018-01-05 17:32:57 -07:00
|
|
|
# ============================================================ #
|
|
|
|
# ================= < Script Sanity Checks > ================= #
|
|
|
|
# ============================================================ #
|
2018-01-09 13:43:40 -07:00
|
|
|
if [ $EUID -ne 0 ]; then # Super User Check
|
2018-07-10 14:50:19 -06:00
|
|
|
echo -e "\\033[31mAborted, please execute the script as root.\\033[0m"; exit 1
|
2018-01-05 17:32:57 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
# ===================== < XTerm Checks > ===================== #
|
2018-01-09 00:46:40 -07:00
|
|
|
# TODO: Run the checks below only if we're not using tmux.
|
2018-01-09 13:43:40 -07:00
|
|
|
if [ ! "${DISPLAY:-}" ]; then # Assure display is available.
|
2018-07-10 14:50:19 -06:00
|
|
|
echo -e "\\033[31mAborted, X (graphical) session unavailable.\\033[0m"; exit 2
|
2018-01-05 17:32:57 -07:00
|
|
|
fi
|
|
|
|
|
2018-01-09 13:43:40 -07:00
|
|
|
if ! hash xdpyinfo 2>/dev/null; then # Assure display probe.
|
2018-07-10 14:50:19 -06:00
|
|
|
echo -e "\\033[31mAborted, xdpyinfo is unavailable.\\033[0m"; exit 3
|
2018-01-05 17:32:57 -07:00
|
|
|
fi
|
|
|
|
|
2018-01-09 13:43:40 -07:00
|
|
|
if ! xdpyinfo &>/dev/null; then # Assure display info available.
|
2018-07-10 14:50:19 -06:00
|
|
|
echo -e "\\033[31mAborted, xterm test session failed.\\033[0m"; exit 3
|
2018-01-05 17:32:57 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
# ================ < Parameter Parser Check > ================ #
|
|
|
|
getopt --test > /dev/null # Assure enhanced getopt (returns 4).
|
2018-01-09 13:43:40 -07:00
|
|
|
if [ $? -ne 4 ]; then
|
2018-07-10 14:50:19 -06:00
|
|
|
echo "\\033[31mAborted, enhanced getopt isn't available.\\033[0m"; exit 4
|
2018-01-05 17:32:57 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
# =============== < Working Directory Check > ================ #
|
2018-01-09 13:43:40 -07:00
|
|
|
if ! mkdir -p "$FLUXIONWorkspacePath" &> /dev/null; then
|
2018-07-10 14:50:19 -06:00
|
|
|
echo "\\033[31mAborted, can't generate a workspace directory.\\033[0m"; exit 5
|
2018-01-05 17:32:57 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Once sanity check is passed, we can start to load everything.
|
|
|
|
|
|
|
|
# ============================================================ #
|
|
|
|
# =================== < Library Includes > =================== #
|
|
|
|
# ============================================================ #
|
2018-05-30 11:55:07 -06:00
|
|
|
source "$FLUXIONLibPath/installer/InstallerUtils.sh"
|
|
|
|
source "$FLUXIONLibPath/InterfaceUtils.sh"
|
|
|
|
source "$FLUXIONLibPath/SandboxUtils.sh"
|
|
|
|
source "$FLUXIONLibPath/FormatUtils.sh"
|
|
|
|
source "$FLUXIONLibPath/ColorUtils.sh"
|
|
|
|
source "$FLUXIONLibPath/IOUtils.sh"
|
|
|
|
source "$FLUXIONLibPath/HashUtils.sh"
|
|
|
|
source "$FLUXIONLibPath/Help.sh"
|
2018-01-05 17:32:57 -07:00
|
|
|
|
|
|
|
# NOTE: These are configured after arguments are loaded (later).
|
|
|
|
|
|
|
|
# ============================================================ #
|
|
|
|
# =================== < Parse Parameters > =================== #
|
|
|
|
# ============================================================ #
|
2018-01-09 12:36:29 -07:00
|
|
|
if ! FLUXIONCLIArguments=$(
|
2018-03-14 13:04:44 -06:00
|
|
|
getopt --options="vdkrnmtbhe:c:l:a:r" \
|
2018-05-29 16:47:13 -06:00
|
|
|
--longoptions="debug,version,killer,reloader,help,airmon-ng,multiplexer,target,test,auto,bssid:,essid:,channel:,language:,attack:,ratio,skip-dependencies" \
|
2018-01-09 12:36:29 -07:00
|
|
|
--name="FLUXION V$FLUXIONVersion.$FLUXIONRevision" -- "$@"
|
|
|
|
); then
|
|
|
|
echo -e "${CRed}Aborted$CClr, parameter error detected..."; exit 5
|
2018-01-05 17:32:57 -07:00
|
|
|
fi
|
|
|
|
|
2018-03-14 13:04:44 -06:00
|
|
|
AttackCLIArguments=${FLUXIONCLIArguments##* -- }
|
|
|
|
readonly FLUXIONCLIArguments=${FLUXIONCLIArguments%%-- *}
|
|
|
|
if [ "$AttackCLIArguments" = "$FLUXIONCLIArguments" ]; then
|
|
|
|
AttackCLIArguments=""
|
|
|
|
fi
|
2018-01-05 17:32:57 -07:00
|
|
|
|
|
|
|
|
|
|
|
# ============================================================ #
|
|
|
|
# ================== < Load Configurables > ================== #
|
|
|
|
# ============================================================ #
|
|
|
|
|
|
|
|
# ============= < Argument Loaded Configurables > ============ #
|
|
|
|
eval set -- "$FLUXIONCLIArguments" # Set environment parameters.
|
|
|
|
|
2018-05-04 12:03:58 -06:00
|
|
|
#[ "$1" != "--" ] && readonly FLUXIONAuto=1 # Auto-mode if using CLI.
|
2018-07-10 14:50:19 -06:00
|
|
|
while [ "$1" != "" ] && [ "$1" != "--" ]; do
|
2018-01-05 17:32:57 -07:00
|
|
|
case "$1" in
|
|
|
|
-v|--version) echo "FLUXION V$FLUXIONVersion.$FLUXIONRevision"; exit;;
|
2018-01-31 06:57:43 -07:00
|
|
|
-h|--help) fluxion_help; exit;;
|
2018-01-31 05:53:13 -07:00
|
|
|
-d|--debug) readonly FLUXIONDebug=1;;
|
|
|
|
-k|--killer) readonly FLUXIONWIKillProcesses=1;;
|
|
|
|
-r|--reloader) readonly FLUXIONWIReloadDriver=1;;
|
|
|
|
-n|--airmon-ng) readonly FLUXIONAirmonNG=1;;
|
|
|
|
-m|--multiplexer) readonly FLUXIONTMux=1;;
|
2018-01-16 22:09:09 -07:00
|
|
|
-b|--bssid) FluxionTargetMAC=$2; shift;;
|
2018-01-20 01:54:55 -07:00
|
|
|
-e|--essid) FluxionTargetSSID=$2;
|
2018-03-16 16:34:28 -06:00
|
|
|
# TODO: Rearrange declarations to have routines available for use here.
|
2018-05-28 07:17:27 -06:00
|
|
|
FluxionTargetSSIDClean=$(echo "$FluxionTargetSSID" | sed -r 's/( |\/|\.|\~|\\)+/_/g')
|
2018-01-20 01:54:55 -07:00
|
|
|
shift;;
|
2018-01-16 22:09:09 -07:00
|
|
|
-c|--channel) FluxionTargetChannel=$2; shift;;
|
2018-01-09 13:43:40 -07:00
|
|
|
-l|--language) FluxionLanguage=$2; shift;;
|
|
|
|
-a|--attack) FluxionAttack=$2; shift;;
|
2018-05-04 12:03:58 -06:00
|
|
|
--ratio) FLUXIONWindowRatio=$2; shift;;
|
|
|
|
--auto) readonly FLUXIONAuto=1;;
|
2018-05-29 16:47:13 -06:00
|
|
|
--skip-dependencies) readonly FLUXIONSkipDependencies=1;;
|
2018-01-05 17:32:57 -07:00
|
|
|
esac
|
|
|
|
shift # Shift new parameters
|
|
|
|
done
|
|
|
|
|
|
|
|
shift # Remove "--" to prepare for attacks to read parameters.
|
|
|
|
# Executable arguments are handled after subroutine definition.
|
|
|
|
|
|
|
|
# =================== < User Preferences > =================== #
|
|
|
|
# Load user-defined preferences if there's an executable script.
|
2018-01-09 00:46:40 -07:00
|
|
|
# If no script exists, prepare one for the user to store config.
|
2018-01-05 17:32:57 -07:00
|
|
|
# WARNING: Preferences file must assure no redeclared constants.
|
2018-03-13 12:37:45 -06:00
|
|
|
if [ -x "$FLUXIONPreferencesFile" ]; then
|
|
|
|
source "$FLUXIONPreferencesFile"
|
2018-01-09 00:46:40 -07:00
|
|
|
else
|
2018-05-02 12:50:31 -06:00
|
|
|
echo '#!/usr/bin/env bash' > "$FLUXIONPreferencesFile"
|
2018-03-13 12:37:45 -06:00
|
|
|
chmod u+x "$FLUXIONPreferencesFile"
|
2018-01-05 17:32:57 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
# ================ < Configurable Constants > ================ #
|
2018-01-09 13:43:40 -07:00
|
|
|
if [ "$FLUXIONAuto" != "1" ]; then # If defined, assure 1.
|
2018-01-31 05:53:13 -07:00
|
|
|
readonly FLUXIONAuto=${FLUXIONAuto:+1}
|
2018-01-05 17:32:57 -07:00
|
|
|
fi
|
|
|
|
|
2018-01-09 13:43:40 -07:00
|
|
|
if [ "$FLUXIONDebug" != "1" ]; then # If defined, assure 1.
|
2018-01-31 05:53:13 -07:00
|
|
|
readonly FLUXIONDebug=${FLUXIONDebug:+1}
|
2018-01-05 17:32:57 -07:00
|
|
|
fi
|
|
|
|
|
2018-01-09 13:43:40 -07:00
|
|
|
if [ "$FLUXIONAirmonNG" != "1" ]; then # If defined, assure 1.
|
2018-01-31 05:53:13 -07:00
|
|
|
readonly FLUXIONAirmonNG=${FLUXIONAirmonNG:+1}
|
2018-01-05 17:32:57 -07:00
|
|
|
fi
|
|
|
|
|
2018-01-09 13:43:40 -07:00
|
|
|
if [ "$FLUXIONWIKillProcesses" != "1" ]; then # If defined, assure 1.
|
2018-01-31 05:53:13 -07:00
|
|
|
readonly FLUXIONWIKillProcesses=${FLUXIONWIKillProcesses:+1}
|
2018-01-05 17:32:57 -07:00
|
|
|
fi
|
|
|
|
|
2018-01-09 13:43:40 -07:00
|
|
|
if [ "$FLUXIONWIReloadDriver" != "1" ]; then # If defined, assure 1.
|
2018-01-31 05:53:13 -07:00
|
|
|
readonly FLUXIONWIReloadDriver=${FLUXIONWIReloadDriver:+1}
|
2018-01-05 17:32:57 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
# FLUXIONDebug [Normal Mode "" / Developer Mode 1]
|
|
|
|
if [ $FLUXIONDebug ]; then
|
2018-07-10 14:50:19 -06:00
|
|
|
:> /tmp/fluxion_debug_log
|
2018-04-22 05:21:49 -06:00
|
|
|
readonly FLUXIONOutputDevice="/tmp/fluxion_debug_log"
|
2018-01-31 05:53:13 -07:00
|
|
|
readonly FLUXIONHoldXterm="-hold"
|
2018-01-05 17:32:57 -07:00
|
|
|
else
|
2018-01-31 05:53:13 -07:00
|
|
|
readonly FLUXIONOutputDevice="/dev/null"
|
|
|
|
readonly FLUXIONHoldXterm=""
|
2018-01-05 17:32:57 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
# ================ < Configurable Variables > ================ #
|
2018-01-31 05:53:13 -07:00
|
|
|
readonly FLUXIONPromptDefault="$CRed[${CSBlu}fluxion$CSYel@$CSWht$HOSTNAME$CClr$CRed]-[$CSYel~$CClr$CRed]$CClr "
|
2018-01-05 17:32:57 -07:00
|
|
|
FLUXIONPrompt=$FLUXIONPromptDefault
|
|
|
|
|
2018-01-31 05:53:13 -07:00
|
|
|
readonly FLUXIONVLineDefault="$CRed[$CSYel*$CClr$CRed]$CClr"
|
2018-01-05 17:32:57 -07:00
|
|
|
FLUXIONVLine=$FLUXIONVLineDefault
|
|
|
|
|
|
|
|
# ================== < Library Parameters > ================== #
|
2018-01-31 05:53:13 -07:00
|
|
|
readonly InterfaceUtilsOutputDevice="$FLUXIONOutputDevice"
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-01-31 05:53:13 -07:00
|
|
|
readonly SandboxWorkspacePath="$FLUXIONWorkspacePath"
|
|
|
|
readonly SandboxOutputDevice="$FLUXIONOutputDevice"
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-01-31 05:53:13 -07:00
|
|
|
readonly InstallerUtilsWorkspacePath="$FLUXIONWorkspacePath"
|
|
|
|
readonly InstallerUtilsOutputDevice="$FLUXIONOutputDevice"
|
|
|
|
readonly InstallerUtilsNoticeMark="$FLUXIONVLine"
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-01-31 05:53:13 -07:00
|
|
|
readonly PackageManagerLog="$InstallerUtilsWorkspacePath/package_manager.log"
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-04-22 05:21:49 -06:00
|
|
|
declare IOUtilsHeader="fluxion_header"
|
2018-01-31 05:53:13 -07:00
|
|
|
readonly IOUtilsQueryMark="$FLUXIONVLine"
|
|
|
|
readonly IOUtilsPrompt="$FLUXIONPrompt"
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-01-31 05:53:13 -07:00
|
|
|
readonly HashOutputDevice="$FLUXIONOutputDevice"
|
2018-01-05 17:32:57 -07:00
|
|
|
|
|
|
|
# ============================================================ #
|
|
|
|
# =================== < Default Language > =================== #
|
|
|
|
# ============================================================ #
|
|
|
|
# Set by default in case fluxion is aborted before setting one.
|
|
|
|
source "$FLUXIONPath/language/en.sh"
|
|
|
|
|
|
|
|
# ============================================================ #
|
|
|
|
# ================== < Startup & Shutdown > ================== #
|
|
|
|
# ============================================================ #
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_startup() {
|
2018-01-05 17:32:57 -07:00
|
|
|
if [ "$FLUXIONDebug" ]; then return 1; fi
|
|
|
|
|
2018-01-31 05:20:33 -07:00
|
|
|
# Make sure that we save the iptable files
|
2018-02-01 08:22:40 -07:00
|
|
|
iptables-save >"$FLUXIONIPTablesBackup"
|
2018-01-09 12:36:29 -07:00
|
|
|
local banner=()
|
|
|
|
|
|
|
|
format_center_literals \
|
|
|
|
" ⌠▓▒▓▒ ⌠▓╗ ⌠█┐ ┌█ ┌▓\ /▓┐ ⌠▓╖ ⌠◙▒▓▒◙ ⌠█\ ☒┐"
|
|
|
|
banner+=("$FormatCenterLiterals")
|
|
|
|
format_center_literals \
|
|
|
|
" ║▒_ │▒║ │▒║ ║▒ \▒\/▒/ │☢╫ │▒┌╤┐▒ ║▓▒\ ▓║"
|
|
|
|
banner+=("$FormatCenterLiterals")
|
|
|
|
format_center_literals \
|
|
|
|
" ≡◙◙ ║◙║ ║◙║ ║◙ ◙◙ ║¤▒ ║▓║☯║▓ ♜◙\✪\◙♜"
|
|
|
|
banner+=("$FormatCenterLiterals")
|
|
|
|
format_center_literals \
|
|
|
|
" ║▒ │▒║__ │▒└_┘▒ /▒/\▒\ │☢╫ │▒└╧┘▒ ║█ \▒█║"
|
|
|
|
banner+=("$FormatCenterLiterals")
|
|
|
|
format_center_literals \
|
|
|
|
" ⌡▓ ⌡◘▒▓▒ ⌡◘▒▓▒◘ └▓/ \▓┘ ⌡▓╝ ⌡◙▒▓▒◙ ⌡▓ \▓┘"
|
|
|
|
banner+=("$FormatCenterLiterals")
|
|
|
|
format_center_literals \
|
|
|
|
"¯¯¯ ¯¯¯¯¯¯ ¯¯¯¯¯¯¯ ¯¯¯ ¯¯¯ ¯¯¯¯ ¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯"
|
|
|
|
banner+=("$FormatCenterLiterals")
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-07-11 23:04:26 -06:00
|
|
|
clear
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-05-28 07:17:27 -06:00
|
|
|
if [ "$FLUXIONAuto" ]; then echo -e "$CBlu"; else echo -e "$CRed"; fi
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-01-09 13:43:40 -07:00
|
|
|
for line in "${banner[@]}"; do
|
|
|
|
echo "$line"; sleep 0.05
|
2018-01-05 17:32:57 -07:00
|
|
|
done
|
|
|
|
|
|
|
|
echo # Do not remove.
|
|
|
|
|
|
|
|
sleep 0.1
|
2018-01-09 12:36:29 -07:00
|
|
|
local -r fluxionRepository="https://github.com/FluxionNetwork/fluxion"
|
|
|
|
format_center_literals "${CGrn}Site: ${CRed}$fluxionRepository$CClr"
|
2018-01-05 17:32:57 -07:00
|
|
|
echo -e "$FormatCenterLiterals"
|
|
|
|
|
|
|
|
sleep 0.1
|
2018-01-09 12:36:29 -07:00
|
|
|
local -r versionInfo="${CSRed}FLUXION $FLUXIONVersion$CClr"
|
|
|
|
local -r revisionInfo="(rev. $CSBlu$FLUXIONRevision$CClr)"
|
2018-01-19 12:59:15 -07:00
|
|
|
local -r credits="by$CCyn FluxionNetwork$CClr"
|
2018-01-09 12:36:29 -07:00
|
|
|
format_center_literals "$versionInfo $revisionInfo $credits"
|
2018-01-05 17:32:57 -07:00
|
|
|
echo -e "$FormatCenterLiterals"
|
|
|
|
|
|
|
|
sleep 0.1
|
2018-01-09 12:36:29 -07:00
|
|
|
local -r fluxionDomain="raw.githubusercontent.com"
|
|
|
|
local -r fluxionPath="FluxionNetwork/fluxion/master/fluxion.sh"
|
|
|
|
local -r updateDomain="github.com"
|
|
|
|
local -r updatePath="FluxionNetwork/fluxion/archive/master.zip"
|
|
|
|
if installer_utils_check_update "https://$fluxionDomain/$fluxionPath" \
|
|
|
|
"FLUXIONVersion=" "FLUXIONRevision=" \
|
|
|
|
$FLUXIONVersion $FLUXIONRevision; then
|
|
|
|
installer_utils_run_update "https://$updateDomain/$updatePath" \
|
2018-04-25 03:08:57 -06:00
|
|
|
"FLUXION-V$FLUXIONVersion.$FLUXIONRevision" "$FLUXIONPath"
|
|
|
|
fluxion_shutdown
|
2018-01-05 17:32:57 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo # Do not remove.
|
|
|
|
|
2018-01-09 12:36:29 -07:00
|
|
|
local requiredCLITools=(
|
|
|
|
"aircrack-ng" "python2:python2.7|python2" "bc" "awk:awk|gawk|mawk"
|
2018-05-05 08:08:43 -06:00
|
|
|
"curl" "cowpatty" "dhcpd:isc-dhcp-server|dhcp" "7zr:p7zip" "hostapd" "lighttpd"
|
2018-06-16 07:16:24 -06:00
|
|
|
"iwconfig:wireless-tools" "macchanger" "mdk3" "nmap" "openssl"
|
2018-01-09 12:36:29 -07:00
|
|
|
"php-cgi" "pyrit" "xterm" "rfkill" "unzip" "route:net-tools"
|
|
|
|
"fuser:psmisc" "killall:psmisc"
|
|
|
|
)
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-05-29 16:47:13 -06:00
|
|
|
if [ $FLUXIONSkipDependencies != 1 ];then
|
|
|
|
while ! installer_utils_check_dependencies requiredCLITools[@]; do
|
2018-05-29 17:02:25 -06:00
|
|
|
if ! installer_utils_run_dependencies InstallerUtilsCheckDependencies[@]; then
|
|
|
|
echo
|
|
|
|
echo -e "${CRed}Dependency installation failed!$CClr"
|
|
|
|
echo "Press enter to retry, ctrl+c to exit..."
|
2018-07-10 14:50:19 -06:00
|
|
|
read -r bullshit
|
2018-05-29 17:02:25 -06:00
|
|
|
fi
|
2018-05-29 16:47:13 -06:00
|
|
|
done
|
|
|
|
fi
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-07-10 14:50:19 -06:00
|
|
|
echo -e "\\n\\n" # This echo is for spacing
|
2018-01-05 17:32:57 -07:00
|
|
|
}
|
|
|
|
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_shutdown() {
|
2018-01-05 17:32:57 -07:00
|
|
|
if [ $FLUXIONDebug ]; then return 1; fi
|
|
|
|
|
|
|
|
# Show the header if the subroutine has already been loaded.
|
2018-01-09 13:43:40 -07:00
|
|
|
if type -t fluxion_header &> /dev/null; then
|
|
|
|
fluxion_header
|
2018-01-05 17:32:57 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo -e "$CWht[$CRed-$CWht]$CRed $FLUXIONCleanupAndClosingNotice$CClr"
|
|
|
|
|
2018-01-09 12:36:29 -07:00
|
|
|
# Get running processes we might have to kill before exiting.
|
2018-01-05 17:32:57 -07:00
|
|
|
local processes
|
|
|
|
readarray processes < <(ps -A)
|
|
|
|
|
|
|
|
# Currently, fluxion is only responsible for killing airodump-ng, since
|
|
|
|
# fluxion explicitly uses it to scan for candidate target access points.
|
|
|
|
# NOTICE: Processes started by subscripts, such as an attack script,
|
2018-01-09 12:36:29 -07:00
|
|
|
# MUST BE TERMINATED BY THAT SCRIPT in the subscript's abort handler.
|
2018-01-05 17:32:57 -07:00
|
|
|
local -r targets=("airodump-ng")
|
|
|
|
|
|
|
|
local targetID # Program identifier/title
|
|
|
|
for targetID in "${targets[@]}"; do
|
|
|
|
# Get PIDs of all programs matching targetPID
|
2018-07-10 14:50:19 -06:00
|
|
|
local targetPID
|
|
|
|
targetPID=$(
|
2018-01-09 12:36:29 -07:00
|
|
|
echo "${processes[@]}" | awk '$4~/'"$targetID"'/{print $1}'
|
|
|
|
)
|
2018-01-05 17:32:57 -07:00
|
|
|
if [ ! "$targetPID" ]; then continue; fi
|
|
|
|
echo -e "$CWht[$CRed-$CWht] `io_dynamic_output $FLUXIONKillingProcessNotice`"
|
|
|
|
kill -s SIGKILL $targetPID &> $FLUXIONOutputDevice
|
|
|
|
done
|
|
|
|
|
|
|
|
# Assure changes are reverted if installer was activated.
|
|
|
|
if [ "$PackageManagerCLT" ]; then
|
2018-01-09 12:36:29 -07:00
|
|
|
echo -e "$CWht[$CRed-$CWht] "$(
|
|
|
|
io_dynamic_output "$FLUXIONRestoringPackageManagerNotice"
|
|
|
|
)"$CClr"
|
2018-03-13 15:01:28 -06:00
|
|
|
# Notice: The package manager has already been restored at this point.
|
|
|
|
# InstallerUtils assures the manager is restored after running operations.
|
2018-01-05 17:32:57 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
# If allocated interfaces exist, deallocate them now.
|
|
|
|
if [ ${#FluxionInterfaces[@]} -gt 0 ]; then
|
|
|
|
local interface
|
|
|
|
for interface in "${!FluxionInterfaces[@]}"; do
|
|
|
|
# Only deallocate fluxion or airmon-ng created interfaces.
|
2018-05-19 15:01:50 -06:00
|
|
|
if [[ "$interface" == "flux"* || "$interface" == *"mon"* || "$interface" == "prism"* ]]; then
|
2018-01-05 17:32:57 -07:00
|
|
|
fluxion_deallocate_interface $interface
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2018-02-01 08:22:40 -07:00
|
|
|
echo -e "$CWht[$CRed-$CWht] $FLUXIONDisablingCleaningIPTablesNotice$CClr"
|
|
|
|
if [ -f "$FLUXIONIPTablesBackup" ]; then
|
|
|
|
iptables-restore <"$FLUXIONIPTablesBackup" \
|
|
|
|
&> $FLUXIONOutputDevice
|
|
|
|
else
|
|
|
|
iptables --flush
|
|
|
|
iptables --table nat --flush
|
|
|
|
iptables --delete-chain
|
|
|
|
iptables --table nat --delete-chain
|
|
|
|
fi
|
|
|
|
|
2018-01-05 17:32:57 -07:00
|
|
|
echo -e "$CWht[$CRed-$CWht] $FLUXIONRestoringTputNotice$CClr"
|
|
|
|
tput cnorm
|
|
|
|
|
|
|
|
if [ ! $FLUXIONDebug ]; then
|
|
|
|
echo -e "$CWht[$CRed-$CWht] $FLUXIONDeletingFilesNotice$CClr"
|
|
|
|
sandbox_remove_workfile "$FLUXIONWorkspacePath/*"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $FLUXIONWIKillProcesses ]; then
|
|
|
|
echo -e "$CWht[$CRed-$CWht] $FLUXIONRestartingNetworkManagerNotice$CClr"
|
|
|
|
|
|
|
|
# TODO: Add support for other network managers (wpa_supplicant?).
|
2018-07-10 14:50:19 -06:00
|
|
|
if [ ! -x "$(command -v systemctl)" ]; then
|
|
|
|
if [ -x "$(command -v service)" ];then
|
2018-02-01 08:22:40 -07:00
|
|
|
service network-manager restart &> $FLUXIONOutputDevice &
|
|
|
|
service networkmanager restart &> $FLUXIONOutputDevice &
|
|
|
|
service networking restart &> $FLUXIONOutputDevice &
|
|
|
|
fi
|
2018-01-05 17:32:57 -07:00
|
|
|
else
|
|
|
|
systemctl restart network-manager.service &> $FLUXIONOutputDevice &
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo -e "$CWht[$CGrn+$CWht] $CGrn$FLUXIONCleanupSuccessNotice$CClr"
|
|
|
|
echo -e "$CWht[$CGrn+$CWht] $CGry$FLUXIONThanksSupportersNotice$CClr"
|
|
|
|
|
|
|
|
sleep 3
|
|
|
|
|
2018-07-11 23:04:26 -06:00
|
|
|
clear
|
2018-01-05 17:32:57 -07:00
|
|
|
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# ============================================================ #
|
|
|
|
# ================= < Handler Subroutines > ================== #
|
|
|
|
# ============================================================ #
|
|
|
|
# Delete log only in Normal Mode !
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_conditional_clear() {
|
2018-01-05 17:32:57 -07:00
|
|
|
# Clear iff we're not in debug mode
|
2018-07-11 23:04:26 -06:00
|
|
|
if [ ! $FLUXIONDebug ]; then clear; fi
|
2018-01-05 17:32:57 -07:00
|
|
|
}
|
|
|
|
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_conditional_bail() {
|
2018-01-05 17:32:57 -07:00
|
|
|
echo ${1:-"Something went wrong, whoops! (report this)"}
|
|
|
|
sleep 5
|
|
|
|
if [ ! $FLUXIONDebug ]; then
|
|
|
|
fluxion_handle_exit
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
echo "Press any key to continue execution..."
|
2018-07-10 14:50:19 -06:00
|
|
|
read -r bullshit
|
2018-01-05 17:32:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
# ERROR Report only in Developer Mode
|
2018-01-09 13:43:40 -07:00
|
|
|
if [ $FLUXIONDebug ]; then
|
2018-03-16 20:00:48 -06:00
|
|
|
fluxion_error_report() {
|
2018-01-05 17:32:57 -07:00
|
|
|
echo "Exception caught @ line #$1"
|
|
|
|
}
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-09 13:43:40 -07:00
|
|
|
trap 'fluxion_error_report $LINENO' ERR
|
2018-01-05 17:32:57 -07:00
|
|
|
fi
|
|
|
|
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_handle_abort_attack() {
|
2018-01-05 17:32:57 -07:00
|
|
|
if [ $(type -t stop_attack) ]; then
|
|
|
|
stop_attack &> $FLUXIONOutputDevice
|
|
|
|
unprep_attack &> $FLUXIONOutputDevice
|
|
|
|
else
|
|
|
|
echo "Attack undefined, can't stop anything..." > $FLUXIONOutputDevice
|
|
|
|
fi
|
2018-03-16 16:34:28 -06:00
|
|
|
|
|
|
|
fluxion_target_tracker_stop
|
2018-01-05 17:32:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
# In case of abort signal, abort any attacks currently running.
|
|
|
|
trap fluxion_handle_abort_attack SIGABRT
|
|
|
|
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_handle_exit() {
|
2018-01-05 17:32:57 -07:00
|
|
|
fluxion_handle_abort_attack
|
|
|
|
fluxion_shutdown
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# In case of unexpected termination, run fluxion_shutdown.
|
|
|
|
trap fluxion_handle_exit SIGINT SIGHUP
|
|
|
|
|
|
|
|
|
2018-03-16 16:34:28 -06:00
|
|
|
fluxion_handle_target_change() {
|
|
|
|
echo "Target change signal received!" > $FLUXIONOutputDevice
|
|
|
|
|
|
|
|
local targetInfo
|
|
|
|
readarray -t targetInfo < <(more "$FLUXIONWorkspacePath/target_info.txt")
|
|
|
|
|
|
|
|
FluxionTargetMAC=${targetInfo[0]}
|
|
|
|
FluxionTargetSSID=${targetInfo[1]}
|
|
|
|
FluxionTargetChannel=${targetInfo[2]}
|
|
|
|
|
|
|
|
FluxionTargetSSIDClean=$(fluxion_target_normalize_SSID)
|
2018-04-22 21:16:37 -06:00
|
|
|
|
|
|
|
if ! stop_attack; then
|
|
|
|
fluxion_conditional_bail "Target tracker failed to stop attack."
|
|
|
|
fi
|
|
|
|
|
2018-04-22 23:18:12 -06:00
|
|
|
if ! unprep_attack; then
|
|
|
|
fluxion_conditional_bail "Target tracker failed to unprep attack."
|
|
|
|
fi
|
|
|
|
|
2018-04-22 21:16:37 -06:00
|
|
|
if ! load_attack "$FLUXIONPath/attacks/$FluxionAttack/attack.conf"; then
|
|
|
|
fluxion_conditional_bail "Target tracker failed to load attack."
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! prep_attack; then
|
|
|
|
fluxion_conditional_bail "Target tracker failed to prep attack."
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! fluxion_run_attack; then
|
|
|
|
fluxion_conditional_bail "Target tracker failed to start attack."
|
|
|
|
fi
|
2018-03-16 16:34:28 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
# If target monitoring enabled, act on changes.
|
|
|
|
trap fluxion_handle_target_change SIGALRM
|
|
|
|
|
|
|
|
|
2018-01-05 17:32:57 -07:00
|
|
|
# ============================================================ #
|
|
|
|
# =============== < Resolution & Positioning > =============== #
|
|
|
|
# ============================================================ #
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_set_resolution() { # Windows + Resolution
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-01-31 05:53:13 -07:00
|
|
|
# Get dimensions
|
2018-07-11 23:04:26 -06:00
|
|
|
# Verify this works on Kali before commiting.
|
|
|
|
# shopt -s checkwinsize; (:;:)
|
|
|
|
# SCREEN_SIZE_X="$LINES"
|
|
|
|
# SCREEN_SIZE_Y="$COLUMNS"
|
|
|
|
|
|
|
|
SCREEN_SIZE=$(xdpyinfo | grep dimension | awk '{print $4}' | tr -d "(")
|
|
|
|
SCREEN_SIZE_X=$(printf '%.*f\n' 0 $(echo $SCREEN_SIZE | sed -e s'/x/ /'g | awk '{print $1}'))
|
|
|
|
SCREEN_SIZE_Y=$(printf '%.*f\n' 0 $(echo $SCREEN_SIZE | sed -e s'/x/ /'g | awk '{print $2}'))
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-01-31 05:53:13 -07:00
|
|
|
# Calculate proportional windows
|
2018-04-22 05:24:14 -06:00
|
|
|
if hash bc ;then
|
|
|
|
PROPOTION=$(echo $(awk "BEGIN {print $SCREEN_SIZE_X/$SCREEN_SIZE_Y}")/1 | bc)
|
|
|
|
NEW_SCREEN_SIZE_X=$(echo $(awk "BEGIN {print $SCREEN_SIZE_X/$FLUXIONWindowRatio}")/1 | bc)
|
|
|
|
NEW_SCREEN_SIZE_Y=$(echo $(awk "BEGIN {print $SCREEN_SIZE_Y/$FLUXIONWindowRatio}")/1 | bc)
|
|
|
|
|
|
|
|
NEW_SCREEN_SIZE_BIG_X=$(echo $(awk "BEGIN {print 1.5*$SCREEN_SIZE_X/$FLUXIONWindowRatio}")/1 | bc)
|
|
|
|
NEW_SCREEN_SIZE_BIG_Y=$(echo $(awk "BEGIN {print 1.5*$SCREEN_SIZE_Y/$FLUXIONWindowRatio}")/1 | bc)
|
|
|
|
|
|
|
|
SCREEN_SIZE_MID_X=$(echo $(($SCREEN_SIZE_X + ($SCREEN_SIZE_X - 2 * $NEW_SCREEN_SIZE_X) / 2)))
|
|
|
|
SCREEN_SIZE_MID_Y=$(echo $(($SCREEN_SIZE_Y + ($SCREEN_SIZE_Y - 2 * $NEW_SCREEN_SIZE_Y) / 2)))
|
|
|
|
|
|
|
|
# Upper windows
|
|
|
|
TOPLEFT="-geometry $NEW_SCREEN_SIZE_Xx$NEW_SCREEN_SIZE_Y+0+0"
|
|
|
|
TOPRIGHT="-geometry $NEW_SCREEN_SIZE_Xx$NEW_SCREEN_SIZE_Y-0+0"
|
|
|
|
TOP="-geometry $NEW_SCREEN_SIZE_Xx$NEW_SCREEN_SIZE_Y+$SCREEN_SIZE_MID_X+0"
|
|
|
|
|
|
|
|
# Lower windows
|
|
|
|
BOTTOMLEFT="-geometry $NEW_SCREEN_SIZE_Xx$NEW_SCREEN_SIZE_Y+0-0"
|
|
|
|
BOTTOMRIGHT="-geometry $NEW_SCREEN_SIZE_Xx$NEW_SCREEN_SIZE_Y-0-0"
|
|
|
|
BOTTOM="-geometry $NEW_SCREEN_SIZE_Xx$NEW_SCREEN_SIZE_Y+$SCREEN_SIZE_MID_X-0"
|
|
|
|
|
|
|
|
# Y mid
|
|
|
|
LEFT="-geometry $NEW_SCREEN_SIZE_Xx$NEW_SCREEN_SIZE_Y+0-$SCREEN_SIZE_MID_Y"
|
|
|
|
RIGHT="-geometry $NEW_SCREEN_SIZE_Xx$NEW_SCREEN_SIZE_Y-0+$SCREEN_SIZE_MID_Y"
|
|
|
|
|
|
|
|
# Big
|
|
|
|
TOPLEFTBIG="-geometry $NEW_SCREEN_SIZE_BIG_Xx$NEW_SCREEN_SIZE_BIG_Y+0+0"
|
|
|
|
TOPRIGHTBIG="-geometry $NEW_SCREEN_SIZE_BIG_Xx$NEW_SCREEN_SIZE_BIG_Y-0+0"
|
|
|
|
fi
|
2018-01-05 17:32:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# ============================================================ #
|
|
|
|
# ================= < Sequencing Framework > ================= #
|
|
|
|
# ============================================================ #
|
|
|
|
# The following lists some problems with the framework's design.
|
|
|
|
# The list below is a list of DESIGN FLAWS, not framework bugs.
|
|
|
|
# * Sequenced undo instructions' return value is being ignored.
|
|
|
|
# * A global is generated for every new namespace being used.
|
|
|
|
# * It uses eval too much, but it's bash, so that's not so bad.
|
|
|
|
# TODO: Try to fix this or come up with a better alternative.
|
|
|
|
declare -rA FLUXIONUndoable=( \
|
|
|
|
["set"]="unset" \
|
|
|
|
["prep"]="unprep" \
|
|
|
|
["run"]="halt" \
|
|
|
|
["start"]="stop" \
|
|
|
|
)
|
|
|
|
|
2018-01-08 21:56:44 -07:00
|
|
|
# Yes, I know, the identifiers are fucking ugly. If only we had
|
|
|
|
# some type of mangling with bash identifiers, that'd be great.
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_do() {
|
2018-07-11 23:04:26 -06:00
|
|
|
if [ ${#@} -lt 2 ]; then return -1; fi
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-01-08 21:56:44 -07:00
|
|
|
local -r __fluxion_do__namespace=$1
|
|
|
|
local -r __fluxion_do__identifier=$2
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-01-16 22:09:09 -07:00
|
|
|
# Notice, the instruction will be adde to the Do Log
|
|
|
|
# regardless of whether it succeeded or failed to execute.
|
2018-01-08 21:56:44 -07:00
|
|
|
eval FXDLog_$__fluxion_do__namespace+=\("$__fluxion_do__identifier"\)
|
|
|
|
eval ${__fluxion_do__namespace}_$__fluxion_do__identifier "${@:3}"
|
2018-01-05 17:32:57 -07:00
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_undo() {
|
2018-07-11 23:04:26 -06:00
|
|
|
if [ ${#@} -ne 1 ]; then return -1; fi
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-01-08 21:56:44 -07:00
|
|
|
local -r __fluxion_undo__namespace=$1
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-01-10 23:20:41 -07:00
|
|
|
# Removed read-only due to local constant shadowing bug.
|
|
|
|
# I've reported the bug, we can add it when fixed.
|
|
|
|
eval local __fluxion_undo__history=\("\${FXDLog_$__fluxion_undo__namespace[@]}"\)
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-01-16 22:09:09 -07:00
|
|
|
eval echo \$\{FXDLog_$__fluxion_undo__namespace[@]\} \
|
|
|
|
> $FLUXIONOutputDevice
|
|
|
|
|
2018-01-08 21:56:44 -07:00
|
|
|
local __fluxion_undo__i
|
|
|
|
for (( __fluxion_undo__i=${#__fluxion_undo__history[@]}; \
|
|
|
|
__fluxion_undo__i > 0; __fluxion_undo__i-- )); do
|
2018-07-11 23:04:26 -06:00
|
|
|
local __fluxion_undo__instruction=${__fluxion_undo__history[__fluxion_undo__i-1]}
|
2018-01-09 00:46:40 -07:00
|
|
|
local __fluxion_undo__command=${__fluxion_undo__instruction%%_*}
|
|
|
|
local __fluxion_undo__identifier=${__fluxion_undo__instruction#*_}
|
2018-01-09 12:36:29 -07:00
|
|
|
|
2018-01-16 22:09:09 -07:00
|
|
|
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
|
2018-01-08 21:56:44 -07:00
|
|
|
eval FXDLog_$__fluxion_undo__namespace=\("${__fluxion_undo__history[@]::$__fluxion_undo__i}"\)
|
2018-01-16 22:09:09 -07:00
|
|
|
eval echo History\: \$\{FXDLog_$__fluxion_undo__namespace[@]\} \
|
|
|
|
> $FLUXIONOutputDevice
|
2018-01-05 17:32:57 -07:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2018-07-11 23:04:26 -06:00
|
|
|
return -2 # The undo-chain failed.
|
2018-01-05 17:32:57 -07:00
|
|
|
}
|
|
|
|
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_done() {
|
2018-07-11 23:04:26 -06:00
|
|
|
if [ ${#@} -ne 1 ]; then return -1; fi
|
2018-01-08 21:56:44 -07:00
|
|
|
|
|
|
|
local -r __fluxion_done__namespace=$1
|
|
|
|
|
2018-07-11 23:04:26 -06:00
|
|
|
eval "FluxionDone=\${FXDLog_${__fluxion_done__namespace[-1]}}"
|
2018-01-09 00:46:40 -07:00
|
|
|
|
|
|
|
if [ ! "$FluxionDone" ]; then return 1; fi
|
2018-01-05 17:32:57 -07:00
|
|
|
}
|
|
|
|
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_done_reset() {
|
2018-07-11 23:04:26 -06:00
|
|
|
if [ ${#@} -ne 1 ]; then return -1; fi
|
2018-01-08 21:56:44 -07:00
|
|
|
|
|
|
|
local -r __fluxion_done_reset__namespace=$1
|
|
|
|
|
|
|
|
eval FXDLog_$__fluxion_done_reset__namespace=\(\)
|
2018-01-05 17:32:57 -07:00
|
|
|
}
|
|
|
|
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_do_sequence() {
|
2018-07-10 14:50:19 -06:00
|
|
|
if [ ${#@} -ne 2 ]; then return 1; fi
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-01-06 21:21:37 -07:00
|
|
|
# TODO: Implement an alternative, better method of doing
|
2018-01-31 05:53:13 -07:00
|
|
|
# what this subroutine does, maybe using for-loop iteFLUXIONWindowRation.
|
2018-01-05 17:32:57 -07:00
|
|
|
# The for-loop implementation must support the subroutines
|
|
|
|
# defined above, including updating the namespace tracker.
|
|
|
|
|
2018-01-06 21:21:37 -07:00
|
|
|
local -r __fluxion_do_sequence__namespace=$1
|
2018-01-10 23:20:41 -07:00
|
|
|
|
|
|
|
# Removed read-only due to local constant shadowing bug.
|
|
|
|
# I've reported the bug, we can add it when fixed.
|
|
|
|
local __fluxion_do_sequence__sequence=("${!2}")
|
2018-01-06 21:21:37 -07:00
|
|
|
|
|
|
|
if [ ${#__fluxion_do_sequence__sequence[@]} -eq 0 ]; then
|
|
|
|
return -2
|
|
|
|
fi
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-01-06 21:21:37 -07:00
|
|
|
local -A __fluxion_do_sequence__index=()
|
2018-01-05 17:32:57 -07:00
|
|
|
|
|
|
|
local i
|
2018-01-16 22:09:09 -07:00
|
|
|
for i in $(seq 0 $((${#__fluxion_do_sequence__sequence[@]} - 1))); do
|
|
|
|
__fluxion_do_sequence__index["${__fluxion_do_sequence__sequence[i]}"]=$i
|
2018-01-05 17:32:57 -07:00
|
|
|
done
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-09 00:46:40 -07:00
|
|
|
# Start sequence with the first instruction available.
|
2018-01-16 22:09:09 -07:00
|
|
|
local __fluxion_do_sequence__instructionIndex=0
|
2018-01-06 21:21:37 -07:00
|
|
|
local __fluxion_do_sequence__instruction=${__fluxion_do_sequence__sequence[0]}
|
|
|
|
while [ "$__fluxion_do_sequence__instruction" ]; do
|
|
|
|
if ! fluxion_do $__fluxion_do_sequence__namespace $__fluxion_do_sequence__instruction; then
|
2018-01-16 22:09:09 -07:00
|
|
|
if ! fluxion_undo $__fluxion_do_sequence__namespace; then
|
2018-01-16 23:33:22 -07:00
|
|
|
return -2
|
2018-01-05 17:32:57 -07:00
|
|
|
fi
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-16 22:09:09 -07:00
|
|
|
# Synchronize the current instruction's index by checking last.
|
|
|
|
if ! fluxion_done $__fluxion_do_sequence__namespace; then
|
|
|
|
return -3;
|
|
|
|
fi
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-16 22:09:09 -07:00
|
|
|
__fluxion_do_sequence__instructionIndex=${__fluxion_do_sequence__index["$FluxionDone"]}
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-16 22:09:09 -07:00
|
|
|
if [ ! "$__fluxion_do_sequence__instructionIndex" ]; then
|
|
|
|
return -4
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
let __fluxion_do_sequence__instructionIndex++
|
2018-01-09 13:43:40 -07:00
|
|
|
fi
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-16 22:09:09 -07:00
|
|
|
__fluxion_do_sequence__instruction=${__fluxion_do_sequence__sequence[$__fluxion_do_sequence__instructionIndex]}
|
2018-01-17 14:26:04 -07:00
|
|
|
echo "Running next: $__fluxion_do_sequence__instruction" \
|
2018-01-16 22:09:09 -07:00
|
|
|
> $FLUXIONOutputDevice
|
2018-01-05 17:32:57 -07:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# ============================================================ #
|
|
|
|
# ================= < Load All Subroutines > ================= #
|
|
|
|
# ============================================================ #
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_header() {
|
2018-01-05 17:32:57 -07:00
|
|
|
format_apply_autosize "[%*s]\n"
|
|
|
|
local verticalBorder=$FormatApplyAutosize
|
|
|
|
|
|
|
|
format_apply_autosize "[%*s${CSRed}FLUXION $FLUXIONVersion${CSWht}.${CSBlu}$FLUXIONRevision$CSRed <$CIRed F${CIYel}luxion$CIRed I${CIYel}s$CIRed T${CIYel}he$CIRed F${CIYel}uture$CClr$CSYel >%*s$CSBlu]\n"
|
|
|
|
local headerTextFormat="$FormatApplyAutosize"
|
|
|
|
|
|
|
|
fluxion_conditional_clear
|
|
|
|
|
|
|
|
echo -e "$(printf "$CSRed$verticalBorder" "" | sed -r "s/ /~/g")"
|
|
|
|
printf "$CSRed$verticalBorder" ""
|
|
|
|
printf "$headerTextFormat" "" ""
|
|
|
|
printf "$CSBlu$verticalBorder" ""
|
|
|
|
echo -e "$(printf "$CSBlu$verticalBorder" "" | sed -r "s/ /~/g")$CClr"
|
|
|
|
echo
|
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
|
|
|
# ======================= < Language > ======================= #
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_unset_language() {
|
2018-01-09 13:43:40 -07:00
|
|
|
FluxionLanguage=""
|
2018-01-09 00:46:40 -07:00
|
|
|
|
2018-03-13 12:37:45 -06:00
|
|
|
if [ "$FLUXIONPreferencesFile" ]; then
|
|
|
|
sed -i.backup "/FluxionLanguage=.\+/ d" "$FLUXIONPreferencesFile"
|
2018-01-09 00:46:40 -07:00
|
|
|
fi
|
2018-01-05 17:32:57 -07:00
|
|
|
}
|
|
|
|
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_set_language() {
|
2018-01-09 13:43:40 -07:00
|
|
|
if [ ! "$FluxionLanguage" ]; then
|
2018-01-09 00:46:40 -07:00
|
|
|
# Get all languages available.
|
|
|
|
local languageCodes
|
2018-07-10 16:41:38 -06:00
|
|
|
readarray -t languageCodes < <(ls -1 language | sed -E 's/\.sh//')
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-01-09 00:46:40 -07:00
|
|
|
local languages
|
2018-01-09 12:36:29 -07:00
|
|
|
readarray -t languages < <(
|
|
|
|
head -n 3 language/*.sh |
|
|
|
|
grep -E "^# native: " |
|
|
|
|
sed -E 's/# \w+: //'
|
|
|
|
)
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-01-09 12:36:29 -07:00
|
|
|
io_query_format_fields "$FLUXIONVLine Select your language" \
|
|
|
|
"\t$CRed[$CSYel%d$CClr$CRed]$CClr %s / %s\n" \
|
|
|
|
languageCodes[@] languages[@]
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-01-09 13:43:40 -07:00
|
|
|
FluxionLanguage=${IOQueryFormatFields[0]}
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-01-09 00:46:40 -07:00
|
|
|
echo # Do not remove.
|
2018-01-05 17:32:57 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Check if all language files are present for the selected language.
|
|
|
|
find -type d -name language | while read language_dir; do
|
2018-01-09 13:43:40 -07:00
|
|
|
if [ ! -e "$language_dir/${FluxionLanguage}.sh" ]; then
|
2018-01-05 17:32:57 -07:00
|
|
|
echo -e "$FLUXIONVLine ${CYel}Warning${CClr}, missing language file:"
|
2018-01-09 13:43:40 -07:00
|
|
|
echo -e "\t$language_dir/${FluxionLanguage}.sh"
|
2018-01-05 17:32:57 -07:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ $? -eq 1 ]; then # If a file is missing, fall back to english.
|
|
|
|
echo -e "\n\n$FLUXIONVLine Falling back to English..."; sleep 5
|
2018-01-09 13:43:40 -07:00
|
|
|
FluxionLanguage="en"
|
2018-01-05 17:32:57 -07:00
|
|
|
fi
|
|
|
|
|
2018-01-09 13:43:40 -07:00
|
|
|
source "$FLUXIONPath/language/$FluxionLanguage.sh"
|
2018-01-09 00:46:40 -07:00
|
|
|
|
2018-03-13 12:37:45 -06:00
|
|
|
if [ "$FLUXIONPreferencesFile" ]; then
|
|
|
|
if more $FLUXIONPreferencesFile | \
|
2018-01-09 13:43:40 -07:00
|
|
|
grep -q "FluxionLanguage=.\+" &> /dev/null; then
|
|
|
|
sed -r "s/FluxionLanguage=.+/FluxionLanguage=$FluxionLanguage/g" \
|
2018-03-13 12:37:45 -06:00
|
|
|
-i.backup "$FLUXIONPreferencesFile"
|
2018-01-09 00:46:40 -07:00
|
|
|
else
|
2018-03-13 12:37:45 -06:00
|
|
|
echo "FluxionLanguage=$FluxionLanguage" >> "$FLUXIONPreferencesFile"
|
2018-01-09 00:46:40 -07:00
|
|
|
fi
|
|
|
|
fi
|
2018-01-05 17:32:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
# ====================== < Interfaces > ====================== #
|
|
|
|
declare -A FluxionInterfaces=() # Global interfaces' registry.
|
|
|
|
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_deallocate_interface() { # Release interfaces
|
2018-01-05 17:32:57 -07:00
|
|
|
if [ ! "$1" ] || ! interface_is_real $1; then return 1; fi
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-05 17:32:57 -07:00
|
|
|
local -r oldIdentifier=$1
|
|
|
|
local -r newIdentifier=${FluxionInterfaces[$oldIdentifier]}
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-05 17:32:57 -07:00
|
|
|
# Assure the interface is in the allocation table.
|
|
|
|
if [ ! "$newIdentifier" ]; then return 2; fi
|
|
|
|
|
2018-01-19 12:59:15 -07:00
|
|
|
local interfaceIdentifier=$newIdentifier
|
|
|
|
echo -e "$CWht[$CSRed-$CWht] "$(
|
|
|
|
io_dynamic_output "$FLUXIONDeallocatingInterfaceNotice"
|
|
|
|
)"$CClr"
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-19 12:59:15 -07:00
|
|
|
if interface_is_wireless $oldIdentifier; then
|
2018-05-03 15:55:06 -06:00
|
|
|
# If interface was allocated by airmon-ng, deallocate with it.
|
2018-05-19 15:01:50 -06:00
|
|
|
if [[ "$oldIdentifier" == *"mon"* || "$oldIdentifier" == "prism"* ]]; then
|
2018-05-03 15:55:06 -06:00
|
|
|
if ! airmon-ng stop $oldIdentifier &> $FLUXIONOutputDevice; then
|
|
|
|
return 4
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
# Attempt deactivating monitor mode on the interface.
|
|
|
|
if ! interface_set_mode $oldIdentifier managed; then
|
|
|
|
return 3
|
|
|
|
fi
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-05-03 15:55:06 -06:00
|
|
|
# Attempt to restore the original interface identifier.
|
2018-07-10 14:50:19 -06:00
|
|
|
if ! interface_reidentify "$oldIdentifier" "$newIdentifier"; then
|
2018-05-03 15:55:06 -06:00
|
|
|
return 5
|
|
|
|
fi
|
2018-01-05 17:32:57 -07:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Once successfully renamed, remove from allocation table.
|
|
|
|
unset FluxionInterfaces[$oldIdentifier]
|
|
|
|
unset FluxionInterfaces[$newIdentifier]
|
|
|
|
}
|
|
|
|
|
2018-01-08 22:50:10 -07:00
|
|
|
# Parameters: <interface_identifier>
|
|
|
|
# ------------------------------------------------------------ #
|
|
|
|
# Return 1: No interface identifier was passed.
|
|
|
|
# Return 2: Interface identifier given points to no interface.
|
|
|
|
# Return 3: Unable to determine interface's driver.
|
|
|
|
# Return 4: Fluxion failed to reidentify interface.
|
|
|
|
# Return 5: Interface allocation failed (identifier missing).
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_allocate_interface() { # Reserve interfaces
|
2018-01-08 22:50:10 -07:00
|
|
|
if [ ! "$1" ]; then return 1; fi
|
2018-01-05 17:32:57 -07:00
|
|
|
|
|
|
|
local -r identifier=$1
|
|
|
|
|
2018-01-08 22:50:10 -07:00
|
|
|
# If the interface is already in allocation table, we're done.
|
2018-01-05 17:32:57 -07:00
|
|
|
if [ "${FluxionInterfaces[$identifier]+x}" ]; then
|
|
|
|
return 0
|
|
|
|
fi
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-08 22:50:10 -07:00
|
|
|
if ! interface_is_real $identifier; then return 2; fi
|
|
|
|
|
2018-01-19 12:59:15 -07:00
|
|
|
|
|
|
|
local interfaceIdentifier=$identifier
|
|
|
|
echo -e "$CWht[$CSGrn+$CWht] "$(
|
|
|
|
io_dynamic_output "$FLUXIONAllocatingInterfaceNotice"
|
|
|
|
)"$CClr"
|
|
|
|
|
2018-01-06 21:21:37 -07:00
|
|
|
|
|
|
|
if interface_is_wireless $identifier; then
|
2018-01-05 17:32:57 -07:00
|
|
|
# Unblock wireless interfaces to make them available.
|
|
|
|
echo -e "$FLUXIONVLine $FLUXIONUnblockingWINotice"
|
|
|
|
rfkill unblock all &> $FLUXIONOutputDevice
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-05 17:32:57 -07:00
|
|
|
if [ "$FLUXIONWIReloadDriver" ]; then
|
|
|
|
# Get selected interface's driver details/info-descriptor.
|
|
|
|
echo -e "$FLUXIONVLine $FLUXIONGatheringWIInfoNotice"
|
|
|
|
|
|
|
|
if ! interface_driver "$identifier"; then
|
|
|
|
echo -e "$FLUXIONVLine$CRed $FLUXIONUnknownWIDriverError"
|
|
|
|
sleep 3
|
2018-01-08 22:50:10 -07:00
|
|
|
return 3
|
2018-01-05 17:32:57 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Notice: This local is function-scoped, not block-scoped.
|
|
|
|
local -r driver="$InterfaceDriver"
|
|
|
|
|
|
|
|
# Unload the driver module from the kernel.
|
|
|
|
rmmod -f $driver &> $FLUXIONOutputDevice
|
|
|
|
|
|
|
|
# Wait while interface becomes unavailable.
|
2018-01-09 12:36:29 -07:00
|
|
|
echo -e "$FLUXIONVLine "$(
|
|
|
|
io_dynamic_output $FLUXIONUnloadingWIDriverNotice
|
|
|
|
)
|
2018-01-09 13:43:40 -07:00
|
|
|
while interface_physical "$identifier"; do
|
|
|
|
sleep 1
|
2018-01-05 17:32:57 -07:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$FLUXIONWIKillProcesses" ]; then
|
|
|
|
# Get list of potentially troublesome programs.
|
|
|
|
echo -e "$FLUXIONVLine $FLUXIONFindingConflictingProcessesNotice"
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-05 17:32:57 -07:00
|
|
|
# Kill potentially troublesome programs.
|
|
|
|
echo -e "$FLUXIONVLine $FLUXIONKillingConflictingProcessesNotice"
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-05 17:32:57 -07:00
|
|
|
# TODO: Make the loop below airmon-ng independent.
|
|
|
|
# Maybe replace it with a list of network-managers?
|
|
|
|
# WARNING: Version differences could break code below.
|
2018-01-10 19:17:08 -07:00
|
|
|
for program in "$(airmon-ng check | awk 'NR>6{print $2}')"; do
|
2018-01-09 13:43:40 -07:00
|
|
|
killall "$program" &> $FLUXIONOutputDevice
|
2018-01-05 17:32:57 -07:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$FLUXIONWIReloadDriver" ]; then
|
|
|
|
# Reload the driver module into the kernel.
|
|
|
|
modprobe "$driver" &> $FLUXIONOutputDevice
|
|
|
|
|
|
|
|
# Wait while interface becomes available.
|
2018-01-09 12:36:29 -07:00
|
|
|
echo -e "$FLUXIONVLine "$(
|
|
|
|
io_dynamic_output $FLUXIONLoadingWIDriverNotice
|
|
|
|
)
|
2018-01-09 13:43:40 -07:00
|
|
|
while ! interface_physical "$identifier"; do
|
|
|
|
sleep 1
|
2018-01-05 17:32:57 -07:00
|
|
|
done
|
|
|
|
fi
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-05 17:32:57 -07:00
|
|
|
# Set wireless flag to prevent having to re-query.
|
|
|
|
local -r allocatingWirelessInterface=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# If we're using the interface library, reidentify now.
|
|
|
|
# If usuing airmon-ng, let airmon-ng rename the interface.
|
|
|
|
if [ ! $FLUXIONAirmonNG ]; then
|
|
|
|
echo -e "$FLUXIONVLine $FLUXIONReidentifyingInterface"
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-09 13:43:40 -07:00
|
|
|
# Prevent interface-snatching by renaming the interface.
|
|
|
|
if [ $allocatingWirelessInterface ]; then
|
2018-05-03 17:30:56 -06:00
|
|
|
# Get next wireless interface to add to FluxionInterfaces global.
|
|
|
|
fluxion_next_assignable_interface fluxwl
|
2018-01-09 13:43:40 -07:00
|
|
|
else
|
2018-05-03 17:30:56 -06:00
|
|
|
# Get next ethernet interface to add to FluxionInterfaces global.
|
|
|
|
fluxion_next_assignable_interface fluxet
|
2018-01-05 17:32:57 -07:00
|
|
|
fi
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-05-03 17:30:56 -06:00
|
|
|
interface_reidentify $identifier $FluxionNextAssignableInterface
|
|
|
|
|
2018-01-09 13:43:40 -07:00
|
|
|
if [ $? -ne 0 ]; then # If reidentifying failed, abort immediately.
|
|
|
|
return 4
|
2018-01-05 17:32:57 -07:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $allocatingWirelessInterface ]; then
|
|
|
|
# Activate wireless interface monitor mode and save identifier.
|
|
|
|
echo -e "$FLUXIONVLine $FLUXIONStartingWIMonitorNotice"
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-05 17:32:57 -07:00
|
|
|
# TODO: Consider the airmon-ng flag is set, monitor mode is
|
|
|
|
# already enabled on the interface being allocated, and the
|
|
|
|
# interface identifier is something non-airmon-ng standard.
|
|
|
|
# The interface could already be in use by something else.
|
|
|
|
# Snatching or crashing interface issues could occur.
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-05 17:32:57 -07:00
|
|
|
# NOTICE: Conditionals below populate newIdentifier on success.
|
|
|
|
if [ $FLUXIONAirmonNG ]; then
|
2018-01-09 13:43:40 -07:00
|
|
|
local -r newIdentifier=$(
|
|
|
|
airmon-ng start $identifier |
|
|
|
|
grep "monitor .* enabled" |
|
2018-05-19 15:01:50 -06:00
|
|
|
grep -oP "wl[a-zA-Z0-9]+mon|mon[0-9]+|prism[0-9]+"
|
2018-01-09 13:43:40 -07:00
|
|
|
)
|
2018-01-05 17:32:57 -07:00
|
|
|
else
|
|
|
|
# Attempt activating monitor mode on the interface.
|
2018-05-03 17:30:56 -06:00
|
|
|
if interface_set_mode $FluxionNextAssignableInterface monitor; then
|
2018-01-05 17:32:57 -07:00
|
|
|
# Register the new identifier upon consecutive successes.
|
2018-05-03 17:30:56 -06:00
|
|
|
local -r newIdentifier=$FluxionNextAssignableInterface
|
2018-01-09 13:43:40 -07:00
|
|
|
else
|
2018-01-05 17:32:57 -07:00
|
|
|
# If monitor-mode switch fails, undo rename and abort.
|
2018-05-03 17:30:56 -06:00
|
|
|
interface_reidentify $FluxionNextAssignableInterface $identifier
|
2018-01-05 17:32:57 -07:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# On failure to allocate the interface, we've got to abort.
|
|
|
|
# Notice: If the interface was already in monitor mode and
|
|
|
|
# airmon-ng is activated, WE didn't allocate the interface.
|
|
|
|
if [ ! "$newIdentifier" -o "$newIdentifier" = "$oldIdentifier" ]; then
|
|
|
|
echo -e "$FLUXIONVLine $FLUXIONInterfaceAllocationFailedError"
|
|
|
|
sleep 3
|
2018-01-08 22:50:10 -07:00
|
|
|
return 5
|
2018-01-05 17:32:57 -07:00
|
|
|
fi
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-05 17:32:57 -07:00
|
|
|
# Register identifiers to allocation hash table.
|
|
|
|
FluxionInterfaces[$newIdentifier]=$identifier
|
|
|
|
FluxionInterfaces[$identifier]=$newIdentifier
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-05 17:32:57 -07:00
|
|
|
echo -e "$FLUXIONVLine $FLUXIONInterfaceAllocatedNotice"
|
|
|
|
sleep 3
|
2018-01-06 21:21:37 -07:00
|
|
|
|
|
|
|
# Notice: Interfaces are accessed with their original identifier
|
2018-01-05 17:32:57 -07:00
|
|
|
# as the key for the global FluxionInterfaces hash/map/dictionary.
|
|
|
|
}
|
|
|
|
|
2018-05-03 17:30:56 -06:00
|
|
|
# Parameters: <interface_prefix>
|
|
|
|
# Description: Prints next available assignable interface name.
|
|
|
|
# ------------------------------------------------------------ #
|
|
|
|
fluxion_next_assignable_interface() {
|
|
|
|
# Find next available interface by checking global.
|
2018-05-04 11:55:36 -06:00
|
|
|
local -r prefix=$1
|
2018-05-03 17:30:56 -06:00
|
|
|
local index=0
|
|
|
|
while [ "${FluxionInterfaces[$prefix$index]}" ]; do
|
|
|
|
let index++
|
|
|
|
done
|
|
|
|
FluxionNextAssignableInterface="$prefix$index"
|
|
|
|
}
|
|
|
|
|
2018-01-20 15:06:45 -07:00
|
|
|
# Parameters: <interfaces:lambda> [<query>]
|
2018-01-08 21:56:44 -07:00
|
|
|
# Note: The interfaces lambda must print an interface per line.
|
|
|
|
# ------------------------------------------------------------ #
|
2018-07-11 23:04:26 -06:00
|
|
|
# Return -1: Go back
|
2018-01-08 21:56:44 -07:00
|
|
|
# Return 1: Missing interfaces lambda identifier (not passed).
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_get_interface() {
|
2018-01-08 21:56:44 -07:00
|
|
|
if ! type -t "$1" &> /dev/null; then return 1; fi
|
|
|
|
|
2018-01-17 14:26:04 -07:00
|
|
|
if [ "$2" ]; then
|
|
|
|
local -r interfaceQuery="$2"
|
|
|
|
else
|
|
|
|
local -r interfaceQuery=$FLUXIONInterfaceQuery
|
|
|
|
fi
|
|
|
|
|
2018-01-08 21:56:44 -07:00
|
|
|
while true; do
|
2018-01-20 15:06:45 -07:00
|
|
|
local candidateInterfaces
|
|
|
|
readarray -t candidateInterfaces < <($1)
|
|
|
|
local interfacesAvailable=()
|
2018-01-08 21:56:44 -07:00
|
|
|
local interfacesAvailableInfo=()
|
|
|
|
local interfacesAvailableColor=()
|
|
|
|
local interfacesAvailableState=()
|
|
|
|
|
|
|
|
# Gather information from all available interfaces.
|
2018-01-20 15:06:45 -07:00
|
|
|
local candidateInterface
|
|
|
|
for candidateInterface in "${candidateInterfaces[@]}"; do
|
|
|
|
if [ ! "$candidateInterface" ]; then
|
|
|
|
local skipOption=1
|
|
|
|
continue
|
|
|
|
fi
|
2018-01-08 22:50:10 -07:00
|
|
|
|
2018-01-20 15:06:45 -07:00
|
|
|
interface_chipset "$candidateInterface"
|
2018-01-08 21:56:44 -07:00
|
|
|
interfacesAvailableInfo+=("$InterfaceChipset")
|
|
|
|
|
|
|
|
# If it has already been allocated, we can use it at will.
|
2018-01-20 15:06:45 -07:00
|
|
|
local candidateInterfaceAlt=${FluxionInterfaces["$candidateInterface"]}
|
|
|
|
if [ "$candidateInterfaceAlt" ]; then
|
|
|
|
interfacesAvailable+=("$candidateInterfaceAlt")
|
|
|
|
|
2018-01-08 21:56:44 -07:00
|
|
|
interfacesAvailableColor+=("$CGrn")
|
|
|
|
interfacesAvailableState+=("[*]")
|
2018-01-05 17:32:57 -07:00
|
|
|
else
|
2018-01-20 15:06:45 -07:00
|
|
|
interfacesAvailable+=("$candidateInterface")
|
|
|
|
|
|
|
|
interface_state "$candidateInterface"
|
2018-01-08 21:56:44 -07:00
|
|
|
|
|
|
|
if [ "$InterfaceState" = "up" ]; then
|
|
|
|
interfacesAvailableColor+=("$CPrp")
|
|
|
|
interfacesAvailableState+=("[-]")
|
|
|
|
else
|
|
|
|
interfacesAvailableColor+=("$CClr")
|
|
|
|
interfacesAvailableState+=("[+]")
|
|
|
|
fi
|
2018-01-05 17:32:57 -07:00
|
|
|
fi
|
2018-01-08 21:56:44 -07:00
|
|
|
done
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-08 21:56:44 -07:00
|
|
|
# If only one interface exists and it's not unavailable, choose it.
|
|
|
|
if [ "${#interfacesAvailable[@]}" -eq 1 -a \
|
2018-01-20 15:06:45 -07:00
|
|
|
"${interfacesAvailableState[0]}" != "[-]" -a \
|
|
|
|
"$skipOption" == "" ]; then
|
2018-01-10 19:17:08 -07:00
|
|
|
FluxionInterfaceSelected="${interfacesAvailable[0]}"
|
|
|
|
FluxionInterfaceSelectedState="${interfacesAvailableState[0]}"
|
|
|
|
FluxionInterfaceSelectedInfo="${interfacesAvailableInfo[0]}"
|
|
|
|
break
|
2018-01-08 21:56:44 -07:00
|
|
|
else
|
2018-01-20 15:06:45 -07:00
|
|
|
if [ $skipOption ]; then
|
|
|
|
interfacesAvailable+=("$FLUXIONGeneralSkipOption")
|
|
|
|
interfacesAvailableColor+=("$CClr")
|
|
|
|
fi
|
|
|
|
|
|
|
|
interfacesAvailable+=(
|
|
|
|
"$FLUXIONGeneralRepeatOption"
|
|
|
|
"$FLUXIONGeneralBackOption"
|
2018-01-08 21:56:44 -07:00
|
|
|
)
|
|
|
|
|
2018-01-20 15:06:45 -07:00
|
|
|
interfacesAvailableColor+=(
|
|
|
|
"$CClr"
|
|
|
|
"$CClr"
|
2018-01-08 21:56:44 -07:00
|
|
|
)
|
|
|
|
|
2018-01-09 12:36:29 -07:00
|
|
|
format_apply_autosize \
|
|
|
|
"$CRed[$CSYel%1d$CClr$CRed]%b %-8b %3s$CClr %-*.*s\n"
|
|
|
|
|
2018-01-08 21:56:44 -07:00
|
|
|
io_query_format_fields \
|
2018-01-17 14:26:04 -07:00
|
|
|
"$FLUXIONVLine $interfaceQuery" "$FormatApplyAutosize" \
|
2018-01-08 21:56:44 -07:00
|
|
|
interfacesAvailableColor[@] interfacesAvailable[@] \
|
|
|
|
interfacesAvailableState[@] interfacesAvailableInfo[@]
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-01-08 21:56:44 -07:00
|
|
|
echo
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-01-08 21:56:44 -07:00
|
|
|
case "${IOQueryFormatFields[1]}" in
|
2018-01-20 15:06:45 -07:00
|
|
|
"$FLUXIONGeneralSkipOption")
|
|
|
|
FluxionInterfaceSelected=""
|
|
|
|
FluxionInterfaceSelectedState=""
|
|
|
|
FluxionInterfaceSelectedInfo=""
|
|
|
|
return 0;;
|
2018-01-08 21:56:44 -07:00
|
|
|
"$FLUXIONGeneralRepeatOption") continue;;
|
2018-07-11 23:04:26 -06:00
|
|
|
"$FLUXIONGeneralBackOption") return -1;;
|
2018-01-10 19:17:08 -07:00
|
|
|
*)
|
|
|
|
FluxionInterfaceSelected="${IOQueryFormatFields[1]}"
|
|
|
|
FluxionInterfaceSelectedState="${IOQueryFormatFields[2]}"
|
|
|
|
FluxionInterfaceSelectedInfo="${IOQueryFormatFields[3]}"
|
|
|
|
break;;
|
2018-01-08 21:56:44 -07:00
|
|
|
esac
|
|
|
|
fi
|
|
|
|
done
|
2018-01-05 17:32:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-05 22:57:16 -07:00
|
|
|
# ============== < Fluxion Target Subroutines > ============== #
|
|
|
|
# Parameters: interface [ channel(s) [ band(s) ] ]
|
|
|
|
# ------------------------------------------------------------ #
|
|
|
|
# Return 1: Missing monitor interface.
|
|
|
|
# Return 2: Xterm failed to start airmon-ng.
|
|
|
|
# Return 3: Invalid capture file was generated.
|
|
|
|
# Return 4: No candidates were detected.
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_target_get_candidates() {
|
2018-01-05 22:57:16 -07:00
|
|
|
# Assure a valid wireless interface for scanning was given.
|
|
|
|
if [ ! "$1" ] || ! interface_is_wireless "$1"; then return 1; fi
|
|
|
|
|
|
|
|
echo -e "$FLUXIONVLine $FLUXIONStartingScannerNotice"
|
|
|
|
echo -e "$FLUXIONVLine $FLUXIONStartingScannerTip"
|
|
|
|
|
|
|
|
# Assure all previous scan results have been cleared.
|
|
|
|
sandbox_remove_workfile "$FLUXIONWorkspacePath/dump*"
|
|
|
|
|
|
|
|
#if [ "$FLUXIONAuto" ]; then
|
|
|
|
# sleep 30 && killall xterm &
|
|
|
|
#fi
|
|
|
|
|
|
|
|
# Begin scanner and output all results to "dump-01.csv."
|
2018-01-09 12:36:29 -07:00
|
|
|
if ! xterm -title "$FLUXIONScannerHeader" $TOPLEFTBIG \
|
|
|
|
-bg "#000000" -fg "#FFFFFF" -e \
|
|
|
|
"airodump-ng -Mat WPA "${2:+"--channel $2"}" "${3:+"--band $3"}" -w \"$FLUXIONWorkspacePath/dump\" $1" 2> $FLUXIONOutputDevice; then
|
2018-01-05 22:57:16 -07:00
|
|
|
echo -e "$FLUXIONVLine$CRed $FLUXIONGeneralXTermFailureError"
|
|
|
|
sleep 5
|
|
|
|
return 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Sanity check the capture files generated by the scanner.
|
|
|
|
# If the file doesn't exist, or if it's empty, abort immediately.
|
|
|
|
if [ ! -f "$FLUXIONWorkspacePath/dump-01.csv" -o \
|
|
|
|
! -s "$FLUXIONWorkspacePath/dump-01.csv" ]; then
|
2018-01-06 21:21:37 -07:00
|
|
|
sandbox_remove_workfile "$FLUXIONWorkspacePath/dump*"
|
2018-01-05 22:57:16 -07:00
|
|
|
return 3
|
|
|
|
fi
|
|
|
|
|
2018-01-31 05:53:13 -07:00
|
|
|
# Syntheize scan opeFLUXIONWindowRation results from output file "dump-01.csv."
|
2018-01-05 22:57:16 -07:00
|
|
|
echo -e "$FLUXIONVLine $FLUXIONPreparingScannerResultsNotice"
|
|
|
|
# WARNING: The code below may break with different version of airmon-ng.
|
|
|
|
# The times matching operator "{n}" isn't supported by mawk (alias awk).
|
2018-01-09 12:36:29 -07:00
|
|
|
# readarray FLUXIONTargetCandidates < <(
|
|
|
|
# gawk -F, 'NF==15 && $1~/([A-F0-9]{2}:){5}[A-F0-9]{2}/ {print $0}'
|
|
|
|
# $FLUXIONWorkspacePath/dump-01.csv
|
|
|
|
# )
|
|
|
|
# readarray FLUXIONTargetCandidatesClients < <(
|
|
|
|
# gawk -F, 'NF==7 && $1~/([A-F0-9]{2}:){5}[A-F0-9]{2}/ {print $0}'
|
|
|
|
# $FLUXIONWorkspacePath/dump-01.csv
|
|
|
|
# )
|
|
|
|
local -r matchMAC="([A-F0-9][A-F0-9]:)+[A-F0-9][A-F0-9]"
|
|
|
|
readarray FluxionTargetCandidates < <(
|
2018-01-10 19:17:08 -07:00
|
|
|
awk -F, "NF==15 && length(\$1)==17 && \$1~/$matchMAC/ {print \$0}" \
|
2018-01-09 12:36:29 -07:00
|
|
|
"$FLUXIONWorkspacePath/dump-01.csv"
|
|
|
|
)
|
|
|
|
readarray FluxionTargetCandidatesClients < <(
|
2018-01-10 19:17:08 -07:00
|
|
|
awk -F, "NF==7 && length(\$1)==17 && \$1~/$matchMAC/ {print \$0}" \
|
2018-01-09 12:36:29 -07:00
|
|
|
"$FLUXIONWorkspacePath/dump-01.csv"
|
|
|
|
)
|
2018-01-05 22:57:16 -07:00
|
|
|
|
|
|
|
# Cleanup the workspace to prevent potential bugs/conflicts.
|
|
|
|
sandbox_remove_workfile "$FLUXIONWorkspacePath/dump*"
|
|
|
|
|
2018-01-08 21:56:44 -07:00
|
|
|
if [ ${#FluxionTargetCandidates[@]} -eq 0 ]; then
|
2018-01-05 22:57:16 -07:00
|
|
|
echo -e "$FLUXIONVLine $FLUXIONScannerDetectedNothingNotice"
|
|
|
|
sleep 3
|
|
|
|
return 4
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_get_target() {
|
2018-01-05 22:57:16 -07:00
|
|
|
# Assure a valid wireless interface for scanning was given.
|
|
|
|
if [ ! "$1" ] || ! interface_is_wireless "$1"; then return 1; fi
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-08 21:56:44 -07:00
|
|
|
local -r interface=$1
|
|
|
|
|
2018-01-05 22:57:16 -07:00
|
|
|
local choices=( \
|
|
|
|
"$FLUXIONScannerChannelOptionAll (2.4GHz)" \
|
|
|
|
"$FLUXIONScannerChannelOptionAll (5GHz)" \
|
|
|
|
"$FLUXIONScannerChannelOptionAll (2.4GHz & 5Ghz)" \
|
|
|
|
"$FLUXIONScannerChannelOptionSpecific" "$FLUXIONGeneralBackOption"
|
|
|
|
)
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-05 22:57:16 -07:00
|
|
|
io_query_choice "$FLUXIONScannerChannelQuery" choices[@]
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
|
|
|
case "$IOQueryChoice" in
|
|
|
|
"$FLUXIONScannerChannelOptionAll (2.4GHz)")
|
2018-01-08 21:56:44 -07:00
|
|
|
fluxion_target_get_candidates $interface "" "bg";;
|
2018-01-06 21:21:37 -07:00
|
|
|
|
|
|
|
"$FLUXIONScannerChannelOptionAll (5GHz)")
|
2018-01-08 21:56:44 -07:00
|
|
|
fluxion_target_get_candidates $interface "" "a";;
|
2018-01-06 21:21:37 -07:00
|
|
|
|
|
|
|
"$FLUXIONScannerChannelOptionAll (2.4GHz & 5Ghz)")
|
2018-01-08 21:56:44 -07:00
|
|
|
fluxion_target_get_candidates $interface "" "abg";;
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-05 22:57:16 -07:00
|
|
|
"$FLUXIONScannerChannelOptionSpecific")
|
|
|
|
fluxion_header
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-01-05 22:57:16 -07:00
|
|
|
echo -e "$FLUXIONVLine $FLUXIONScannerChannelQuery"
|
|
|
|
echo
|
|
|
|
echo -e " $FLUXIONScannerChannelSingleTip ${CBlu}6$CClr "
|
|
|
|
echo -e " $FLUXIONScannerChannelMiltipleTip ${CBlu}1-5$CClr "
|
|
|
|
echo -e " $FLUXIONScannerChannelMiltipleTip ${CBlu}1,2,5-7,11$CClr "
|
|
|
|
echo
|
|
|
|
echo -ne "$FLUXIONPrompt"
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-01-05 22:57:16 -07:00
|
|
|
local channels
|
|
|
|
read channels
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
2018-01-08 21:56:44 -07:00
|
|
|
fluxion_target_get_candidates $interface $channels;;
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-05 22:57:16 -07:00
|
|
|
"$FLUXIONGeneralBackOption")
|
2018-07-11 23:04:26 -06:00
|
|
|
return -1;;
|
2018-01-05 22:57:16 -07:00
|
|
|
esac
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-05 22:57:16 -07:00
|
|
|
# Abort if errors occured while searching for candidates.
|
|
|
|
if [ $? -ne 0 ]; then return 2; fi
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-05 22:57:16 -07:00
|
|
|
local candidatesMAC=()
|
|
|
|
local candidatesClientsCount=()
|
|
|
|
local candidatesChannel=()
|
|
|
|
local candidatesSecurity=()
|
|
|
|
local candidatesSignal=()
|
|
|
|
local candidatesPower=()
|
|
|
|
local candidatesESSID=()
|
|
|
|
local candidatesColor=()
|
|
|
|
|
|
|
|
# Gather information from all the candidates detected.
|
|
|
|
# TODO: Clean up this for loop using a cleaner algorithm.
|
2018-07-11 23:04:26 -06:00
|
|
|
# Maybe try using array appending & [-1] for last elements.
|
2018-01-08 21:56:44 -07:00
|
|
|
for candidateAPInfo in "${FluxionTargetCandidates[@]}"; do
|
2018-01-05 22:57:16 -07:00
|
|
|
# Strip candidate info from any extraneous spaces after commas.
|
|
|
|
candidateAPInfo=$(echo "$candidateAPInfo" | sed -r "s/,\s*/,/g")
|
|
|
|
|
|
|
|
local i=${#candidatesMAC[@]}
|
|
|
|
|
|
|
|
candidatesMAC[i]=$(echo "$candidateAPInfo" | cut -d , -f 1)
|
2018-01-08 21:56:44 -07:00
|
|
|
candidatesClientsCount[i]=$(
|
|
|
|
echo "${FluxionTargetCandidatesClients[@]}" |
|
|
|
|
grep -c "${candidatesMAC[i]}"
|
|
|
|
)
|
2018-01-05 22:57:16 -07:00
|
|
|
candidatesChannel[i]=$(echo "$candidateAPInfo" | cut -d , -f 4)
|
|
|
|
candidatesSecurity[i]=$(echo "$candidateAPInfo" | cut -d , -f 6)
|
|
|
|
candidatesPower[i]=$(echo "$candidateAPInfo" | cut -d , -f 9)
|
2018-01-08 21:56:44 -07:00
|
|
|
candidatesColor[i]=$(
|
|
|
|
[ ${candidatesClientsCount[i]} -gt 0 ] && echo $CGrn || echo $CClr
|
|
|
|
)
|
2018-01-05 22:57:16 -07:00
|
|
|
|
|
|
|
# Parse any non-ascii characters by letting bash handle them.
|
2018-01-09 12:36:29 -07:00
|
|
|
# Escape all single quotes in ESSID and let bash's $'...' handle it.
|
2018-01-08 21:56:44 -07:00
|
|
|
local sanitizedESSID=$(
|
|
|
|
echo "${candidateAPInfo//\'/\\\'}" | cut -d , -f 14
|
|
|
|
)
|
2018-01-05 22:57:16 -07:00
|
|
|
candidatesESSID[i]=$(eval "echo \$'$sanitizedESSID'")
|
|
|
|
|
|
|
|
local power=${candidatesPower[i]}
|
2018-07-11 23:04:26 -06:00
|
|
|
if [ $power -eq -1 ]; then
|
|
|
|
# airodump-ng's man page says -1 means unsupported value.
|
2018-01-05 22:57:16 -07:00
|
|
|
candidatesQuality[i]="??"
|
|
|
|
elif [ $power -le $FLUXIONNoiseFloor ]; then
|
|
|
|
candidatesQuality[i]=0
|
|
|
|
elif [ $power -gt $FLUXIONNoiseCeiling ]; then
|
|
|
|
candidatesQuality[i]=100
|
|
|
|
else
|
2018-01-09 12:36:29 -07:00
|
|
|
# Bash doesn't support floating point division, work around it...
|
|
|
|
# Q = ((P - F) / (C - F)); Q-quality, P-power, F-floor, C-Ceiling.
|
2018-01-10 19:17:08 -07:00
|
|
|
candidatesQuality[i]=$(( \
|
|
|
|
(${candidatesPower[i]} * 10 - $FLUXIONNoiseFloor * 10) / \
|
|
|
|
(($FLUXIONNoiseCeiling - $FLUXIONNoiseFloor) / 10) \
|
|
|
|
))
|
2018-01-05 22:57:16 -07:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
format_center_literals "WIFI LIST"
|
|
|
|
local -r headerTitle="$FormatCenterLiterals\n\n"
|
|
|
|
|
|
|
|
format_apply_autosize "$CRed[$CSYel ** $CClr$CRed]$CClr %-*.*s %4s %3s %3s %2s %-8.8s %18s\n"
|
2018-01-09 12:36:29 -07:00
|
|
|
local -r headerFields=$(
|
|
|
|
printf "$FormatApplyAutosize" \
|
|
|
|
"ESSID" "QLTY" "PWR" "STA" "CH" "SECURITY" "BSSID"
|
|
|
|
)
|
2018-01-05 22:57:16 -07:00
|
|
|
|
|
|
|
format_apply_autosize "$CRed[$CSYel%03d$CClr$CRed]%b %-*.*s %3s%% %3s %3d %2s %-8.8s %18s\n"
|
2018-01-09 12:36:29 -07:00
|
|
|
io_query_format_fields "$headerTitle$headerFields" \
|
|
|
|
"$FormatApplyAutosize" \
|
2018-01-05 22:57:16 -07:00
|
|
|
candidatesColor[@] \
|
|
|
|
candidatesESSID[@] \
|
|
|
|
candidatesQuality[@] \
|
|
|
|
candidatesPower[@] \
|
|
|
|
candidatesClientsCount[@] \
|
|
|
|
candidatesChannel[@] \
|
|
|
|
candidatesSecurity[@] \
|
|
|
|
candidatesMAC[@]
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
2018-01-08 21:56:44 -07:00
|
|
|
FluxionTargetMAC=${IOQueryFormatFields[7]}
|
|
|
|
FluxionTargetSSID=${IOQueryFormatFields[1]}
|
|
|
|
FluxionTargetChannel=${IOQueryFormatFields[5]}
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-08 21:56:44 -07:00
|
|
|
FluxionTargetEncryption=${IOQueryFormatFields[6]}
|
2018-01-05 22:57:16 -07:00
|
|
|
|
2018-01-08 21:56:44 -07:00
|
|
|
FluxionTargetMakerID=${FluxionTargetMAC:0:8}
|
|
|
|
FluxionTargetMaker=$(
|
|
|
|
macchanger -l |
|
|
|
|
grep ${FluxionTargetMakerID,,} 2> $FLUXIONOutputDevice |
|
|
|
|
cut -d ' ' -f 5-
|
2018-01-05 22:57:16 -07:00
|
|
|
)
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-03-16 16:34:28 -06:00
|
|
|
FluxionTargetSSIDClean=$(fluxion_target_normalize_SSID)
|
2018-01-05 22:57:16 -07:00
|
|
|
|
|
|
|
# We'll change a single hex digit from the target AP's MAC address.
|
|
|
|
# This new MAC address will be used as the rogue AP's MAC address.
|
2018-01-09 12:36:29 -07:00
|
|
|
local -r rogueMACHex=$(printf %02X $((0x${FluxionTargetMAC:13:1} + 1)))
|
|
|
|
FluxionTargetRogueMAC="${FluxionTargetMAC::13}${rogueMACHex:1:1}${FluxionTargetMAC:14:4}"
|
2018-01-05 22:57:16 -07:00
|
|
|
}
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-03-16 16:34:28 -06:00
|
|
|
fluxion_target_normalize_SSID() {
|
|
|
|
# Sanitize network ESSID to make it safe for manipulation.
|
|
|
|
# Notice: Why remove these? Some smartass might decide to name their
|
|
|
|
# network "; rm -rf / ;". If the string isn't sanitized accidentally
|
|
|
|
# shit'll hit the fan and we'll have an extremly distressed user.
|
|
|
|
# Replacing ' ', '/', '.', '~', '\' with '_'
|
|
|
|
echo "$FluxionTargetSSID" | sed -r 's/( |\/|\.|\~|\\)+/_/g'
|
|
|
|
}
|
|
|
|
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_target_show() {
|
2018-01-06 21:21:37 -07:00
|
|
|
format_apply_autosize "%*s$CBlu%7s$CClr: %-32s%*s\n"
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-01-06 21:21:37 -07:00
|
|
|
local colorlessFormat="$FormatApplyAutosize"
|
2018-01-09 12:36:29 -07:00
|
|
|
local colorfullFormat=$(
|
|
|
|
echo "$colorlessFormat" | sed -r 's/%-32s/%-32b/g'
|
|
|
|
)
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-08 21:56:44 -07:00
|
|
|
printf "$colorlessFormat" "" "ESSID" "\"${FluxionTargetSSID:-[N/A]}\" / ${FluxionTargetEncryption:-[N/A]}" ""
|
|
|
|
printf "$colorlessFormat" "" "Channel" " ${FluxionTargetChannel:-[N/A]}" ""
|
|
|
|
printf "$colorfullFormat" "" "BSSID" " ${FluxionTargetMAC:-[N/A]} ($CYel${FluxionTargetMaker:-[N/A]}$CClr)" ""
|
2018-01-06 21:21:37 -07:00
|
|
|
|
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
2018-03-15 23:23:03 -06:00
|
|
|
fluxion_target_tracker_daemon() {
|
2018-03-16 16:34:28 -06:00
|
|
|
if [ ! "$1" ]; then return 1; fi # Assure we've got fluxion's PID.
|
|
|
|
|
|
|
|
readonly fluxionPID=$1
|
2018-03-15 23:23:03 -06:00
|
|
|
readonly monitorTimeout=10 # In seconds.
|
|
|
|
readonly capturePath="$FLUXIONWorkspacePath/tracker_capture"
|
|
|
|
|
|
|
|
if [ \
|
|
|
|
-z "$FluxionTargetMAC" -o \
|
|
|
|
-z "$FluxionTargetSSID" -o \
|
|
|
|
-z "$FluxionTargetChannel" ]; then
|
2018-03-16 16:34:28 -06:00
|
|
|
return 2 # If we're missing target information, we can't track properly.
|
2018-03-15 23:23:03 -06:00
|
|
|
fi
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
echo "[T-Tracker] Captor listening for $monitorTimeout seconds..."
|
|
|
|
timeout --preserve-status $monitorTimeout airodump-ng -aw "$capturePath" \
|
2018-03-16 16:34:28 -06:00
|
|
|
-d "$FluxionTargetMAC" $FluxionTargetTrackerInterface &> /dev/null
|
2018-03-15 23:23:03 -06:00
|
|
|
local error=$? # Catch the returned status error code.
|
|
|
|
|
|
|
|
if [ $error -ne 0 ]; then # If any error was encountered, abort!
|
|
|
|
echo -e "[T-Tracker] ${CRed}Error:$CClr Operation aborted (code: $error)!"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
|
2018-03-16 16:34:28 -06:00
|
|
|
local targetInfo=$(head -n 3 "$capturePath-01.csv" | tail -n 1)
|
2018-03-15 23:23:03 -06:00
|
|
|
sandbox_remove_workfile "$capturePath-*"
|
|
|
|
|
|
|
|
local targetChannel=$(
|
|
|
|
echo "$targetInfo" | awk -F, '{gsub(/ /, "", $4); print $4}'
|
|
|
|
)
|
|
|
|
|
2018-03-16 16:34:28 -06:00
|
|
|
echo "[T-Tracker] $targetInfo"
|
|
|
|
|
2018-03-15 23:23:03 -06:00
|
|
|
if [ "$targetChannel" -ne "$FluxionTargetChannel" ]; then
|
2018-03-16 16:34:28 -06:00
|
|
|
echo "[T-Tracker] Target channel change detected!"
|
|
|
|
FluxionTargetChannel=$targetChannel
|
2018-03-15 23:23:03 -06:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
|
|
|
|
# NOTE: We might also want to check for SSID changes here, assuming the only
|
|
|
|
# thing that remains constant is the MAC address. The problem with that is
|
|
|
|
# that airodump-ng has some serious problems with unicode, apparently.
|
|
|
|
# Try feeding it an access point with Chinese characters and check the .csv.
|
|
|
|
done
|
|
|
|
|
2018-03-16 16:34:28 -06:00
|
|
|
# Save/overwrite the new target information to the workspace for retrival.
|
|
|
|
echo "$FluxionTargetMAC" > "$FLUXIONWorkspacePath/target_info.txt"
|
|
|
|
echo "$FluxionTargetSSID" >> "$FLUXIONWorkspacePath/target_info.txt"
|
|
|
|
echo "$FluxionTargetChannel" >> "$FLUXIONWorkspacePath/target_info.txt"
|
|
|
|
|
|
|
|
# NOTICE: Using different signals for different things is a BAD idea.
|
|
|
|
# We should use a single signal, SIGINT, to handle different situations.
|
|
|
|
kill -s SIGALRM $fluxionPID # Signal fluxion a change was detected.
|
|
|
|
|
2018-03-15 23:23:03 -06:00
|
|
|
sandbox_remove_workfile "$capturePath-*"
|
|
|
|
}
|
|
|
|
|
|
|
|
fluxion_target_tracker_stop() {
|
|
|
|
if [ ! "$FluxionTargetTrackerDaemonPID" ]; then return 1; fi
|
|
|
|
kill -s SIGABRT $FluxionTargetTrackerDaemonPID &> /dev/null
|
|
|
|
FluxionTargetTrackerDaemonPID=""
|
|
|
|
}
|
|
|
|
|
|
|
|
fluxion_target_tracker_start() {
|
2018-03-16 16:34:28 -06:00
|
|
|
if [ ! "$FluxionTargetTrackerInterface" ]; then return 1; fi
|
|
|
|
|
|
|
|
fluxion_target_tracker_daemon $$ &> "$FLUXIONOutputDevice" &
|
2018-03-15 23:23:03 -06:00
|
|
|
FluxionTargetTrackerDaemonPID=$!
|
|
|
|
}
|
|
|
|
|
2018-01-20 15:06:45 -07:00
|
|
|
fluxion_target_unset_tracker() {
|
|
|
|
if [ ! "$FluxionTargetTrackerInterface" ]; then return 1; fi
|
|
|
|
|
|
|
|
FluxionTargetTrackerInterface=""
|
|
|
|
}
|
|
|
|
|
|
|
|
fluxion_target_set_tracker() {
|
2018-03-16 16:34:28 -06:00
|
|
|
if [ "$FluxionTargetTrackerInterface" ]; then
|
|
|
|
echo "Tracker interface already set, skipping." > $FLUXIONOutputDevice
|
|
|
|
return 0
|
|
|
|
fi
|
2018-01-20 15:06:45 -07:00
|
|
|
|
|
|
|
# Check if attack provides tracking interfaces, get & set one.
|
|
|
|
if ! type -t attack_tracking_interfaces &> /dev/null; then
|
2018-03-16 16:34:28 -06:00
|
|
|
echo "Tracker DOES NOT have interfaces available!" > $FLUXIONOutputDevice
|
2018-01-20 15:06:45 -07:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2018-03-16 16:34:28 -06:00
|
|
|
if [ "$FluxionTargetTrackerInterface" == "" ]; then
|
2018-01-20 15:06:45 -07:00
|
|
|
echo "Running get interface (tracker)." > $FLUXIONOutputDevice
|
2018-04-27 17:00:11 -06:00
|
|
|
local -r interfaceQuery=$FLUXIONTargetTrackerInterfaceQuery
|
|
|
|
local -r interfaceQueryTip=$FLUXIONTargetTrackerInterfaceQueryTip
|
2018-01-20 15:06:45 -07:00
|
|
|
if ! fluxion_get_interface attack_tracking_interfaces \
|
2018-04-27 17:00:11 -06:00
|
|
|
"$interfaceQuery\n$FLUXIONVLine $interfaceQueryTip"; then
|
2018-01-20 15:06:45 -07:00
|
|
|
echo "Failed to get tracker interface!" > $FLUXIONOutputDevice
|
|
|
|
return 2
|
|
|
|
fi
|
|
|
|
local selectedInterface=$FluxionInterfaceSelected
|
|
|
|
else
|
2018-03-15 23:23:03 -06:00
|
|
|
# Assume user passed one via the command line and move on.
|
|
|
|
# If none was given we'll take care of that case below.
|
2018-01-20 15:06:45 -07:00
|
|
|
local selectedInterface=$FluxionTargetTrackerInterface
|
2018-03-16 16:34:28 -06:00
|
|
|
echo "Tracker interface passed via command line!" > $FLUXIONOutputDevice
|
2018-01-20 15:06:45 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
# If user skipped a tracker interface, move on.
|
|
|
|
if [ ! "$selectedInterface" ]; then
|
|
|
|
fluxion_target_unset_tracker
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! fluxion_allocate_interface $selectedInterface; then
|
|
|
|
echo "Failed to allocate tracking interface!" > $FLUXIONOutputDevice
|
|
|
|
return 3
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Successfully got tracker interface." > $FLUXIONOutputDevice
|
|
|
|
FluxionTargetTrackerInterface=${FluxionInterfaces[$selectedInterface]}
|
|
|
|
}
|
|
|
|
|
|
|
|
fluxion_target_unset() {
|
|
|
|
FluxionTargetMAC=""
|
|
|
|
FluxionTargetSSID=""
|
|
|
|
FluxionTargetChannel=""
|
|
|
|
|
|
|
|
FluxionTargetEncryption=""
|
|
|
|
|
|
|
|
FluxionTargetMakerID=""
|
|
|
|
FluxionTargetMaker=""
|
|
|
|
|
|
|
|
FluxionTargetSSIDClean=""
|
|
|
|
|
|
|
|
FluxionTargetRogueMAC=""
|
|
|
|
|
|
|
|
return 1 # To trigger undo-chain.
|
|
|
|
}
|
|
|
|
|
|
|
|
fluxion_target_set() {
|
|
|
|
# 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
|
|
|
|
# If we've got a candidate target, ask user if we'll keep targetting it.
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2018-03-16 16:34:28 -06:00
|
|
|
if ! fluxion_get_interface attack_targetting_interfaces \
|
|
|
|
"$FLUXIONTargetSearchingInterfaceQuery"; then
|
2018-01-20 15:06:45 -07:00
|
|
|
return 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! fluxion_allocate_interface $FluxionInterfaceSelected; then
|
|
|
|
return 3
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! fluxion_get_target \
|
|
|
|
${FluxionInterfaces[$FluxionInterfaceSelected]}; then
|
|
|
|
return 4
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-01-06 21:21:37 -07:00
|
|
|
|
|
|
|
# =================== < Hash Subroutines > =================== #
|
|
|
|
# Parameters: <hash path> <bssid> <essid> [channel [encryption [maker]]]
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_hash_verify() {
|
2018-01-06 21:21:37 -07:00
|
|
|
if [ ${#@} -lt 3 ]; then return 1; fi
|
|
|
|
|
|
|
|
local -r hashPath=$1
|
|
|
|
local -r hashBSSID=$2
|
|
|
|
local -r hashESSID=$3
|
|
|
|
local -r hashChannel=$4
|
|
|
|
local -r hashEncryption=$5
|
|
|
|
local -r hashMaker=$6
|
|
|
|
|
|
|
|
if [ ! -f "$hashPath" -o ! -s "$hashPath" ]; then
|
|
|
|
echo -e "$FLUXIONVLine $FLUXIONHashFileDoesNotExistError"
|
|
|
|
sleep 3
|
|
|
|
return 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$FLUXIONAuto" ]; then
|
2018-05-04 11:52:53 -06:00
|
|
|
local -r verifier="cowpatty"
|
2018-01-06 21:21:37 -07:00
|
|
|
else
|
|
|
|
fluxion_header
|
|
|
|
|
|
|
|
echo -e "$FLUXIONVLine $FLUXIONHashVerificationMethodQuery"
|
|
|
|
echo
|
|
|
|
|
2018-01-20 15:06:45 -07:00
|
|
|
fluxion_target_show
|
2018-01-06 21:21:37 -07:00
|
|
|
|
|
|
|
local choices=( \
|
|
|
|
"$FLUXIONHashVerificationMethodPyritOption" \
|
|
|
|
"$FLUXIONHashVerificationMethodAircrackOption" \
|
2018-05-02 18:50:28 -06:00
|
|
|
"$FLUXIONHashVerificationMethodCowpattyOption" \
|
2018-01-06 21:21:37 -07:00
|
|
|
"$FLUXIONGeneralBackOption" \
|
|
|
|
)
|
|
|
|
|
|
|
|
io_query_choice "" choices[@]
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
|
|
|
case "$IOQueryChoice" in
|
|
|
|
"$FLUXIONHashVerificationMethodPyritOption")
|
|
|
|
local -r verifier="pyrit" ;;
|
|
|
|
|
|
|
|
"$FLUXIONHashVerificationMethodAircrackOption")
|
|
|
|
local -r verifier="aircrack-ng" ;;
|
|
|
|
|
2018-05-02 18:50:28 -06:00
|
|
|
"$FLUXIONHashVerificationMethodCowpattyOption")
|
|
|
|
local -r verifier="cowpatty" ;;
|
|
|
|
|
2018-01-06 21:21:37 -07:00
|
|
|
"$FLUXIONGeneralBackOption")
|
2018-07-11 23:04:26 -06:00
|
|
|
return -1 ;;
|
2018-01-06 21:21:37 -07:00
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
|
|
|
hash_check_handshake \
|
|
|
|
"$verifier" \
|
|
|
|
"$hashPath" \
|
2018-01-10 19:17:08 -07:00
|
|
|
"$hashESSID" \
|
|
|
|
"$hashBSSID"
|
2018-01-06 21:21:37 -07:00
|
|
|
|
|
|
|
local -r hashResult=$?
|
|
|
|
|
|
|
|
# A value other than 0 means there's an issue with the hash.
|
|
|
|
if [ $hashResult -ne 0 ]; then
|
|
|
|
echo -e "$FLUXIONVLine $FLUXIONHashInvalidError"
|
|
|
|
else
|
|
|
|
echo -e "$FLUXIONVLine $FLUXIONHashValidNotice"
|
|
|
|
fi
|
|
|
|
|
|
|
|
sleep 3
|
|
|
|
|
|
|
|
if [ $hashResult -ne 0 ]; then return 1; fi
|
|
|
|
}
|
|
|
|
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_hash_unset_path() {
|
2018-01-17 14:26:04 -07:00
|
|
|
if [ ! "$FluxionHashPath" ]; then return 1; fi
|
2018-01-06 21:21:37 -07:00
|
|
|
FluxionHashPath=""
|
2018-01-20 01:54:55 -07:00
|
|
|
|
|
|
|
# Since we're auto-selecting when on auto, trigger undo-chain.
|
|
|
|
if [ "$FLUXIONAuto" ]; then return 2; fi
|
2018-01-06 21:21:37 -07:00
|
|
|
}
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-01-06 21:21:37 -07:00
|
|
|
# Parameters: <hash path> <bssid> <essid> [channel [encryption [maker]]]
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_hash_set_path() {
|
2018-01-06 21:21:37 -07:00
|
|
|
if [ "$FluxionHashPath" ]; then return 0; fi
|
2018-01-05 17:32:57 -07:00
|
|
|
|
2018-01-06 21:21:37 -07:00
|
|
|
fluxion_hash_unset_path
|
|
|
|
|
|
|
|
local -r hashPath=$1
|
|
|
|
|
|
|
|
# If we've got a default path, check if a hash exists.
|
|
|
|
# If one exists, ask users if they'd like to use it.
|
|
|
|
if [ "$hashPath" -a -f "$hashPath" -a -s "$hashPath" ]; then
|
2018-01-20 01:54:55 -07:00
|
|
|
if [ "$FLUXIONAuto" ]; then
|
|
|
|
FluxionHashPath=$hashPath
|
|
|
|
return
|
|
|
|
else
|
|
|
|
local choices=( \
|
|
|
|
"$FLUXIONUseFoundHashOption" \
|
|
|
|
"$FLUXIONSpecifyHashPathOption" \
|
|
|
|
"$FLUXIONHashSourceRescanOption" \
|
|
|
|
"$FLUXIONGeneralBackOption" \
|
|
|
|
)
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-20 01:54:55 -07:00
|
|
|
fluxion_header
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-20 01:54:55 -07:00
|
|
|
echo -e "$FLUXIONVLine $FLUXIONFoundHashNotice"
|
|
|
|
echo -e "$FLUXIONVLine $FLUXIONUseFoundHashQuery"
|
|
|
|
echo
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-20 01:54:55 -07:00
|
|
|
io_query_choice "" choices[@]
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-20 01:54:55 -07:00
|
|
|
echo
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-20 01:54:55 -07:00
|
|
|
case "$IOQueryChoice" in
|
|
|
|
"$FLUXIONUseFoundHashOption")
|
|
|
|
FluxionHashPath=$hashPath
|
|
|
|
return ;;
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-20 01:54:55 -07:00
|
|
|
"$FLUXIONHashSourceRescanOption")
|
|
|
|
fluxion_hash_set_path "$@"
|
|
|
|
return $? ;;
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-20 01:54:55 -07:00
|
|
|
"$FLUXIONGeneralBackOption")
|
2018-07-11 23:04:26 -06:00
|
|
|
return -1 ;;
|
2018-01-20 01:54:55 -07:00
|
|
|
esac
|
|
|
|
fi
|
2018-01-06 21:21:37 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
while [ ! "$FluxionHashPath" ]; do
|
|
|
|
fluxion_header
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo -e "$FLUXIONVLine $FLUXIONPathToHandshakeFileQuery"
|
|
|
|
echo -e "$FLUXIONVLine $FLUXIONPathToHandshakeFileReturnTip"
|
|
|
|
echo
|
|
|
|
echo -ne "$FLUXIONAbsolutePathInfo: "
|
|
|
|
read FluxionHashPath
|
|
|
|
|
|
|
|
# Back-track when the user leaves the hash path blank.
|
|
|
|
# Notice: Path is cleared if we return, no need to unset.
|
2018-07-10 14:50:19 -06:00
|
|
|
if [ ! "$FluxionHashPath" ]; then return 1; fi
|
2018-01-06 21:21:37 -07:00
|
|
|
|
|
|
|
# Make sure the path points to a valid generic file.
|
|
|
|
if [ ! -f "$FluxionHashPath" -o ! -s "$FluxionHashPath" ]; then
|
|
|
|
echo -e "$FLUXIONVLine $FLUXIONEmptyOrNonExistentHashError"
|
|
|
|
sleep 5
|
|
|
|
fluxion_hash_unset_path
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# Paramters: <defaultHashPath> <bssid> <essid>
|
2018-01-17 14:26:04 -07:00
|
|
|
fluxion_hash_get_path() {
|
2018-01-06 21:21:37 -07:00
|
|
|
# Assure we've got the bssid and the essid passed in.
|
|
|
|
if [ ${#@} -lt 2 ]; then return 1; fi
|
|
|
|
|
2018-01-08 21:56:44 -07:00
|
|
|
while true; do
|
2018-01-17 22:11:04 -07:00
|
|
|
fluxion_hash_unset_path
|
2018-03-13 17:56:49 -06:00
|
|
|
if ! fluxion_hash_set_path "$@"; then
|
2018-07-11 23:04:26 -06:00
|
|
|
return -1 # WARNING: The recent error code is NOT contained in $? here!
|
2018-03-13 17:56:49 -06:00
|
|
|
fi
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-17 22:11:04 -07:00
|
|
|
if fluxion_hash_verify "$FluxionHashPath" "$2" "$3"; then
|
2018-01-08 21:56:44 -07:00
|
|
|
break;
|
|
|
|
fi
|
|
|
|
done
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-08 21:56:44 -07:00
|
|
|
# At this point FluxionHashPath will be set and ready.
|
2018-01-06 21:21:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# ================== < Attack Subroutines > ================== #
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_unset_attack() {
|
2018-01-16 22:09:09 -07:00
|
|
|
local -r attackWasSet=${FluxionAttack:+1}
|
2018-01-06 21:21:37 -07:00
|
|
|
FluxionAttack=""
|
2018-01-16 22:09:09 -07:00
|
|
|
if [ ! "$attackWasSet" ]; then return 1; fi
|
2018-01-06 21:21:37 -07:00
|
|
|
}
|
|
|
|
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_set_attack() {
|
2018-01-06 21:21:37 -07:00
|
|
|
if [ "$FluxionAttack" ]; then return 0; fi
|
|
|
|
|
|
|
|
fluxion_unset_attack
|
|
|
|
|
|
|
|
fluxion_header
|
|
|
|
|
|
|
|
echo -e "$FLUXIONVLine $FLUXIONAttackQuery"
|
|
|
|
echo
|
|
|
|
|
|
|
|
fluxion_target_show
|
|
|
|
|
|
|
|
local attacks
|
2018-07-10 16:41:38 -06:00
|
|
|
readarray -t attacks < <(ls -1 "$FLUXIONPath/attacks")
|
2018-01-06 21:21:37 -07:00
|
|
|
|
|
|
|
local descriptions
|
2018-01-09 12:36:29 -07:00
|
|
|
readarray -t descriptions < <(
|
2018-05-24 17:44:53 -06:00
|
|
|
head -n 3 "$FLUXIONPath/attacks/"*"/language/$FluxionLanguage.sh" | \
|
2018-01-09 12:36:29 -07:00
|
|
|
grep -E "^# description: " | sed -E 's/# \w+: //'
|
|
|
|
)
|
2018-01-06 21:21:37 -07:00
|
|
|
|
|
|
|
local identifiers=()
|
|
|
|
|
|
|
|
local attack
|
|
|
|
for attack in "${attacks[@]}"; do
|
2018-01-09 12:36:29 -07:00
|
|
|
local identifier=$(
|
2018-05-24 17:44:53 -06:00
|
|
|
head -n 3 "$FLUXIONPath/attacks/$attack/language/$FluxionLanguage.sh" | \
|
2018-01-09 12:36:29 -07:00
|
|
|
grep -E "^# identifier: " | sed -E 's/# \w+: //'
|
|
|
|
)
|
2018-03-13 21:15:03 -06:00
|
|
|
if [ "$identifier" ]; then
|
|
|
|
identifiers+=("$identifier")
|
|
|
|
else
|
|
|
|
identifiers+=("$attack")
|
2018-01-06 21:21:37 -07:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2018-01-09 00:46:40 -07:00
|
|
|
attacks+=("$FLUXIONGeneralBackOption")
|
|
|
|
identifiers+=("$FLUXIONGeneralBackOption")
|
2018-01-06 21:21:37 -07:00
|
|
|
descriptions+=("")
|
|
|
|
|
2018-01-09 12:36:29 -07:00
|
|
|
io_query_format_fields "" \
|
|
|
|
"\t$CRed[$CSYel%d$CClr$CRed]$CClr%0.0s $CCyn%b$CClr %b\n" \
|
|
|
|
attacks[@] identifiers[@] descriptions[@]
|
2018-01-06 21:21:37 -07:00
|
|
|
|
|
|
|
echo
|
|
|
|
|
2018-01-09 00:46:40 -07:00
|
|
|
if [ "${IOQueryFormatFields[1]}" = "$FLUXIONGeneralBackOption" ]; then
|
2018-07-11 23:04:26 -06:00
|
|
|
return -1
|
2018-01-06 21:21:37 -07:00
|
|
|
fi
|
2018-05-28 07:17:27 -06:00
|
|
|
|
2018-04-23 13:02:54 -06:00
|
|
|
if [ "${IOQueryFormatFields[1]}" = "$FLUXIONAttackRestartOption" ]; then
|
2018-01-25 13:29:04 -07:00
|
|
|
return 2
|
|
|
|
fi
|
|
|
|
|
2018-01-06 21:21:37 -07:00
|
|
|
|
|
|
|
FluxionAttack=${IOQueryFormatFields[0]}
|
|
|
|
}
|
|
|
|
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_unprep_attack() {
|
2018-01-06 21:21:37 -07:00
|
|
|
if type -t unprep_attack &> /dev/null; then
|
|
|
|
unprep_attack
|
|
|
|
fi
|
|
|
|
|
2018-01-10 23:20:41 -07:00
|
|
|
IOUtilsHeader="fluxion_header"
|
|
|
|
|
2018-04-22 21:59:16 -06:00
|
|
|
# Remove any lingering targetting subroutines loaded.
|
2018-03-15 23:23:03 -06:00
|
|
|
unset attack_targetting_interfaces
|
|
|
|
unset attack_tracking_interfaces
|
|
|
|
|
2018-04-22 21:59:16 -06:00
|
|
|
# Remove any lingering restoration subroutines loaded.
|
|
|
|
unset load_attack
|
|
|
|
unset save_attack
|
|
|
|
|
2018-03-16 16:34:28 -06:00
|
|
|
FluxionTargetTrackerInterface=""
|
|
|
|
|
2018-01-06 21:21:37 -07:00
|
|
|
return 1 # Trigger another undo since prep isn't significant.
|
|
|
|
}
|
|
|
|
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_prep_attack() {
|
2018-01-06 21:21:37 -07:00
|
|
|
local -r path="$FLUXIONPath/attacks/$FluxionAttack"
|
|
|
|
|
|
|
|
if [ ! -x "$path/attack.sh" ]; then return 1; fi
|
2018-01-09 13:43:40 -07:00
|
|
|
if [ ! -x "$path/language/$FluxionLanguage.sh" ]; then return 2; fi
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-20 01:44:30 -07:00
|
|
|
# Load attack parameters if any exist.
|
|
|
|
if [ "$AttackCLIArguments" ]; then
|
|
|
|
eval set -- "$AttackCLIArguments"
|
|
|
|
# Remove them after loading them once.
|
|
|
|
unset AttackCLIArguments
|
|
|
|
fi
|
|
|
|
|
2018-01-06 21:21:37 -07:00
|
|
|
# Load attack and its corresponding language file.
|
2018-01-18 00:16:47 -07:00
|
|
|
# Load english by default to overwrite globals that ARE defined.
|
|
|
|
source "$path/language/en.sh"
|
|
|
|
if [ "$FluxionLanguage" != "en" ]; then
|
|
|
|
source "$path/language/$FluxionLanguage.sh"
|
|
|
|
fi
|
2018-01-06 21:21:37 -07:00
|
|
|
source "$path/attack.sh"
|
2018-01-10 19:17:08 -07:00
|
|
|
|
2018-01-16 22:09:09 -07:00
|
|
|
# Check if attack is targetted & set the attack target if so.
|
2018-01-10 19:17:08 -07:00
|
|
|
if type -t attack_targetting_interfaces &> /dev/null; then
|
2018-01-20 15:06:45 -07:00
|
|
|
if ! fluxion_target_set; then return 3; fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check if attack provides tracking interfaces, get & set one.
|
2018-03-16 20:00:48 -06:00
|
|
|
# TODO: Uncomment the lines below after implementation.
|
2018-04-22 21:16:37 -06:00
|
|
|
if type -t attack_tracking_interfaces &> /dev/null; then
|
|
|
|
if ! fluxion_target_set_tracker; then return 4; fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# If attack is capable of restoration, check for configuration.
|
|
|
|
if type -t load_attack &> /dev/null; then
|
|
|
|
# If configuration file available, check if user wants to restore.
|
|
|
|
if [ -f "$path/attack.conf" ]; then
|
2018-04-23 13:02:54 -06:00
|
|
|
local choices=( \
|
|
|
|
"$FLUXIONAttackRestoreOption" \
|
|
|
|
"$FLUXIONAttackResetOption" \
|
|
|
|
)
|
|
|
|
|
2018-04-23 13:40:57 -06:00
|
|
|
io_query_choice "$FLUXIONAttackResumeQuery" choices[@]
|
2018-04-22 21:16:37 -06:00
|
|
|
|
2018-04-23 13:02:54 -06:00
|
|
|
if [ "$IOQueryChoice" = "$FLUXIONAttackRestoreOption" ]; then
|
2018-04-22 21:16:37 -06:00
|
|
|
load_attack "$path/attack.conf"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-20 15:06:45 -07:00
|
|
|
if ! prep_attack; then return 5; fi
|
2018-04-22 21:16:37 -06:00
|
|
|
|
|
|
|
# Save the attack for user's convenience if possible.
|
|
|
|
if type -t save_attack &> /dev/null; then
|
|
|
|
save_attack "$path/attack.conf"
|
|
|
|
fi
|
2018-01-06 21:21:37 -07:00
|
|
|
}
|
|
|
|
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_run_attack() {
|
2018-01-06 21:21:37 -07:00
|
|
|
start_attack
|
2018-03-16 16:34:28 -06:00
|
|
|
fluxion_target_tracker_start
|
2018-01-06 21:21:37 -07:00
|
|
|
|
|
|
|
local choices=( \
|
|
|
|
"$FLUXIONSelectAnotherAttackOption" \
|
|
|
|
"$FLUXIONGeneralExitOption" \
|
|
|
|
)
|
|
|
|
|
|
|
|
io_query_choice \
|
2018-01-10 19:17:08 -07:00
|
|
|
"$(io_dynamic_output $FLUXIONAttackInProgressNotice)" choices[@]
|
2018-01-06 21:21:37 -07:00
|
|
|
|
|
|
|
echo
|
|
|
|
|
|
|
|
# IOQueryChoice is a global, meaning, its value is volatile.
|
|
|
|
# We need to make sure to save the choice before it changes.
|
|
|
|
local choice="$IOQueryChoice"
|
|
|
|
|
2018-03-16 16:34:28 -06:00
|
|
|
fluxion_target_tracker_stop
|
2018-01-06 21:21:37 -07:00
|
|
|
stop_attack
|
|
|
|
|
|
|
|
if [ "$choice" = "$FLUXIONGeneralExitOption" ]; then
|
|
|
|
fluxion_handle_exit
|
|
|
|
fi
|
|
|
|
|
2018-03-13 21:15:03 -06:00
|
|
|
fluxion_unprep_attack
|
2018-01-06 21:21:37 -07:00
|
|
|
fluxion_unset_attack
|
|
|
|
}
|
2018-01-05 17:32:57 -07:00
|
|
|
|
|
|
|
# ============================================================ #
|
|
|
|
# ================= < Argument Executables > ================= #
|
|
|
|
# ============================================================ #
|
|
|
|
eval set -- "$FLUXIONCLIArguments" # Set environment parameters.
|
2018-01-20 01:44:30 -07:00
|
|
|
while [ "$1" != "" -a "$1" != "--" ]; do
|
2018-01-05 17:32:57 -07:00
|
|
|
case "$1" in
|
|
|
|
-t|--target) echo "Not yet implemented!"; sleep 3; fluxion_shutdown;;
|
|
|
|
esac
|
|
|
|
shift # Shift new parameters
|
|
|
|
done
|
|
|
|
|
|
|
|
# ============================================================ #
|
|
|
|
# ===================== < FLUXION Loop > ===================== #
|
|
|
|
# ============================================================ #
|
2018-01-09 14:20:11 -07:00
|
|
|
fluxion_main() {
|
2018-01-05 17:32:57 -07:00
|
|
|
fluxion_startup
|
|
|
|
|
|
|
|
fluxion_set_resolution
|
|
|
|
|
2018-01-10 23:20:41 -07:00
|
|
|
# Removed read-only due to local constant shadowing bug.
|
|
|
|
# I've reported the bug, we can add it when fixed.
|
|
|
|
local sequence=(
|
2018-01-09 14:20:11 -07:00
|
|
|
"set_language"
|
|
|
|
"set_attack"
|
|
|
|
"prep_attack"
|
|
|
|
"run_attack"
|
2018-01-09 00:46:40 -07:00
|
|
|
)
|
2018-01-09 12:36:29 -07:00
|
|
|
|
2018-01-09 13:43:40 -07:00
|
|
|
while true; do # Fluxion's runtime-loop.
|
|
|
|
fluxion_do_sequence fluxion sequence[@]
|
2018-01-05 17:32:57 -07:00
|
|
|
done
|
2018-01-06 21:21:37 -07:00
|
|
|
|
2018-01-05 17:32:57 -07:00
|
|
|
fluxion_shutdown
|
|
|
|
}
|
|
|
|
|
|
|
|
fluxion_main # Start Fluxion
|
|
|
|
|
|
|
|
# FLUXSCRIPT END
|