Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
extract_lockdownd_services.rb
#!/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
You can’t perform that action at this time.