Tested on OS X El Capitan ver 10.11.6
Use case: You need to get your wifi passwords out for backup, or migration to another OS.
This process requires two parts:
- Running the 'security' command line tool.
- An AppleScript to keep clicking "allow" and/or enter the admin password.
First, you need to allow the "script editor" access the security prompts.
- Go to preferences
- Open Security & Privacy
- Click on the "Privacy" tab
- Unlock the settings (bottom left)
- Allow the "Script Editor.app" access
- Lock the settings (bottom left)
- Open "Script Editor"
- paste in the key-chain-dump-prompt.applescript
- Change your-username and your-password accordingly
- click the "play" button
Then:
- Open "terminal"
- Run the following:
$ security dump-keychain -d > keychain_all.txt
To extract the wifi ssids and passwords from the dump file, run the provided extract-wifi.py python script.
$ python extract-wifi.py
I used the Accessibility Inspector to determine the correct syntax for the apple script.