lib/AppleDecrypter.rb
##
# This function attempts to decrypt the specified data by looping over all the loaded passwords. 
# It expects a +salt+ as a binary String, the number of +iterations+ as an Integer, 
# a +key+ representing the wrapped key as a binary String, an +iv+ as a binary String, a +tag+ as a binary String, 
# the +data+ to be decrypted as a binary String, and the +item+ being decrypted as an Object to help with debugging. 
# Any successful decrypts will add the corresponding password to the +@successful_passwords+ to be tried 
# first the next time. 
This function attempts to decrypt the specified data by looping over all the loaded passwords.
This function attempts to decrypt the specified data by looping over all the loaded passwords .
def decrypt(salt, iterations, key, iv, tag, data, debug_text=nil)
    decrypt_result = false
    if @passwords.length == 0 and !@warned_about_empty_password_list
      puts "Apple Decrypter: Attempting to decrypt objects without a password list set, check the -w option for more success"
      @logger.error("Apple Decrypter: Attempting to decrypt objects without a password list set, check the -w option for more success")
      @warned_about_empty_password_list = true
    end
    @successful_passwords.each do |password|
      decrypt_result = decrypt_with_password(password, salt, iterations, key, iv, tag, data, debug_text)
      if decrypt_result
        break
      end
    end
    if !decrypt_result
      @passwords.each do |password|
        decrypt_result = decrypt_with_password(password, salt, iterations, key, iv, tag, data, debug_text)
        if decrypt_result
          @successful_passwords.push(password)
          break
        end
      end
    end
    return decrypt_result
  end
def decrypt ( salt , iterations , key , iv , tag , data , debug_text = nil ) decrypt_result = false if @passwords . length == 0 and ! @warned_about_empty_password_list puts "Apple Decrypter: Attempting to decrypt objects without a password list set, check the -w option for more success" @logger . error ( "Apple Decrypter: Attempting to decrypt objects without a password list set, check the -w option for more success" ) @warned_about_empty_password_list = true end @successful_passwords . each do | password | decrypt_result = decrypt_with_password ( password , salt , iterations , key , iv , tag , data , debug_text ) if decrypt_result break end end if ! decrypt_result @passwords . each do | password | decrypt_result = decrypt_with_password ( password , salt , iterations , key , iv , tag , data , debug_text ) if decrypt_result @successful_passwords . push ( password ) break end end end return decrypt_result end
This function attempts to decrypt the specified data by looping over all the loaded passwords.
This function attempts to decrypt the specified data by looping over all the loaded passwords .
# Initialize plaintext variable to be false so we can check if we don't succeed # Warn the user if we come across something encrypted and they haven't provided a password list # Start with the known good passwords # Only try the full list if we haven't already found the password
salt
iterations
key
iv
tag
data
debug_text