Skip to content

Instantly share code, notes, and snippets.

@breezeight
Created January 23, 2014 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save breezeight/8579873 to your computer and use it in GitHub Desktop.
Save breezeight/8579873 to your computer and use it in GitHub Desktop.
print_provision.rb extract the mobileprovisioning and print its content
#!/usr/bin/env ruby
#gem install rubyzip
require 'rubygems'
require 'zip'
require 'pathname'
def error(msg)
puts "(error) #{msg}"
exit 1
end
if ARGV.size!=1
error "usage: print_provision.rb <ipa_file>"
end
zipfile_path=ARGV[0]
if File.extname(zipfile_path) != ".ipa"
error "#{zipfile_path} is not an ipa"
end
app_name = File.basename(zipfile_path, ".ipa")
MOBILE_PROVISIONING_PATH="Payload/#{app_name}.app/embedded.mobileprovision"
zipfile = Zip::File.open(zipfile_path)
zipentry = zipfile.find_entry(MOBILE_PROVISIONING_PATH)
if zipentry.nil?
error "#{MOBILE_PROVISIONING_PATH} is not contained in #{zipfile_path}"
exit 1
end
filename = Pathname.new(zipentry.name).split.last.to_s
zipfile.extract(zipentry, filename)
puts "#{filename} extracted in #{Dir.pwd}"
puts `security cms -D -i #{filename}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment