Esportare le password dal portachiavi di OSX
Può essere utile esportare tutte le password salvate nel portachiavi (keychain) di OSX, magari per fare un’installazione pulita di OSX senza voler reimportare fisicamente il file del portachiavi (cosa che può creare qualche problema). Per farlo si può usare il comando security, con la seguente sintassi:
[sociallocker]
1 |
security dump-keychain -d login.keychain |
[/sociallocker]
Per esportare le password in un file da conservare, si può usare:
1 |
security dump-keychain -d login.keychain > keychain.txt |
Potrebbe essere richiesto più volte conferma di accesso al porta chiavi, in questo caso si può avviare un AppleScript con il seguente codice:
[sociallocker]
1 2 3 4 5 6 7 8 9 10 11 12 |
tell application "System Events" repeat while exists (processes where name is "SecurityAgent") tell process "SecurityAgent" try click button "Allow" of group 1 of window 1 on error click button "Autoriser" of group 1 of window 1 end try end tell delay 0.2 end repeat end tell |
[/sociallocker]
per Yosemite:
[sociallocker]
1 2 3 4 5 6 7 8 |
tell application "System Events" repeat while exists (processes where name is "SecurityAgent") tell process "SecurityAgent" click button "Allow" of window 1 end tell delay 0.2 end repeat end tell |
[/sociallocker]
Per MacOS Mojave:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<span class="pl-k">tell</span> <span class="pl-c1">application</span> <span class="pl-s"><span class="pl-pds">"</span>System Events<span class="pl-pds">"</span></span> <span class="pl-k">repeat</span> <span class="pl-k">while</span> exists (processes <span class="pl-k">where</span> <span class="pl-c1">name</span> <span class="pl-k">is</span> <span class="pl-s"><span class="pl-pds">"</span>SecurityAgent<span class="pl-pds">"</span></span>) <span class="pl-k">tell</span> process <span class="pl-s"><span class="pl-pds">"</span>SecurityAgent<span class="pl-pds">"</span></span> <span class="pl-k">set</span> <span class="pl-smi">frontmost</span> <span class="pl-k">to</span> <span class="pl-c1">true</span> <span class="pl-k">try</span> <span class="pl-c1">keystroke</span> <span class="pl-s"><span class="pl-pds">"</span>PUT YOUR KEYCHAIN'S PASSWORD HERE<span class="pl-pds">"</span></span> <span class="pl-c1">delay</span> <span class="pl-c1">0.1</span> <span class="pl-c1">keystroke</span> <span class="pl-c1">return</span> <span class="pl-c1">delay</span> <span class="pl-c1">0.1</span> <span class="pl-k">on error</span> <span class="pl-c">-- do nothing to skip the error</span> <span class="pl-k">end try</span> <span class="pl-k">end tell</span> <span class="pl-c1">delay</span> <span class="pl-c1">0.5</span> <span class="pl-k">end repeat</span> <span class="pl-k">end tell</span> |
Inoltre, per esportare anche System.keychain (generalmente ci sono le reti wifi ed altro cose del genere), si può eseguire:
[sociallocker]
1 |
security dump-keychain -d /Library/Keychains/System.keychain > systemkeychain.txt |
[/sociallocker]
Nota: Segnalo all’indirizzo https://gist.github.com/rwest/1583781 uno script ruby che recupera i dati dal file di dump e li converte in un csv.
enjoy!
Ti interessa acquistare un dominio a prezzi ultraconvenienti? clicca qui
Se hai trovato utili le informazioni su questo blog,
Fai una donazione!
Clicca sul bottone qui sotto o almeno clicca sul banner pubblicitario 🙂
Commenta