Division Zero (Div0). Copyright © 2011-2018

All rights reserved.

Staying Connected to a Broken Wi-Fi AP (Mac OS X)

17 Sep 2015

While this is not strictly a security-related snippet, it might still be interesting curiosity for someone working on that field and having to deal with a hostile or just mad Wi-Fi Access Point (AP) which just keeps on dropping the connection.

 

In this scenario, there are no other more well behaving APs around, and one just want to stay online. Rejoining manually and ignoring the connection failure notifications is one way to go, but as the events occur too frequently, they can become a real bottleneck in the production process.

 

Hence a good solution is for the Mac OS X to build up a small bash script to keep on joining, as soon as the connection drops. Luckily Apple provides a built-in command to connect to a Wi-Fi AP with given SSID and password. Building a loop around that is also trivial.

 

op=1
while [ $op -eq 1 ]; do
echo "joining..."
xop=$( networksetup -setairportnetwork en0 SSID PASSWORD )
# you could check the return value here, but we just ignore
done

 

This would just keep on joining until killed. And what is funny, it actually solves the issue mostly, as the time gap between the connection dropped and re-established is quite small. Of course one would need to take into account the local network policies, as the AP might consider frequent rejoins as a hostile behaviour, depending on the reason of the connection being dropped (for that matter, check the output in xop variable).

 

But, for the curious minds, this is good learning point, and at least reminds about the powerful networksetup command to be used for this and many other manoeuvres.

Tags:

Share on Facebook
Share on Twitter
Please reload

RECENT POST

September 5, 2017

Please reload

CATEGORIES
Please reload

TAGS
RSS
RSS Feed