applehelpwriter

Recover Wifi passwords

Sep 23rd, 2017
923
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ###########################################################
  2. -->> ABOUT
  3. ###########################################################
  4. (*
  5.  
  6.  Phil Stokes -- 2017
  7.  applehelpwriter.com
  8.  sqwarq.com
  9.  
  10. *)
  11. ###########################################################
  12. -->> DESCRIPTION
  13. ###########################################################
  14. (*
  15.  
  16. Display wifi passwords for all the SSIDs (Wifi network names) listed in the ssidList variable.
  17.  
  18.  
  19. *)
  20. ###########################################################
  21. -->> USAGE
  22. ###########################################################
  23. (*
  24.  
  25. 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.
  26.  
  27. *)
  28. ###########################################################
  29. -->> IMPORT STATEMENTS
  30. ###########################################################
  31.  
  32. use AppleScript version "2.4" -- Yosemite (10.10) or later
  33. use scripting additions
  34. use framework "Foundation"
  35. # use diagLib : script "Dialog ToolKit"
  36. # use fileLib : script "Folder_File_Contents"
  37. # use sortLib : script "AscendingSort"
  38. # use listStringLib : script "List_and_Strings Lib"
  39.  
  40. ###########################################################
  41. -->> VARIABLES
  42. ###########################################################
  43. set d to current date
  44. set ssidList to {"dummy wifi name 1", "dummy wifi name 2"}
  45. set ssids to {}
  46. property NSString : a reference to current application's NSString
  47.  
  48.  
  49. ###########################################################
  50. -->> HANDLERS
  51. ###########################################################
  52. on parseError:anError
  53.     set o to offset of "{{" in anError
  54.     set p to offset of "}}" in anError
  55.     set k to text (o + 2) thru (p - 1) of anError
  56.     set s_String to NSString's stringWithString:k
  57.     set r_String to NSString's stringWithString:"}, {"
  58.     set s_String to (s_String's stringByReplacingOccurrencesOfString:r_String withString:"
  59. ")
  60.     set s_String to (s_String's stringByReplacingOccurrencesOfString:"\"" withString:"")
  61.     set s_String to (s_String's stringByReplacingOccurrencesOfString:"," withString:": ")
  62.     set k to s_String as text
  63.     return k
  64. end parseError:
  65.  
  66. ###########################################################
  67. -->> COMMANDS
  68. #########################################################
  69.  
  70. repeat with i from 1 to count of ssidList
  71.     set this_ssid to item i of ssidList
  72.     set ssidRect to {(this_ssid), (do shell script "security find-generic-password -D \"AirPort network password\" -a " & this_ssid & " -gw")}
  73.     set end of ssids to ssidRect
  74. end repeat
  75.  
  76. try
  77.     display dialog ssids
  78. on error errMsg
  79.     set msg to its parseError:errMsg
  80.     display dialog msg buttons "OK" default button "OK" with title "SSID: Password"
  81. end try
  82.  
  83. ###########################################################
  84. #EOF
Add Comment
Please, Sign In to add comment