Advertisement
Guest User

Untitled

a guest
Mar 28th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #!/usr/bin/ruby
  2.  
  3. account = ARGV[0] # account name, e.g. pdxmph@gmail.com
  4. server = ARGV[1] # account server, e.g. imap.gmail.com
  5. user = `whoami`.strip!
  6. keychain_path = "#{ENV['HOME']}/Library/Keychains/login.keychain"
  7.  
  8. params = {'security' => '/usr/bin/security',
  9. 'command' => 'find-internet-password',
  10. 'account' => account,
  11. 'server' => server,
  12. 'keychain' => keychain_path}
  13.  
  14. output = `sudo -u #{user} #{params['security']} 2>&1 >/dev/null -q #{params['command']} -g -a #{params['account']} -s #{params['server']} #{params['keychain']}`
  15.  
  16. puts output.gsub(/^password:\ "(.+?)"/,"\\1")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement