Added support for symbolic linking.

This commit is contained in:
Matias Barcenas 2018-05-24 18:44:53 -05:00
parent e4f074b953
commit 0bf7a399a0
2 changed files with 29 additions and 26 deletions

View File

@ -3,12 +3,11 @@
# ============================================================ # # ============================================================ #
# ================== < FLUXION Parameters > ================== # # ================== < FLUXION Parameters > ================== #
# ============================================================ # # ============================================================ #
# Warning: The FLUXIONPath constant will be incorrectly set when
# called directly via a system link. System links in the path to
# the script, however, will be loaded correctly.
# Path to directory containing the FLUXION executable script. # Path to directory containing the FLUXION executable script.
readonly FLUXIONPath=$(cd "$(dirname "$0")"; pwd -P) readonly FLUXIONPath=$(dirname $(readlink -f "$0"))
# Path to directory containing the FLUXION library (scripts).
readonly FLUXIONLibPath="$FLUXIONPath/lib"
# Path to the temp. directory available to FLUXION & subscripts. # Path to the temp. directory available to FLUXION & subscripts.
readonly FLUXIONWorkspacePath="/tmp/fluxspace" readonly FLUXIONWorkspacePath="/tmp/fluxspace"
@ -66,14 +65,14 @@ fi
# ============================================================ # # ============================================================ #
# =================== < Library Includes > =================== # # =================== < Library Includes > =================== #
# ============================================================ # # ============================================================ #
source lib/installer/InstallerUtils.sh source "$FLUXIONPath/lib/installer/InstallerUtils.sh"
source lib/InterfaceUtils.sh source "$FLUXIONPath/lib/InterfaceUtils.sh"
source lib/SandboxUtils.sh source "$FLUXIONPath/lib/SandboxUtils.sh"
source lib/FormatUtils.sh source "$FLUXIONPath/lib/FormatUtils.sh"
source lib/ColorUtils.sh source "$FLUXIONPath/lib/ColorUtils.sh"
source lib/IOUtils.sh source "$FLUXIONPath/lib/IOUtils.sh"
source lib/HashUtils.sh source "$FLUXIONPath/lib/HashUtils.sh"
source lib/Help.sh source "$FLUXIONPath/lib/Help.sh"
# NOTE: These are configured after arguments are loaded (later). # NOTE: These are configured after arguments are loaded (later).
@ -1691,11 +1690,11 @@ fluxion_set_attack() {
fluxion_target_show fluxion_target_show
local attacks local attacks
readarray -t attacks < <(ls -1 attacks) readarray -t attacks < <(ls -1 "$FLUXIONPath/attacks")
local descriptions local descriptions
readarray -t descriptions < <( readarray -t descriptions < <(
head -n 3 attacks/*/language/$FluxionLanguage.sh | \ head -n 3 "$FLUXIONPath/attacks/"*"/language/$FluxionLanguage.sh" | \
grep -E "^# description: " | sed -E 's/# \w+: //' grep -E "^# description: " | sed -E 's/# \w+: //'
) )
@ -1704,7 +1703,7 @@ fluxion_set_attack() {
local attack local attack
for attack in "${attacks[@]}"; do for attack in "${attacks[@]}"; do
local identifier=$( local identifier=$(
head -n 3 "attacks/$attack/language/$FluxionLanguage.sh" | \ head -n 3 "$FLUXIONPath/attacks/$attack/language/$FluxionLanguage.sh" | \
grep -E "^# identifier: " | sed -E 's/# \w+: //' grep -E "^# identifier: " | sed -E 's/# \w+: //'
) )
if [ "$identifier" ]; then if [ "$identifier" ]; then

View File

@ -3,13 +3,17 @@
if [ "$IOUtilsVersion" ]; then return 0; fi if [ "$IOUtilsVersion" ]; then return 0; fi
readonly IOUtilsVersion="1.0" readonly IOUtilsVersion="1.0"
if [ ! "$FLUXIONLibPath" ]; then return 1; fi
IOUtilsHeader="[x] ================================ [x]" IOUtilsHeader="[x] ================================ [x]"
IOUtilsQueryMark="[-] " IOUtilsQueryMark="[-] "
IOUtilsPrompt="[$USER@$HOSTNAME]> " IOUtilsPrompt="[$USER@$HOSTNAME]> "
if [ ! "$ArrayUtilsVersion" ]; then source lib/ArrayUtils.sh; fi if [ ! "$ArrayUtilsVersion" ]; then
source "$FLUXIONLibPath/ArrayUtils.sh"
fi
function io_input_choice() { io_input_choice() {
local __io_input_choice__choice local __io_input_choice__choice
until [ ! -z "$__io_input_choice__choice" ]; do until [ ! -z "$__io_input_choice__choice" ]; do
echo -ne "$IOUtilsPrompt" echo -ne "$IOUtilsPrompt"
@ -30,24 +34,24 @@ function io_input_choice() {
IOInputChoice=$__io_input_choice__choice IOInputChoice=$__io_input_choice__choice
} }
function io_dynamic_output() { io_dynamic_output() {
eval 'echo -ne "'${@}'"' eval 'echo -ne "'${@}'"'
} }
function io_input_enumerated_choice() { io_input_enumerated_choice() {
local __io_input_enumerated_choice__choices=("${!1}") local __io_input_enumerated_choice__choices=("${!1}")
local __io_input_enumerated_choice__indexes=($(seq ${#__io_input_numeric_choice__choices[@]})) local __io_input_enumerated_choice__indexes=($(seq ${#__io_input_numeric_choice__choices[@]}))
io_input_choice __io_input_enumerated_choice__indexes[@] io_input_choice __io_input_enumerated_choice__indexes[@]
IOInputEnumeratedChoice=${__io_input_enumerated_choice__choices[$IOInputChoice]} IOInputEnumeratedChoice=${__io_input_enumerated_choice__choices[$IOInputChoice]}
} }
# This function outputs formatted lines of fields. # This outputs formatted lines of fields.
# The function takes an output file (like stdout), # The takes an output file (like stdout),
# a "printf format string," and a variable number # a "printf format string," and a variable number
# of indirect-expansion passed arrays (reference). # of indirect-expansion passed arrays (reference).
# NOTICE: At least the first array must be passed! # NOTICE: At least the first array must be passed!
# Example: /dev/stdout "%s is %s." name[@] mood[@] # Example: /dev/stdout "%s is %s." name[@] mood[@]
function io_output_format_fields() { io_output_format_fields() {
# Determine the amount of arguments passed. # Determine the amount of arguments passed.
local __io_output_format_fields__argument_count=${#@} local __io_output_format_fields__argument_count=${#@}
@ -70,7 +74,7 @@ function io_output_format_fields() {
done done
} }
function io_query_format_fields() { io_query_format_fields() {
# Assure we've got required parameters. # Assure we've got required parameters.
if [ ${#@} -lt 2 ]; then if [ ${#@} -lt 2 ]; then
return 1 return 1
@ -111,7 +115,7 @@ function io_query_format_fields() {
done done
} }
function io_query_choice() { io_query_choice() {
# Assure we've got required parameters. # Assure we've got required parameters.
if [ ${#@} -lt 2 ]; then if [ ${#@} -lt 2 ]; then
return 1 return 1
@ -123,7 +127,7 @@ function io_query_choice() {
IOQueryChoice="${IOQueryFormatFields[0]}" IOQueryChoice="${IOQueryFormatFields[0]}"
} }
function io_query_file() { io_query_file() {
if [ ${#@} -lt 2 ]; then if [ ${#@} -lt 2 ]; then
return 1 return 1
fi fi