Created
October 23, 2015 19:33
-
-
Save emonti/bbba44bd3cac4f4fcc46 to your computer and use it in GitHub Desktop.
extract_lockdownd_services.rb
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/env ruby | |
fname = ARGV.shift | |
fname || exit! | |
offset = nil | |
size = nil | |
`otool -l \"#{fname}\" |grep -A11 ^Section`.split(/^--$/).each do |sect_txt| | |
lines = sect_txt.lines.map(&:chomp) | |
info = Hash[ lines[1..-1].map{|ln| ln.strip.split(' ',2)} ] | |
segname, sectname, off, sz = info.values_at("segname","sectname","offset","size") | |
if segname == "__TEXT" and sectname == "__services" | |
offset = off.to_i | |
size = sz.hex | |
break | |
end | |
end | |
unless offset and size | |
$stderr.puts "Couldn't find __TEXT,__services" | |
exit! | |
end | |
dat = IO.binread(fname, size, offset) | |
outfile = "#{fname}_services.plist" | |
$stderr.puts "Writing #{size} bytes to #{outfile}" | |
File.open(outfile, "wb") {|out| out.write dat} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment