Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###########################################################
- -->> ABOUT
- ###########################################################
- (*
- Phil Stokes -- 2017
- applehelpwriter.com
- sqwarq.com
- *)
- ###########################################################
- -->> DESCRIPTION
- ###########################################################
- (*
- Display wifi passwords for all the SSIDs (Wifi network names) listed in the ssidList variable.
- *)
- ###########################################################
- -->> USAGE
- ###########################################################
- (*
- Replace the dummy SSID names in the ssidList variable with the name(s) of your SSID(s) on your network and run the script. You do NOT need to add the passwords to the script. So long as the mac that you run this script on already knows the Wifi password, the script will retrieve it.
- *)
- ###########################################################
- -->> IMPORT STATEMENTS
- ###########################################################
- use AppleScript version "2.4" -- Yosemite (10.10) or later
- use scripting additions
- use framework "Foundation"
- # use diagLib : script "Dialog ToolKit"
- # use fileLib : script "Folder_File_Contents"
- # use sortLib : script "AscendingSort"
- # use listStringLib : script "List_and_Strings Lib"
- ###########################################################
- -->> VARIABLES
- ###########################################################
- set d to current date
- set ssidList to {"dummy wifi name 1", "dummy wifi name 2"}
- set ssids to {}
- property NSString : a reference to current application's NSString
- ###########################################################
- -->> HANDLERS
- ###########################################################
- on parseError:anError
- set o to offset of "{{" in anError
- set p to offset of "}}" in anError
- set k to text (o + 2) thru (p - 1) of anError
- set s_String to NSString's stringWithString:k
- set r_String to NSString's stringWithString:"}, {"
- set s_String to (s_String's stringByReplacingOccurrencesOfString:r_String withString:"
- ")
- set s_String to (s_String's stringByReplacingOccurrencesOfString:"\"" withString:"")
- set s_String to (s_String's stringByReplacingOccurrencesOfString:"," withString:": ")
- set k to s_String as text
- return k
- end parseError:
- ###########################################################
- -->> COMMANDS
- #########################################################
- repeat with i from 1 to count of ssidList
- set this_ssid to item i of ssidList
- set ssidRect to {(this_ssid), (do shell script "security find-generic-password -D \"AirPort network password\" -a " & this_ssid & " -gw")}
- set end of ssids to ssidRect
- end repeat
- try
- display dialog ssids
- on error errMsg
- set msg to its parseError:errMsg
- display dialog msg buttons "OK" default button "OK" with title "SSID: Password"
- end try
- ###########################################################
- #EOF
Add Comment
Please, Sign In to add comment