diff --git a/fluxion.sh b/fluxion.sh index df9627e..bd13a92 100755 --- a/fluxion.sh +++ b/fluxion.sh @@ -3,50 +3,41 @@ ################################ < FLUXION Parameters > ################################ # NOTE: The FLUXIONPath constant will not be populated correctly if the script is called # directly via a symlink. Symlinks in the path to the script should work completely fine. -FLUXIONPath="$( cd "$(dirname "$0")" ; pwd -P )" +declare -r FLUXIONPath="$( cd "$(dirname "$0")" ; pwd -P )" -FLUXIONWorkspacePath="/tmp/fluxspace" -FLUXIONHashPath="$FLUXIONPath/attacks/Handshake Snooper/handshakes" -FLUXIONScanDB="dump" +declare -r FLUXIONWorkspacePath="/tmp/fluxspace" +declare -r FLUXIONHashPath="$FLUXIONPath/attacks/Handshake Snooper/handshakes" +declare -r FLUXIONScanDB="dump" -FLUXIONNoiseFloor=-90 -FLUXIONNoiseCeiling=-60 +declare -r FLUXIONNoiseFloor=-90 +declare -r FLUXIONNoiseCeiling=-60 -FLUXIONVersion=3 -FLUXIONRevision=1 +declare -r FLUXIONVersion=3 +declare -r FLUXIONRevision=1 -FLUXIONDebug=${FLUXIONDebug:+1} -FLUXIONWIKillProcesses=${FLUXIONWIKillProcesses:+1} -FLUXIONWIReloadDriver=${FLUXIONWIReloadDriver:+1} -FLUXIONAuto=${FLUXIONAuto:+1} +declare -r FLUXIONDebug=${FLUXIONDebug:+1} +declare -r FLUXIONWIKillProcesses=${FLUXIONWIKillProcesses:+1} +declare -r FLUXIONWIReloadDriver=${FLUXIONWIReloadDriver:+1} +declare -r FLUXIONAuto=${FLUXIONAuto:+1} # FLUXIONDebug [Normal Mode "" / Developer Mode 1] -export FLUXIONOutputDevice=$([ $FLUXIONDebug ] && echo "/dev/stdout" || echo "/dev/null") +declare -r FLUXIONOutputDevice=$([ $FLUXIONDebug ] && echo "/dev/stdout" || echo "/dev/null") -FLUXIONHoldXterm=$([ $FLUXIONDebug ] && echo "-hold" || echo "") +declare -r FLUXIONHoldXterm=$([ $FLUXIONDebug ] && echo "-hold" || echo "") -################################# < Shell Color Codes > ################################ -CRed="\e[1;31m" -CGrn="\e[1;32m" -CYel="\e[1;33m" -CBlu="\e[1;34m" -CPrp="\e[5;35m" -CCyn="\e[5;36m" -CGry="\e[0;37m" -CWht="\e[1;37m" -CClr="\e[0m" +################################# < Library Includes > ################################# +source lib/installer/InstallerUtils.sh +source lib/InterfaceUtils.sh +source lib/SandboxUtils.sh +source lib/FormatUtils.sh +source lib/ColorUtils.sh +source lib/IOUtils.sh +source lib/HashUtils.sh ################################ < FLUXION Parameters > ################################ FLUXIONPrompt="$CRed[${CBlu}fluxion$CYel@$CClr$HOSTNAME$CRed]-[$CYel~$CRed]$CClr " FLUXIONVLine="$CRed[$CYel*$CRed]$CClr" -################################# < Library Includes > ################################# -source lib/InterfaceUtils.sh -source lib/SandboxUtils.sh -source lib/FormatUtils.sh -source lib/IOUtils.sh -source lib/HashUtils.sh - source language/English.lang ################################ < Library Parameters > ################################ @@ -55,26 +46,36 @@ InterfaceUtilsOutputDevice="$FLUXIONOutputDevice" SandboxWorkspacePath="$FLUXIONWorkspacePath" SandboxOutputDevice="$FLUXIONOutputDevice" +InstallerUtilsWorkspacePath="$FLUXIONWorkspacePath" +InstallerUtilsOutputDevice="$FLUXIONOutputDevice" +InstallerUtilsNoticeMark="$FLUXIONVLine" + +PackageManagerLog="$InstallerUtilsWorkspacePath/package_manager.log" + IOUtilsHeader="fluxion_header" IOUtilsQueryMark="$FLUXIONVLine" IOUtilsPrompt="$FLUXIONPrompt" HashOutputDevice="$FLUXIONOutputDevice" -################################# < User Preferences > ################################# -if [ -x "$FLUXIONPath/preferences.sh" ]; then source "$FLUXIONPath/preferences.sh"; fi - -######################################################################################## -if [[ $EUID -ne 0 ]]; then +################################# < Super User Check > ################################# +if [ $EUID -ne 0 ]; then echo -e "${CRed}You don't have admin privilegies, execute the script as root.$CClr" exit 1 fi -if [ -z "${DISPLAY:-}" ]; then +if [ ! "${DISPLAY:-}" ]; then echo -e "${CRed}The script should be exected inside a X (graphical) session.$CClr" - exit 1 + exit 2 fi +################################# < Default Language > ################################# +source language/English.lang + +################################# < User Preferences > ################################# +if [ -x "$FLUXIONPath/preferences.sh" ]; then source "$FLUXIONPath/preferences.sh"; fi + +######################################################################################## function exitmode() { if [ ! $FLUXIONDebug ]; then fluxion_header @@ -157,36 +158,6 @@ function conditional_bail() { read bullshit } -function check_updates() { - # Attempt to retrieve versioning information from repository script. - local FLUXIONOnlineInfo=("`timeout -s SIGTERM 20 curl "https://raw.githubusercontent.com/FluxionNetwork/fluxion/master/fluxion.sh" 2>/dev/null | egrep "^(FLUXIONVersion|FLUXIONRevision)"`") - - if [ -z "${FLUXIONOnlineInfo[@]}" ]; then - FLUXIONOnlineInfo=("version=?\n" "revision=?\n") - fi - - echo -e "${FLUXIONOnlineInfo[@]}" > "$FLUXIONWorkspacePath/latest_version" -} - -# Animation -function spinner() { - local pid=$1 - local delay=0.15 - local spinstr='|/-\' - - tput civis - while [ "`ps a | awk '{print $1}' | grep $pid`" ]; do - local temp=${spinstr#?} - printf " [%c] " "$spinstr" - local spinstr=$temp${spinstr%"$temp"} - sleep $delay - printf "\b\b\b\b\b\b" - done - - printf " \b\b\b\b" - tput cnorm -} - # ERROR Report only in Developer Mode function error_report() { echo "Error on line $1" @@ -243,22 +214,23 @@ fi ####################################### < Start > ###################################### if [ ! $FLUXIONDebug ]; then FLUXIONBanner=() - format_center_literals " ⌠▓▒▓▒ ⌠▓╗ ⌠█┐ ┌█ ┌▓\ /▓┐ ⌠▓╖ ⌠◙▒▓▒◙ ⌠█\ ☒┐"; FLUXIONBanner[${#FLUXIONBanner[@]}]="$FormatCenterLiterals"; - format_center_literals " ║▒_ │▒║ │▒║ ║▒ \▒\/▒/ │☢╫ │▒┌╤┐▒ ║▓▒\ ▓║"; FLUXIONBanner[${#FLUXIONBanner[@]}]="$FormatCenterLiterals"; - format_center_literals " ≡◙◙ ║◙║ ║◙║ ║◙ ◙◙ ║¤▒ ║▓║☯║▓ ♜◙\✪\◙♜"; FLUXIONBanner[${#FLUXIONBanner[@]}]="$FormatCenterLiterals"; - format_center_literals " ║▒ │▒║__ │▒└_┘▒ /▒/\▒\ │☢╫ │▒└╧┘▒ ║█ \▒█║"; FLUXIONBanner[${#FLUXIONBanner[@]}]="$FormatCenterLiterals"; - format_center_literals " ⌡▓ ⌡◘▒▓▒ ⌡◘▒▓▒◘ └▓/ \▓┘ ⌡▓╝ ⌡◙▒▓▒◙ ⌡▓ \▓┘"; FLUXIONBanner[${#FLUXIONBanner[@]}]="$FormatCenterLiterals"; - format_center_literals "¯¯¯ ¯¯¯¯¯¯ ¯¯¯¯¯¯¯ ¯¯¯ ¯¯¯ ¯¯¯¯ ¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯"; FLUXIONBanner[${#FLUXIONBanner[@]}]="$FormatCenterLiterals"; + + format_center_literals " ⌠▓▒▓▒ ⌠▓╗ ⌠█┐ ┌█ ┌▓\ /▓┐ ⌠▓╖ ⌠◙▒▓▒◙ ⌠█\ ☒┐"; FLUXIONBanner+=("$FormatCenterLiterals"); + format_center_literals " ║▒_ │▒║ │▒║ ║▒ \▒\/▒/ │☢╫ │▒┌╤┐▒ ║▓▒\ ▓║"; FLUXIONBanner+=("$FormatCenterLiterals"); + format_center_literals " ≡◙◙ ║◙║ ║◙║ ║◙ ◙◙ ║¤▒ ║▓║☯║▓ ♜◙\✪\◙♜"; FLUXIONBanner+=("$FormatCenterLiterals"); + format_center_literals " ║▒ │▒║__ │▒└_┘▒ /▒/\▒\ │☢╫ │▒└╧┘▒ ║█ \▒█║"; FLUXIONBanner+=("$FormatCenterLiterals"); + format_center_literals " ⌡▓ ⌡◘▒▓▒ ⌡◘▒▓▒◘ └▓/ \▓┘ ⌡▓╝ ⌡◙▒▓▒◙ ⌡▓ \▓┘"; FLUXIONBanner+=("$FormatCenterLiterals"); + format_center_literals "¯¯¯ ¯¯¯¯¯¯ ¯¯¯¯¯¯¯ ¯¯¯ ¯¯¯ ¯¯¯¯ ¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯"; FLUXIONBanner+=("$FormatCenterLiterals"); clear if [ "$FLUXIONAuto" ] - then echo -e "$CBlu" - else echo -e "$CRed" + then echo -e "$CBlu" + else echo -e "$CRed" fi - for line in "${FLUXIONBanner[@]}"; do - echo "$line"; sleep 0.05 + for line in "${FLUXIONBanner[@]}" + do echo "$line"; sleep 0.05 done #echo "${FLUXIONBanner[@]}" echo @@ -270,84 +242,22 @@ if [ ! $FLUXIONDebug ]; then format_center_literals "${CRed}FLUXION $CWht$FLUXIONVersion (rev. $CGrn$FLUXIONRevision$CWht)$CYel by$CWht ghost"; echo -e "$FormatCenterLiterals" sleep 0.1 - FLUXIONVNotice="Online Version" - FLUXIONVNoticeOffset=$(($(tput cols) / 2 + ((${#FLUXIONVNotice} / 2) - 4))) - printf "%${FLUXIONVNoticeOffset}s" "Online Version" - - check_updates & - spinner "$!" - - if [ -f "$FLUXIONWorkspacePath/latest_version" -a \ - -s "$FLUXIONWorkspacePath/latest_version" ]; then - mapfile FLUXIONOnlineInfo < "$FLUXIONWorkspacePath/latest_version" - FLUXIONOnlineVersion=$(echo "${FLUXIONOnlineInfo[@]}" | awk -F= 'tolower($1)~/version/{print $2}') - FLUXIONOnlineRevision=$(echo "${FLUXIONOnlineInfo[@]}" | awk -F= 'tolower($1)~/revision/{print $2}') - else - FLUXIONOnlineVersion="?" - FLUXIONOnlineRevision="?" + if installer_utils_check_update "https://raw.githubusercontent.com/FluxionNetwork/fluxion/master/fluxion.sh" "FLUXIONVersion=" "FLUXIONRevision=" $FLUXIONVersion $FLUXIONRevision + then installer_utils_run_update "https://github.com/FluxionNetwork/fluxion/archive/master.zip" "FLUXION-V$FLUXIONVersion.$FLUXIONRevision" "`dirname "$FLUXIONPath"`" fi - echo -e "$CClr [$CPrp$FLUXIONOnlineVersion.$FLUXIONOnlineRevision$CClr]" - - if [ ! -z "${FLUXIONOnlineVersion[@]}" -a \ - "$FLUXIONOnlineVersion" != "?" -a \ - "$FLUXIONOnlineRevision" != "?" ]; then - if [ "$FLUXIONOnlineVersion" -gt "$FLUXIONVersion" -o \ - "$FLUXIONOnlineVersion" -eq "$FLUXIONVersion" -a \ - "$FLUXIONOnlineRevision" -gt "$FLUXIONRevision" ]; then - echo - echo - echo -ne $CRed" New revision found! "$CYel - echo -ne "Update? [Y/n]: "$CClr - read -N1 doupdate - echo -ne "$CClr" - doupdate=${doupdate:-"Y"} - if [ "$doupdate" = "Y" ]; then - cp $0 $HOME/flux_rev-$FLUXIONRevision.backup - curl "https://raw.githubusercontent.com/FluxionNetwork/fluxion/master/fluxion" -s -o $0 - echo - echo - echo -e ""$CRed"Updated successfully! Restarting the script to apply the changes ..."$CClr"" - sleep 3 - chmod +x $0 - exec $0 - exit - fi - fi - fi echo - sleep 1 + FLUXIONCLIToolsRequired=("aircrack-ng" "awk:awk|gawk|mawk" "curl" "dhcpd:isc-dhcp-server" "hostapd" "lighttpd" "iwconfig:wireless-tools" "macchanger" "mdk3" "nmap" "openssl" "php-cgi" "pyrit" "xterm" "rfkill" "unzip" "route:net-tools" "fuser:psmisc" "killall:psmisc") + FLUXIONCLIToolsMissing=() + + while ! installer_utils_check_dependencies FLUXIONCLIToolsRequired[@] + do installer_utils_run_dependencies InstallerUtilsCheckDependencies[@] + done fi -################################### < Dependencies > ################################### -function check_dependencies() { - local CLITools=("aircrack-ng" "aireplay-ng" "airmon-ng" "airodump-ng" "airbase-ng" "awk" "curl" "dhcpd" "hostapd" "iwconfig" "lighttpd" "macchanger" "mdk3" "nmap" "php-cgi" "pyrit" "xterm" "openssl" "rfkill" "fuser") - - local CLIToolsMissing - - for CLITool in ${CLITools[*]}; do - # Could use parameter replacement, but requires extra variable. - local toolIdentifier=$(printf "%-44s" "$CLITool" | sed 's/ /./g') - local toolState=$(! hash $CLITool 2>/dev/null && echo "$CRed Missing!$CClr" || echo ".....$CGrn OK.$CClr") - CLIToolsMissing=$([[ "$toolState" = *"Missing"* ]] && echo true) - format_center_literals "$FLUXIONVLine $toolIdentifier$toolState" - echo -e "$FormatCenterLiterals" - done - - if [ "$CLIToolsMissing" ]; then - echo - format_center_literals "${CRed}Stopping due to a lack of dependencies!"; echo -e "$FormatCenterLiterals" - echo - exit 1 - fi - - sleep 1 -} - #################################### < Resolution > #################################### -# Windows + Resolution -function set_resolution() { +function set_resolution() { # Windows + Resolution function resA() { TOPLEFT="-geometry 90x13+0+0" TOPRIGHT="-geometry 83x26-0+0" @@ -1068,7 +978,6 @@ function run_attack() { } ################################### < FLUXION Loop > ################################### -check_dependencies set_resolution set_language diff --git a/lib/ColorUtils.sh b/lib/ColorUtils.sh new file mode 100755 index 0000000..c87df81 --- /dev/null +++ b/lib/ColorUtils.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +SandboxUtilsVersion="1.0" + +################################# < Shell Color Codes > ################################ +readonly CRed="\e[1;31m" +readonly CGrn="\e[1;32m" +readonly CYel="\e[1;33m" +readonly CBlu="\e[1;34m" +readonly CPrp="\e[5;35m" +readonly CCyn="\e[5;36m" +readonly CGry="\e[0;37m" +readonly CWht="\e[1;37m" +readonly CClr="\e[0m" + +# FLUXSCRIPT END diff --git a/lib/installer/InstallerUtils.sh b/lib/installer/InstallerUtils.sh new file mode 100644 index 0000000..ce74ab0 --- /dev/null +++ b/lib/installer/InstallerUtils.sh @@ -0,0 +1,226 @@ +#!/bin/bash + +#if [ "$InstallerUtilsVersion" ]; then return 0; fi +# readonly InstallerUtilsVersion="1.0" + +InstallerUtilsWorkspacePath="/tmp/verspace" + +InstallerUtilsOutputDevice="/dev/stdout" + +InstallerUtilsNoticeMark="*" + +PackageManagerLog="$InstallerUtilsWorkspacePath/package_manager.log" + +function installer_utils_run_spinner() { + local pid=$1 + local delay=0.15 + local spinstr='|/-\' + + tput civis + while [ "`ps a | awk '{print $1}' | grep $pid`" ]; do + local temp=${spinstr#?} + printf " [%c] " "$spinstr" + local spinstr=$temp${spinstr%"$temp"} + sleep $delay + printf "\b\b\b\b\b\b" + done + + printf " \b\b\b\b" + tput cnorm +} + +# Pamaters: +# $1 source - Online Info File (text) +# $2 version regex - Online version (regex) +# $3 revision regex - Online version (regex) +function installer_utils_check_version() { + if [ ${#@} -ne 3 ]; then return 1; fi + + # Attempt to retrieve versioning information from repository script. + local -r __installer_utils_check_version__info=("`timeout -s SIGTERM 20 curl "$1" 2> /dev/null`") + + local -r __installer_utils_check_version__onlineVersion=$(echo "${__installer_utils_check_version__info[@]}" | egrep "$2" | egrep -o "[0-9]+") + local -r __installer_utils_check_version__onlineRevision=$(echo "${__installer_utils_check_version__info[@]}" | egrep "$3" | egrep -o "[0-9]+") + + if [ "$__installer_utils_check_version__onlineVersion" ] && [ "$__installer_utils_check_version__onlineRevision" ] + then echo -e "$__installer_utils_check_version__onlineVersion\n$__installer_utils_check_version__onlineRevision" > "$InstallerUtilsWorkspacePath/latest_version" + fi +} + + +# Pamaters: +# $1 source - Online Info File (text) +# $2 version regex - Online version (regex) +# $3 version local - Local version (number) +# $4 revision regex - Online version (regex) +# $5 revision local - Local version (number) +function installer_utils_check_update() { + # The following set of statements aren't very generic, need to be refactored. + local versionDialog="Online Version" + local versionDialogOffset=$(($(tput cols) / 2 + ((${#versionDialog} / 2) - 4))) + printf "%${versionDialogOffset}s" "$versionDialog" + + installer_utils_check_version "${@:1:3}" & + installer_utils_run_spinner "$!" # This should be done externally (refactored). + + local __installer_utils_check_update__localVersion=$4 + local __installer_utils_check_update__localRevision=$5 + local __installer_utils_check_update__version="?" + local __installer_utils_check_update__revision="?" + + if [ -f "$InstallerUtilsWorkspacePath/latest_version" -a \ + -s "$InstallerUtilsWorkspacePath/latest_version" ]; then + local __installer_utils_check_update__vInfo + mapfile -tn 2 __installer_utils_check_update__vInfo < "$InstallerUtilsWorkspacePath/latest_version" + + sandbox_remove_workfile "$InstallerUtilsWorkspacePath/latest_version" + + __installer_utils_check_update__version=${__installer_utils_check_update__vInfo[0]} + __installer_utils_check_update__revision=${__installer_utils_check_update__vInfo[1]} + fi + + echo -e "$CClr [$__installer_utils_check_update__version.$__installer_utils_check_update__revision$CClr]" + + if [ "$__installer_utils_check_update__version" != "?" -a "$__installer_utils_check_update__revision" != "?" ]; then + if [ "$__installer_utils_check_update__version" -gt "$__installer_utils_check_update__localVersion" -o \ + "$__installer_utils_check_update__version" -eq "$__installer_utils_check_update__localRevision" -a \ + "$__installer_utils_check_update__revision" -gt "$__installer_utils_check_update__localRevision" ]; then + format_center_literals "${CRed}A newer version has been found!$CClr" + return 0 + fi + fi + + return 1 # Failure +} + +# Parameters: $1 - Update source (zip) $2 - Backup file name $3 - Update output +function installer_utils_run_update() { + if [ ${#@} -ne 2 ]; then return 1; fi + + local __installer_utils_run_update__source="$1" + local __installer_utils_run_update__backup="$2" + local __installer_utils_run_update__output="$3" + + format_center_literals "${CYel}[ Press Y or enter to update, anything else to skip ]$CClr" + + tput civis + local __installer_utils_run_update__option + read -N1 __installer_utils_run_update__option + tput cnorm + + __installer_utils_run_update__option=${__installer_utils_run_update__option:-Y} + + # If the user doesn't want to upgrade, stop this procedure. + if [ "$__installer_utils_run_update__option" != "Y" -a \ + "$__installer_utils_run_update__option" != "y" ] + then return 1 + fi + + local __installer_utils_run_update__backupFile="$__installer_utils_run_update__backup-`date +%F_%T`" + local __installer_utils_run_update__backupPath="`dirname $__installer_utils_run_update__output`/$__installer_utils_run_update__backupFile.7z" + + # If a file with the backup name already exists, abort. + if [ -f "$__installer_utils_run_update__backupPath" ] + then return 2 + fi + + format_center_literals "${CClr}[ ~ Creating Backup ~ ]$CClr"; echo + # This could use a progress indicator, but I'm a bit tired. + 7zr a "$__installer_utils_run_update__backupPath" "$__installer_utils_run_update__output" &> $InstallerUtilsOutputDevice + + + format_center_literals "${CClr}[ ~ Downloading Update ~ ]$CClr"; echo + if ! curl -L "$__installer_utils_run_update__source" -o "$InstallerUtilsWorkspacePath/update.zip"; then + format_center_literals "${CRed}[ ~ Download Failed ~ ]$CClr" + sleep 3 + return 3 + fi + + format_center_literals "${CClr}[ ~ Verifying Download ~ ]$CClr"; echo + if ! unzip -t "$InstallerUtilsWorkspacePath/update.zip"; then + format_center_literals "${CRed}[ ~ Download Appears Corrupted ~ ]$CClr" + sleep 3 + return 4 + fi + + format_center_literals "${CClr}[ ~ Extracting Files ~ ]$CClr"; echo + mkdir "$InstallerUtilsWorkspacePath/update_contents" + unzip "$InstallerUtilsWorkspacePath/update.zip" -d "$InstallerUtilsWorkspacePath/update_contents" + + + if [ ! -d "$__installer_utils_run_update__output" ]; then + if ! mkdir -p "$__installer_utils_run_update__output"; then + format_center_literals "${CRed}[ ~ Failed To Create Destination Directory ~ ]$CClr"; echo + fi + fi + + format_center_literals "${CClr}[ ~ Moving Files ~ ]$CClr"; echo + mv "$InstallerUtilsWorkspacePath"/update_contents/* "$__installer_utils_run_update__output" + + format_center_literals "${CGrn}[ ~ Update Completed ~ ]$CClr"; echo + sleep 3 +} + +# Parameters: $1 - CLI Tools required array $2 - CLI Tools missing array (will be populated) +function installer_utils_check_dependencies() { + if [ ! "$1" ]; then return 1; fi + + local __installer_utils_run_dependencies__CLIToolsInfo=("${!1}") + InstallerUtilsCheckDependencies=() + + local __installer_utils_run_dependencies__CLIToolInfo + for __installer_utils_run_dependencies__CLIToolInfo in "${__installer_utils_run_dependencies__CLIToolsInfo[@]}"; do + local __installer_utils_run_dependencies__CLITool=${__installer_utils_run_dependencies__CLIToolInfo/:*/} + local __installer_utils_run_dependencies__identifier="`printf "%-44s" "$__installer_utils_run_dependencies__CLITool"`" + local __installer_utils_run_dependencies__state=".....$CGrn OK.$CClr" + + if ! hash "$__installer_utils_run_dependencies__CLITool" 2>/dev/null; then + __installer_utils_run_dependencies__state="$CRed Missing!$CClr" + InstallerUtilsCheckDependencies+=("$__installer_utils_run_dependencies__CLIToolInfo") + fi + + format_center_literals "$InstallerUtilsNoticeMark ${__installer_utils_run_dependencies__identifier// /.}$__installer_utils_run_dependencies__state" + echo -e "$FormatCenterLiterals" + done + + if [ ${#InstallerUtilsCheckDependencies[@]} -gt 0 ]; then return 2; fi +} + +# Parameters: $1 - CLI Tools missing array (will be installed) $2 - substitutes array +function installer_utils_run_dependencies() { + if [ ! "$1" ]; then return 1; fi + + # The array below holds all the packages that will be installed. + local __installer_utils_run_dependencies__dependenciesInfo=("${!1}") + + local __installer_utils_run_dependencies__managers=(lib/installer/managers/*) + + local __installer_utils_run_dependencies__manager + for __installer_utils_run_dependencies__manager in "${__installer_utils_run_dependencies__managers[@]}"; do + source "$__installer_utils_run_dependencies__manager" + if [ "$PackageManagerCLT" ]; then break; fi + done + + if [ ! "$PackageManagerCLT" ]; then + format_center_literals "${CRed}[ ~ No Suitable Package Manager Found ~ ]$CClr"; echo + sleep 3 + return 2 + fi + + prep_package_manager + + for __installer_utils_run_dependencies__dependencyInfo in "${__installer_utils_run_dependencies__dependenciesInfo[@]}"; do + local __installer_utils_run_dependencies__target=${__installer_utils_run_dependencies__dependencyInfo/:*/} + local __installer_utils_run_dependencies__packages=${__installer_utils_run_dependencies__dependencyInfo/*:/} + for __installer_utils_run_dependencies__package in ${__installer_utils_run_dependencies__packages//|/ }; do + clear + if $PackageManagerCLT $PackageManagerCLTInstallOptions $__installer_utils_run_dependencies__package + then break + fi + done + done + + unprep_package_manager +} + +# FLUXSCRIPT END diff --git a/lib/installer/managers/apt.sh b/lib/installer/managers/apt.sh new file mode 100644 index 0000000..bddd297 --- /dev/null +++ b/lib/installer/managers/apt.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +if [ -f "/etc/debian_version" ]; then + PackageManagerCLT="apt" + PackageManagerCLTInstallOptions="install -y" + PackageManagerCLTRemoveOptions="remove -y" + + PackageManagerOutputDevice="/dev/stdout" + + PackageManagerLog="/tmp/lib_package_manager.log" + + function unprep_package_manager() { + echo "`cat /etc/apt/sources.list | grep -v 'deb http://http.kali.org/kali kali-rolling main non-free contrib # Installed By FLUXION'`" > /etc/apt/sources.list + } + + function prep_package_manager() { + if [ ! "`cat /etc/apt/sources.list | egrep 'deb http://http.kali.org/kali ((kali-rolling|main|contrib|non-free) )*'`" ]; then + echo "Doesn't have kali..." + gpg --keyserver hkp://keys.gnupg.net --recv-key 7D8D0BF6 + apt-key adv --keyserver pgp.mit.edu --recv-keys ED444FF07D8D0BF6 + echo "deb http://http.kali.org/kali kali-rolling main non-free contrib # Installed By FLUXION" >> /etc/apt/sources.list + fi + + # Cleanup package manager + sudo apt-get install -f -y | tee -a $PackageManagerLog + sudo apt-get autoremove -y | tee -a $PackageManagerLog + sudo apt-get autoclean -y | tee -a $PackageManagerLog + sudo apt-get clean -y | tee -a $PackageManagerLog + sudo apt-get update | tee -a $PackageManagerLog + } +fi + +# FLUXSCRIPT END diff --git a/lib/installer/managers/emerge.sh b/lib/installer/managers/emerge.sh new file mode 100644 index 0000000..22ada1b --- /dev/null +++ b/lib/installer/managers/emerge.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +if [ -f "/etc/gentoo-release" ]; then + PackageManagerCLT="emerge" + PackageManagerCLTInstallOptions="-s" + PackageManagerCLTRemoveOptions="" + + PackageManagerOutputDevice="/dev/stdout" + + PackageManagerLog="/tmp/lib_package_manager.log" + + function unprep_package_manager() { + echo "Nothing to unprepare." > $PackageManagerOutputDevice + } + + function prep_package_manager() { + echo "Nothing to prepare." > $PackageManagerOutputDevice + } +fi + +# FLUXSCRIPT END diff --git a/lib/installer/managers/pacman.sh b/lib/installer/managers/pacman.sh new file mode 100644 index 0000000..ea176e3 --- /dev/null +++ b/lib/installer/managers/pacman.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +if [ -f "/etc/arch-release" ]; then + PackageManagerCLT="pacman" + PackageManagerCLTInstallOptions="-S -y" + PackageManagerCLTRemoveOptions="-Rs" + + PackageManagerOutputDevice="/dev/stdout" + + PackageManagerLog="/tmp/lib_package_manager.log" + + function unprep_package_manager() { + echo "Nothing to unprepare." > $PackageManagerOutputDevice + } + + function prep_package_manager() { + echo "Nothing to prepare." > $PackageManagerOutputDevice + } +fi + +# FLUXSCRIPT END diff --git a/lib/installer/managers/yum.sh b/lib/installer/managers/yum.sh new file mode 100644 index 0000000..2343611 --- /dev/null +++ b/lib/installer/managers/yum.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +if [ -f "/etc/redhat-release" ]; then + PackageManagerCLT="yum" + PackageManagerCLTInstallOptions="-y install" + PackageManagerCLTRemoveOptions="remove" + + PackageManagerOutputDevice="/dev/stdout" + + PackageManagerLog="/tmp/lib_package_manager.log" + + function unprep_package_manager() { + echo "Nothing to unprepare." > $PackageManagerOutputDevice + } + + function prep_package_manager() { + echo "Nothing to prepare." > $PackageManagerOutputDevice + } +fi + +# FLUXSCRIPT END diff --git a/lib/installer/managers/zypp.sh b/lib/installer/managers/zypp.sh new file mode 100644 index 0000000..25f9db2 --- /dev/null +++ b/lib/installer/managers/zypp.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +if [ -f "/etc/SuSE-release" ]; then + PackageManagerCLT="zypp" + PackageManagerCLTInstallOptions="install" + PackageManagerCLTRemoveOptions="remove" + + PackageManagerOutputDevice="/dev/stdout" + + PackageManagerLog="/tmp/lib_package_manager.log" + + function unprep_package_manager() { + echo "Nothing to unprepare." > $PackageManagerOutputDevice + } + + function prep_package_manager() { + echo "Nothing to prepare." > $PackageManagerOutputDevice + } +fi + +# FLUXSCRIPT END