├── .github └── FUNDING.yml ├── LICENSE ├── README.md └── osx_wificleaner.py /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | patreon: mubix 2 | liberapay: mubix 3 | custom: ['https://paypal.me/mubix'] 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2020, Rob Fuller 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # osx-wificleaner 2 | Cleans out "open" wireless connections from OSX machines 3 | 4 | - Inspired by: https://isc.sans.edu/forums/diary/Investigating+OffPremise+Wireless+Behaviour+or+I+Know+What+You+Connected+To/22089/ 5 | - For a Windows / Powershell script you can find `Get-OpenWifiNetworks.ps1` here: https://github.com/secopsconsult/powershell 6 | 7 | Example run: 8 | ``` 9 | wpad:osx-wificleaner mubix$ sudo ./osx_wificleaner.py 10 | Password: 11 | ====== List of preferred networks ====== 12 | [-] Saved Network hhonors - Encryption: Open 13 | [-] Saved Network MyHomeWif - Encryption: WPA/WPA2 Personal 14 | [-] Saved Network UnitedWifi - Encryption: Open 15 | [-] Saved Network GuestNetwork - Encryption: Open 16 | [-] Saved Network gogoinflight - Encryption: Open 17 | [-] Saved Network PhoneHotspot - Encryption: WPA2 Personal 18 | [-] Saved Network WorkWifi - Encryption: WPA2 Personal 19 | [-] Saved Network iPadHotSpot - Encryption: WPA2 Personal 20 | [-] Saved Network FreePublicWifi - Encryption: Open 21 | [-] Saved Network Ruxcon - Encryption: WPA2 Personal 22 | 23 | ====== Removing 'Open' networks from list ====== 24 | ++++++++++++++++++++++++++++++++++++++++++++++++ 25 | [+] Removing hhonors 26 | Removed hhonors from the preferred networks list 27 | [+] Removing UnitedWifi 28 | Removed UnitedWifi from the preferred networks list 29 | [+] Removing GuestNetwork 30 | Removed GuestNetwork from the preferred networks list 31 | [+] Removing gogoinflight 32 | Removed gogoinflight from the preferred networks list 33 | [+] Removing FreePublicWifi 34 | Removed FreePublicWifi from the preferred networks list 35 | wpad:osx-wificleaner mubix$ 36 | ``` 37 | -------------------------------------------------------------------------------- /osx_wificleaner.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import os 4 | import plistlib 5 | import re 6 | import subprocess 7 | import sys 8 | 9 | if os.geteuid() != 0: 10 | os.execvp("sudo", ["sudo"] + sys.argv) 11 | 12 | interfacelist = subprocess.Popen(["/usr/sbin/networksetup","-listallhardwareports"], stdout=subprocess.PIPE).communicate()[0] 13 | try: 14 | interface = re.search('Wi-Fi\nDevice:\ (.+?)\n', interfacelist.decode()).group(1) 15 | except Exception as e: 16 | print( "Can't find wireless device, exiting...") 17 | print(str(e)) 18 | quit() 19 | 20 | try: 21 | networklist = plistlib.readPlist('/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist')["KnownNetworks"] 22 | except: 23 | print( "PList for Network is missing or no networks saved") 24 | quit() 25 | 26 | opennetworks = [] 27 | 28 | print( "====== List of preferred networks ======") 29 | 30 | for wifilist in networklist: 31 | wifi = networklist["{0}".format(wifilist)] 32 | print( "[-] Saved Network {0} - Encryption: {1}".format(wifi["SSID"].data, wifi["SecurityType"])) 33 | if (wifi["SecurityType"] == "Open"): 34 | opennetworks.append(wifi["SSID"].data) 35 | 36 | print( "\n") 37 | print( "====== Removing 'Open' networks from list ======") 38 | print( "++++++++++++++++++++++++++++++++++++++++++++++++") 39 | 40 | for network in opennetworks: 41 | print( "[+] Removing {0}".format(network)) 42 | subprocess.call(["/usr/sbin/networksetup", "-removepreferredwirelessnetwork", interface, network]) 43 | --------------------------------------------------------------------------------