Tmux flag, preferences saving, & sequence addition.

Added & started implementing the tmux flag, as an alternative to xterm.
Added & started implementing redundant-preferences saving (language, ...).
Added the language selection screen to fluxion's main sequence.

Fixed minor bugs.
This commit is contained in:
Matias Barcenas 2018-01-09 01:46:40 -06:00
parent 98f3d2b7ea
commit 792c362d26
1 changed files with 52 additions and 26 deletions

60
fluxion
View File

@ -33,6 +33,7 @@ if [ $EUID -ne 0 ] # Super User Check
fi fi
# ===================== < XTerm Checks > ===================== # # ===================== < XTerm Checks > ===================== #
# TODO: Run the checks below only if we're not using tmux.
if [ ! "${DISPLAY:-}" ] # Assure display is available. if [ ! "${DISPLAY:-}" ] # Assure display is available.
then echo -e "Aborted, X (graphical) session unavailable."; exit 2 then echo -e "Aborted, X (graphical) session unavailable."; exit 2
fi fi
@ -76,7 +77,7 @@ source lib/HashUtils.sh
# ============================================================ # # ============================================================ #
# =================== < Parse Parameters > =================== # # =================== < Parse Parameters > =================== #
# ============================================================ # # ============================================================ #
if ! FLUXIONCLIArguments=$(getopt --options="vdkrntl:a:" --longoptions="debug,version,killer,reloader,airmon-ng,target,test,language:,attack:" --name="FLUXION V$FLUXIONVersion.$FLUXIONRevision" -- "$@") if ! FLUXIONCLIArguments=$(getopt --options="vdkrnmtl:a:" --longoptions="debug,version,killer,reloader,airmon-ng,multiplexer,target,test,language:,attack:" --name="FLUXION V$FLUXIONVersion.$FLUXIONRevision" -- "$@")
then echo -e "${CRed}Aborted$CClr, parameter error detected..."; exit 5 then echo -e "${CRed}Aborted$CClr, parameter error detected..."; exit 5
fi fi
@ -99,6 +100,7 @@ while [ "$1" != "--" ]; do
-k|--killer) declare -r FLUXIONWIKillProcesses=1;; -k|--killer) declare -r FLUXIONWIKillProcesses=1;;
-r|--reloader) declare -r FLUXIONWIReloadDriver=1;; -r|--reloader) declare -r FLUXIONWIReloadDriver=1;;
-n|--airmon-ng) declare -r FLUXIONAirmonNG=1;; -n|--airmon-ng) declare -r FLUXIONAirmonNG=1;;
-m|--multiplexer) declare -r FLUXIONTMux=1;;
-l|--language) FLUXIONLanguage=$2; shift;; -l|--language) FLUXIONLanguage=$2; shift;;
-a|--attack) FLUXIONAttack=$2; shift;; -a|--attack) FLUXIONAttack=$2; shift;;
esac esac
@ -110,9 +112,13 @@ shift # Remove "--" to prepare for attacks to read parameters.
# =================== < User Preferences > =================== # # =================== < User Preferences > =================== #
# Load user-defined preferences if there's an executable script. # Load user-defined preferences if there's an executable script.
# If no script exists, prepare one for the user to store config.
# WARNING: Preferences file must assure no redeclared constants. # WARNING: Preferences file must assure no redeclared constants.
if [ -x "$FLUXIONPreferencesFile" ] if [ -x "$FLUXIONPreferencesFile" ]
then source "$FLUXIONPreferencesFile" then source "$FLUXIONPreferencesFile"
else
echo '#!/bin/bash' > "$FLUXIONPreferencesFile"
chmod u+x "$FLUXIONPreferencesFile"
fi fi
# ================ < Configurable Constants > ================ # # ================ < Configurable Constants > ================ #
@ -450,10 +456,11 @@ function fluxion_undo() {
local __fluxion_undo__i local __fluxion_undo__i
for (( __fluxion_undo__i=${#__fluxion_undo__history[@]}; \ for (( __fluxion_undo__i=${#__fluxion_undo__history[@]}; \
__fluxion_undo__i > 0; __fluxion_undo__i-- )); do __fluxion_undo__i > 0; __fluxion_undo__i-- )); do
local -r __fluxion_undo__instruction=${__fluxion_undo__history[__fluxion_undo__i-1]} local __fluxion_undo__instruction=${__fluxion_undo__history[__fluxion_undo__i-1]}
local -r __fluxion_undo__command=${__fluxion_undo__instruction%%_*} local __fluxion_undo__command=${__fluxion_undo__instruction%%_*}
local -r __fluxion_undo__identifier=${__fluxion_undo__instruction#*_} local __fluxion_undo__identifier=${__fluxion_undo__instruction#*_}
if eval ${__fluxion_undo__namespace}_${FLUXIONUndoable["$__fluxion_undo__command"]}_$__fluxion_undo__identifier; then
if ! eval ${__fluxion_undo__namespace}_${FLUXIONUndoable["$__fluxion_undo__command"]}_$__fluxion_undo__identifier; then
eval FXDLog_$__fluxion_undo__namespace=\("${__fluxion_undo__history[@]::$__fluxion_undo__i}"\) eval FXDLog_$__fluxion_undo__namespace=\("${__fluxion_undo__history[@]::$__fluxion_undo__i}"\)
return 0 return 0
fi fi
@ -468,7 +475,8 @@ function fluxion_done() {
local -r __fluxion_done__namespace=$1 local -r __fluxion_done__namespace=$1
eval "FluxionDone=\${FXDLog_$__fluxion_done__namespace[-1]}" eval "FluxionDone=\${FXDLog_$__fluxion_done__namespace[-1]}"
[ ! $FluxionDone ] && return 1
if [ ! "$FluxionDone" ]; then return 1; fi
} }
function fluxion_done_reset() { function fluxion_done_reset() {
@ -501,6 +509,7 @@ function fluxion_do_sequence() {
__fluxion_do_sequence__index["${__fluxion_do_sequence__sequence[i-1]}"]=$i __fluxion_do_sequence__index["${__fluxion_do_sequence__sequence[i-1]}"]=$i
done done
# Start sequence with the first instruction available.
local __fluxion_do_sequence__instruction=${__fluxion_do_sequence__sequence[0]} local __fluxion_do_sequence__instruction=${__fluxion_do_sequence__sequence[0]}
while [ "$__fluxion_do_sequence__instruction" ]; do while [ "$__fluxion_do_sequence__instruction" ]; do
if ! fluxion_do $__fluxion_do_sequence__namespace $__fluxion_do_sequence__instruction; then if ! fluxion_do $__fluxion_do_sequence__namespace $__fluxion_do_sequence__instruction; then
@ -509,7 +518,9 @@ function fluxion_do_sequence() {
fi fi
fi fi
if ! fluxion_done; then return -3; fi if ! fluxion_done $__fluxion_do_sequence__namespace; then
return -3;
fi
local __fluxion_do_sequence__instructionIndex=${__fluxion_do_sequence__index["$FluxionDone"]} local __fluxion_do_sequence__instructionIndex=${__fluxion_do_sequence__index["$FluxionDone"]}
@ -544,13 +555,14 @@ function fluxion_header() {
# ======================= < Language > ======================= # # ======================= < Language > ======================= #
function fluxion_unset_language() { function fluxion_unset_language() {
FLUXIONLanguage="" FLUXIONLanguage=""
if [ "$FLUXIONPreferencesFile" ]; then
sed -i.backup "/FLUXIONLanguage=.\+/ d" "$FLUXIONPreferencesFile"
fi
} }
function fluxion_set_language() { function fluxion_set_language() {
if [ ! "$FLUXIONLanguage" ]; then if [ ! "$FLUXIONLanguage" ]; then
if [ "$FLUXIONAuto" ]; then
FLUXIONLanguage="en"
else
# Get all languages available. # Get all languages available.
local languageCodes local languageCodes
readarray -t languageCodes < <(ls -1 language | sed -E 's/\.sh//') readarray -t languageCodes < <(ls -1 language | sed -E 's/\.sh//')
@ -564,7 +576,6 @@ function fluxion_set_language() {
echo # Do not remove. echo # Do not remove.
fi fi
fi
# Check if all language files are present for the selected language. # Check if all language files are present for the selected language.
find -type d -name language | while read language_dir; do find -type d -name language | while read language_dir; do
@ -581,6 +592,16 @@ function fluxion_set_language() {
fi fi
source "$FLUXIONPath/language/$FLUXIONLanguage.sh" source "$FLUXIONPath/language/$FLUXIONLanguage.sh"
if [ "$FLUXIONPreferencesFile" ]; then
if more $FLUXIONPreferencesFile | \
grep -q "FLUXIONLanguage=.\+" &> /dev/null; then
sed -r "s/FLUXIONLanguage=.+/FLUXIONLanguage=$FLUXIONLanguage/g" \
-i.backup "$FLUXIONPreferencesFile"
else
echo "FLUXIONLanguage=$FLUXIONLanguage" >> "$FLUXIONPreferencesFile"
fi
fi
} }
# ====================== < Interfaces > ====================== # # ====================== < Interfaces > ====================== #
@ -1260,16 +1281,16 @@ function fluxion_set_attack() {
fi fi
done done
attacks+=("$FLUXIONGeneralExitOption") attacks+=("$FLUXIONGeneralBackOption")
identifiers+=("$FLUXIONGeneralExitOption") identifiers+=("$FLUXIONGeneralBackOption")
descriptions+=("") descriptions+=("")
io_query_format_fields "" "\t$CRed[$CSYel%d$CClr$CRed]$CClr%0.0s $CCyn%b$CClr %b\n" attacks[@] identifiers[@] descriptions[@] io_query_format_fields "" "\t$CRed[$CSYel%d$CClr$CRed]$CClr%0.0s $CCyn%b$CClr %b\n" attacks[@] identifiers[@] descriptions[@]
echo echo
if [ "${IOQueryFormatFields[1]}" = "$FLUXIONGeneralExitOption" ]; then if [ "${IOQueryFormatFields[1]}" = "$FLUXIONGeneralBackOption" ]; then
fluxion_shutdown; exit return -1
fi fi
FluxionAttack=${IOQueryFormatFields[0]} FluxionAttack=${IOQueryFormatFields[0]}
@ -1335,6 +1356,7 @@ function subtest1() {
local interface local interface
interface_list_all interface_list_all
for interface in "${InterfaceListAll[@]}"; do for interface in "${InterfaceListAll[@]}"; do
if [ "$interface" = "lo" ]; then continue; fi
echo "$interface" echo "$interface"
done done
} }
@ -1393,9 +1415,13 @@ function fluxion_main() {
fluxion_startup fluxion_startup
fluxion_set_resolution fluxion_set_resolution
fluxion_set_language
local -r sequence=("set_attack" "prep_attack" "run_attack") local -r sequence=( \
"set_language" \
"set_attack" \
"prep_attack" \
"run_attack" \
)
while true # Fluxion's runtime-loop. while true # Fluxion's runtime-loop.
do fluxion_do_sequence fluxion sequence[@] do fluxion_do_sequence fluxion sequence[@]