Fixed interface initialization & tweaked defaults.

Fixed a bug caused by a failure to initialize interfaces after selection.
Tweaked some default values, when using auto-mode.
This commit is contained in:
Matias Barcenas 2018-01-19 15:53:46 -06:00
parent 890c7199df
commit 915fddccd4
2 changed files with 96 additions and 57 deletions

View File

@ -38,15 +38,27 @@ captive_portal_unset_jammer_interface() {
captive_portal_set_jammer_interface() { captive_portal_set_jammer_interface() {
if [ "$CaptivePortalJammerInterface" ]; then return 0; fi if [ "$CaptivePortalJammerInterface" ]; then return 0; fi
echo "Running get jammer interface." > $FLUXIONOutputDevice
if ! fluxion_get_interface attack_targetting_interfaces \ if [ ! "$CaptivePortalUninitializedJammerInterface" ]; then
"$CaptivePortalJammerInterfaceQuery"; then echo "Running get jammer interface." > $FLUXIONOutputDevice
echo "Failed to get jammer interface" > $FLUXIONOutputDevice if ! fluxion_get_interface attack_targetting_interfaces \
return 1 "$CaptivePortalJammerInterfaceQuery"; then
echo "Failed to get jammer interface" > $FLUXIONOutputDevice
return 1
fi
local selectedInterface=$FluxionInterfaceSelected
else
local selectedInterface=$CaptivePortalUninitializedJammerInterface
unset CaptivePortalUninitializedJammerInterface
fi
if ! fluxion_allocate_interface $selectedInterface; then
echo "Failed to allocate jammer interface" > $FLUXIONOutputDevice
return 2
fi fi
echo "Succeeded get jammer interface." > $FLUXIONOutputDevice echo "Succeeded get jammer interface." > $FLUXIONOutputDevice
CaptivePortalJammerInterface=${FluxionInterfaces[$FluxionInterfaceSelected]} CaptivePortalJammerInterface=${FluxionInterfaces[$selectedInterface]}
} }
captive_portal_ap_interfaces() { captive_portal_ap_interfaces() {
@ -59,33 +71,44 @@ captive_portal_ap_interfaces() {
} }
captive_portal_unset_ap_interface() { captive_portal_unset_ap_interface() {
if [ ! "$CaptivePortalAPInterface" ]; then return 1; fi if [ ! "$CaptivePortalAccessPointInterface" ]; then return 1; fi
if [ "$CaptivePortalAPInterface" = \ if [ "$CaptivePortalAccessPointInterface" = \
"${CaptivePortalJammerInterface}v" ]; then "${CaptivePortalJammerInterface}v" ]; then
if ! iw dev $CaptivePortalAPInterface del \ if ! iw dev $CaptivePortalAccessPointInterface del \
&> $FLUXIONOutputDevice; then &> $FLUXIONOutputDevice; then
fluxion_conditional_bail "Unable to remove virtual interface!" fluxion_conditional_bail "Unable to remove virtual interface!"
exit 1 exit 1
fi fi
fi fi
CaptivePortalAPInterface="" CaptivePortalAccessPointInterface=""
} }
captive_portal_set_ap_interface() { captive_portal_set_ap_interface() {
if [ "$CaptivePortalAPInterface" ]; then return 0; fi if [ "$CaptivePortalAccessPointInterface" ]; then return 0; fi
echo "Running get ap interface." > $FLUXIONOutputDevice if [ ! "$CaptivePortalUninitializedAccessPointInterface" ]; then
if ! fluxion_get_interface captive_portal_ap_interfaces \ echo "Running get ap interface." > $FLUXIONOutputDevice
"$CaptivePortalAPInterfaceQuery"; then if ! fluxion_get_interface captive_portal_ap_interfaces \
echo "Failed to get ap interface" > $FLUXIONOutputDevice "$CaptivePortalAccessPointInterfaceQuery"; then
return 1 echo "Failed to get ap interface" > $FLUXIONOutputDevice
return 1
fi
local selectedInterface=$FluxionInterfaceSelected
else
local selectedInterface=$CaptivePortalUninitializedAccessPointInterface
unset CaptivePortalUninitializedAccessPointInterface
fi
if ! fluxion_allocate_interface $selectedInterface; then
echo "Failed to allocate ap interface" > $FLUXIONOutputDevice
return 2
fi fi
echo "Succeeded get ap interface." > $FLUXIONOutputDevice echo "Succeeded get ap interface." > $FLUXIONOutputDevice
CaptivePortalAPInterface=${FluxionInterfaces[$FluxionInterfaceSelected]} CaptivePortalAccessPointInterface=${FluxionInterfaces[$selectedInterface]}
# If interfaces are the same, we need an independent virtual interface. # If interfaces are the same, we need an independent virtual interface.
if [ "$CaptivePortalAPInterface" = \ if [ "$CaptivePortalAccessPointInterface" = \
"$CaptivePortalJammerInterface" ]; then "$CaptivePortalJammerInterface" ]; then
# TODO: Make fluxion's interface services manage virtual interfaces. # TODO: Make fluxion's interface services manage virtual interfaces.
# Have fluxion_get_interface return a virutal interface if the primary # Have fluxion_get_interface return a virutal interface if the primary
@ -99,7 +122,7 @@ captive_portal_set_ap_interface() {
return 2 return 2
fi fi
echo "Virtual interface created successfully." > $FLUXIONOutputDevice echo "Virtual interface created successfully." > $FLUXIONOutputDevice
CaptivePortalAPInterface=${CaptivePortalJammerInterface}v CaptivePortalAccessPointInterface=${CaptivePortalJammerInterface}v
fi fi
} }
@ -111,14 +134,14 @@ function captive_portal_unset_ap_service() {
# Since we're auto-selecting when on auto, trigger undo-chain. # Since we're auto-selecting when on auto, trigger undo-chain.
if [ "$FLUXIONAuto" ]; then return 2; fi if [ "$FLUXIONAuto" ]; then return 2; fi
if ! interface_is_wireless "$CaptivePortalAPInterface"; then if ! interface_is_wireless "$CaptivePortalAccessPointInterface"; then
return 3; return 3;
fi fi
} }
function captive_portal_set_ap_service() { function captive_portal_set_ap_service() {
if [ "$CaptivePortalAPService" ]; then return 0; fi if [ "$CaptivePortalAPService" ]; then return 0; fi
if ! interface_is_wireless "$CaptivePortalAPInterface"; then if ! interface_is_wireless "$CaptivePortalAccessPointInterface"; then
return 0; return 0;
fi fi
@ -264,6 +287,9 @@ captive_portal_run_certificate_generator() {
captive_portal_unset_certificate() { captive_portal_unset_certificate() {
if [ ! "$CaptivePortalSSL" ]; then return 1; fi if [ ! "$CaptivePortalSSL" ]; then return 1; fi
# WARNING: The server configuration depends on whether the certificate
# file exists and is positioned in the proper location. The check above
# could unsynchronize with the certificate file if we're not careful!
sandbox_remove_workfile "$FLUXIONWorkspacePath/server.pem" sandbox_remove_workfile "$FLUXIONWorkspacePath/server.pem"
CaptivePortalSSL="" CaptivePortalSSL=""
@ -290,7 +316,7 @@ captive_portal_set_certificate() {
cp "$FLUXIONPath/attacks/Captive Portal/certificate/server.pem" \ cp "$FLUXIONPath/attacks/Captive Portal/certificate/server.pem" \
"$FLUXIONWorkspacePath/server.pem" "$FLUXIONWorkspacePath/server.pem"
CaptivePortalSSL="enabled" # Must be enabled if sourcing own certificate CaptivePortalSSL="enabled" # Enabled if sourcing user certificate
echo "Captive Portal certificate was user supplied, skipping query!" \ echo "Captive Portal certificate was user supplied, skipping query!" \
> $FLUXIONOutputDevice > $FLUXIONOutputDevice
@ -298,12 +324,7 @@ captive_portal_set_certificate() {
fi fi
if [ "$FLUXIONAuto" ]; then if [ "$FLUXIONAuto" ]; then
# If cert generator fails, gtfo, something broke! CaptivePortalSSL="disabled"
if ! captive_portal_run_certificate_generator; then
fluxion_conditional_bail "cert-gen failed!"
return 2
fi
CaptivePortalSSL="enabled"
else else
local choices=( local choices=(
"$CaptivePortalCertificateSourceGenerateOption" "$CaptivePortalCertificateSourceGenerateOption"
@ -349,6 +370,9 @@ captive_portal_set_certificate() {
captive_portal_unset_connectivity() { captive_portal_unset_connectivity() {
if [ ! "$CaptivePortalConnectivity" ]; then return 1; fi if [ ! "$CaptivePortalConnectivity" ]; then return 1; fi
CaptivePortalConnectivity="" CaptivePortalConnectivity=""
# Since we're auto-selecting when on auto, trigger undo-chain.
if [ "$FLUXIONAuto" ]; then return 2; fi
} }
captive_portal_set_connectivity() { captive_portal_set_connectivity() {
@ -356,26 +380,30 @@ captive_portal_set_connectivity() {
captive_portal_unset_connectivity captive_portal_unset_connectivity
local choices=( if [ "$FLUXIONAuto" ]; then
"$CaptivePortalConnectivityDisconnectedOption" CaptivePortalConnectivity="disconnected"
"$CaptivePortalConnectivityEmulatedOption" else
"$FLUXIONGeneralBackOption" local choices=(
) "$CaptivePortalConnectivityDisconnectedOption"
io_query_choice "$CaptivePortalConnectivityQuery" choices[@] "$CaptivePortalConnectivityEmulatedOption"
"$FLUXIONGeneralBackOption"
)
io_query_choice "$CaptivePortalConnectivityQuery" choices[@]
case "$IOQueryChoice" in case "$IOQueryChoice" in
"$CaptivePortalConnectivityDisconnectedOption") "$CaptivePortalConnectivityDisconnectedOption")
CaptivePortalConnectivity="disconnected" ;; CaptivePortalConnectivity="disconnected" ;;
"$CaptivePortalConnectivityEmulatedOption") "$CaptivePortalConnectivityEmulatedOption")
CaptivePortalConnectivity="emulated" ;; CaptivePortalConnectivity="emulated" ;;
"$FLUXIONGeneralBackOption") "$FLUXIONGeneralBackOption")
return 1 return 1
;; ;;
*) *)
fluxion_conditional_bail "Unknown connectivity option!" fluxion_conditional_bail "Unknown connectivity option!"
return 2 return 2
;; ;;
esac esac
fi
} }
captive_portal_unset_user_interface() { captive_portal_unset_user_interface() {
@ -543,7 +571,7 @@ captive_portal_set_attack() {
# AP Service: Prepare service for an attack. # AP Service: Prepare service for an attack.
if [ "$CaptivePortalAPService" ]; then if [ "$CaptivePortalAPService" ]; then
ap_service_prep \ ap_service_prep \
"$CaptivePortalAPInterface" \ "$CaptivePortalAccessPointInterface" \
"$CaptivePortalGatewayAddress" \ "$CaptivePortalGatewayAddress" \
"$FluxionTargetSSID" \ "$FluxionTargetSSID" \
"$FluxionTargetRogueMAC" \ "$FluxionTargetRogueMAC" \
@ -1144,9 +1172,9 @@ fi
while [ "$1" != "" -a "$1" != "--" ]; do while [ "$1" != "" -a "$1" != "--" ]; do
case "$1" in case "$1" in
-a|--ap) -a|--ap)
CaptivePortalAccessPointInterface=$2; shift;; CaptivePortalUninitializedAccessPointInterface=$2; shift;;
-j|--jammer) -j|--jammer)
CaptivePortalJammerInterface=$2; shift;; CaptivePortalUninitializedJammerInterface=$2; shift;;
-s|--ssl) -s|--ssl)
CaptivePortalSSLCertificatePath=$2; shift;; CaptivePortalSSLCertificatePath=$2; shift;;
-c|--connectivity) -c|--connectivity)

