From f4ad6b85315e9e5e10dcaf835da70b645775f962 Mon Sep 17 00:00:00 2001 From: Matias Barcenas Date: Fri, 11 Aug 2017 03:29:47 -0500 Subject: [PATCH] Routing restoration relocation & language auto fix. Moved the routes restoring code & forwarding to the proper unset function. Refactored some code in set_lang. that should only happen when auto is off. --- attacks/Captive Portal/attack.sh | 25 ++++++++++++++++++++ fluxion.sh | 40 +++++++++++++++----------------- 2 files changed, 44 insertions(+), 21 deletions(-) diff --git a/attacks/Captive Portal/attack.sh b/attacks/Captive Portal/attack.sh index af6a33b..ef9349f 100644 --- a/attacks/Captive Portal/attack.sh +++ b/attacks/Captive Portal/attack.sh @@ -753,6 +753,24 @@ function captive_portal_generic() { " > "$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 + + # 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 +} + # Set up DHCP / WEB server # Set up DHCP / WEB server function captive_portal_set_routes() { @@ -762,9 +780,14 @@ function captive_portal_set_routes() { # Add a route to the virtual gateway interface. route add -net $VIGWNetwork.0 netmask 255.255.255.0 gw $VIGWAddress + # 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 + iptables-save > "$FLUXIONWorkspacePath/iptables-rules" + iptables --flush iptables --table nat --flush iptables --delete-chain @@ -836,6 +859,8 @@ function stop_attack() { kill $FLUXIONDHCP &> $FLUXIONOutputDevice fi + captive_portal_unset_routes + ap_stop } diff --git a/fluxion.sh b/fluxion.sh index faa7ae0..1aa66a2 100755 --- a/fluxion.sh +++ b/fluxion.sh @@ -99,20 +99,20 @@ function exitmode() { airmon-ng stop $WIMonitor &> $FLUXIONOutputDevice fi - if [ "`cat /proc/sys/net/ipv4/ip_forward`" != "0" ]; then - echo -e "$CWht[$CRed-$CWht] $FLUXIONDisablingPacketForwardingNotice$CClr" - sysctl -w net.ipv4.ip_forward=0 &> $FLUXIONOutputDevice - fi + #if [ "`cat /proc/sys/net/ipv4/ip_forward`" != "0" ]; then + # echo -e "$CWht[$CRed-$CWht] $FLUXIONDisablingPacketForwardingNotice$CClr" + # sysctl -w net.ipv4.ip_forward=0 &> $FLUXIONOutputDevice + #fi - echo -e "$CWht[$CRed-$CWht] $FLUXIONDisablingCleaningIPTablesNotice$CClr" - if [ ! -f "$FLUXIONWorkspacePath/iptables-rules" ];then - iptables --flush - iptables --table nat --flush - iptables --delete-chain - iptables --table nat --delete-chain - else - iptables-restore < "$FLUXIONWorkspacePath/iptables-rules" - fi + #echo -e "$CWht[$CRed-$CWht] $FLUXIONDisablingCleaningIPTablesNotice$CClr" + #if [ ! -f "$FLUXIONWorkspacePath/iptables-rules" ];then + # iptables --flush + # iptables --table nat --flush + # iptables --delete-chain + # iptables --table nat --delete-chain + #else + # iptables-restore < "$FLUXIONWorkspacePath/iptables-rules" + #fi echo -e "$CWht[$CRed-$CWht] $FLUXIONRestoringTputNotice$CClr" tput cnorm @@ -413,19 +413,17 @@ function set_resolution() { } function set_language() { - iptables-save > "$FLUXIONWorkspacePath/iptables-rules" - - local languages=(language/*.lang) - languages=(${languages[@]/language\//}) - languages=(${languages[@]/.lang/}) - if [ ! $FLUXIONAuto ]; then + local languages=(language/*.lang) + languages=(${languages[@]/language\//}) + languages=(${languages[@]/.lang/}) + io_query_choice "Select your language" languages[@] source "$FLUXIONPath/language/$IOQueryChoice.lang" - fi - echo + echo + fi }