How to import old AirPort passwords
I didn't know where else to put this, but I thought I'd mention it in case anyone was having the same issue.
There are no built-in tools for decrypting the System keychain, but there is a python script called chainbreaker.py which can: https://github.com/n0fate/chainbreaker
I did a simple edit of the script around line 848:
cmd = '/usr/bin/security add-generic-password -a "%s"' % record[8].strip('\0')
cmd += ' -l "%s"' % record[8].strip('\0')
cmd += ' -s "%s"' % record[9].strip('\0')
cmd += ' -D "%s"' % record[3].strip('\0')
cmd += ' -w "%s"' % passwd.strip('\0')
cmd += ' -T "/usr/libexec/airportd" "/Library/Keychains/System.keychain"'
print 'cmd: %s' % cmd
# hexdump(cmd)
print ''
os.system(cmd)
This will only modify your System keychain if you run it as root. Be careful before you do, and make sure you're well enough versed in how the security program works, particularly the add-generic-password command. You can also copy and paste the individual commands for each wifi password you wish to migrate which is probably the safer option (although I had so many I just dumped it).
No applescript/automator magic needed.
To get the key in hex form, type this: sudo hexdump -s 8 -n 24 -e '1/1 "%.2x"' /var/db/SystemKey && echo
Thanks for pointing out chainbreaker. My script is getting old and, as I have not used Apple Keychain for several years, I am losing interest in keeping my script up to date. It's good that there are other solutions out there!
Yes