View File

@ -237,15 +237,26 @@ handshake_snooper_set_jammer_interface() {
if [ "$HANDSHAKEDeauthenticatorIdentifier" = \ if [ "$HANDSHAKEDeauthenticatorIdentifier" = \
"$HandshakeSnooperMonitorMethodOption" ]; then return 0; fi "$HandshakeSnooperMonitorMethodOption" ]; then return 0; fi
echo "Running get jammer interface." > $FLUXIONOutputDevice if [ ! "$HandshakeSnooperUninitializedJammerInterface" ]; then
if ! fluxion_get_interface attack_targetting_interfaces \ echo "Running get jammer interface." > $FLUXIONOutputDevice
"$HandshakeSnooperJammerInterfaceQuery"; then if ! fluxion_get_interface attack_targetting_interfaces \
echo "Failed to get jammer interface" > $FLUXIONOutputDevice "$HandshakeSnooperJammerInterfaceQuery"; then
return 1 echo "Failed to get jammer interface" > $FLUXIONOutputDevice
return 1
fi
local selectedInterface=$FluxionInterfaceSelected
else
local selectedInterface=$HandshakeSnooperUninitializedJammerInterface
unset HandshakeSnooperUninitializedJammerInterface
fi
if ! fluxion_allocate_interface $selectedInterface; then
echo "Failed to allocate jammer interface" > $FLUXIONOutputDevice
return 2
fi fi
echo "Succeeded get jammer interface." > $FLUXIONOutputDevice echo "Succeeded get jammer interface." > $FLUXIONOutputDevice
HandshakeSnooperJammerInterface=${FluxionInterfaces[$FluxionInterfaceSelected]} HandshakeSnooperJammerInterface=${FluxionInterfaces[$selectedInterface]}
} }
handshake_snooper_unset_verifier_identifier() { handshake_snooper_unset_verifier_identifier() {
@ -367,7 +378,7 @@ while [ "$1" != "" -a "$1" != "--" ]; do
-i|--interval) -i|--interval)
HandshakeSnooperVerifierInterval=$2; shift;; HandshakeSnooperVerifierInterval=$2; shift;;
-j|--jammer) -j|--jammer)
HandshakeSnooperJammerInterface=$2; shift;; HandshakeSnooperUninitializedJammerInterface=$2; shift;;
-a|--asynchronous) -a|--asynchronous)
HandshakeSnooperVerifierSynchronicity="non-blocking";; HandshakeSnooperVerifierSynchronicity="non-blocking";;
esac esac