Created
January 10, 2012 05:37
-
-
Save dayglojesus/1587231 to your computer and use it in GitHub Desktop.
Recover Lion Password Hash with RubyCocoa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'openssl' | |
require 'osx/cocoa' | |
include OSX | |
plain_text_pass = 'foobar' | |
file = 'user.plist' | |
user_plist = NSDictionary.dictionaryWithContentsOfFile(file) | |
embedded_bplist = NSPropertyListSerialization.objc_send( | |
:propertyListFromData, user_plist['ShadowHashData'][0], | |
:mutabilityOption, NSPropertyListImmutable, | |
:format, nil, | |
:errorDescription, nil | |
) | |
recovered_hash = embedded_bplist['SALTED-SHA512'].to_s.gsub(/<|>/,"").split | |
sugar = recovered_hash.shift | |
salt = sugar.scan(/../).collect { |byte| byte.hex.chr } | |
generated_hash = OpenSSL::Digest::SHA512.hexdigest(salt.join + plain_text_pass) | |
puts generated_hash | |
puts recovered_hash.join | |
puts "MATCH!" if generated_hash.eql?(recovered_hash.join) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment