Skip to content

Instantly share code, notes, and snippets.

@emonti
Created January 10, 2014 11:38
Show Gist options
  • Save emonti/8350517 to your computer and use it in GitHub Desktop.
Save emonti/8350517 to your computer and use it in GitHub Desktop.
quick/dirty tool to extract embeded gzip files out of the evasi0n7 jailbreak binary -- requires otool so probably OSX
#!/usr/bin/env ruby
fname = ARGV.shift
fname || exit!
sections = `otool -l \"#{fname}\" |grep -A11 ^Section`.split(/^--$/).map do |sect_txt|
lines = sect_txt.lines.map(&:chomp)
Hash[ lines.map{|ln| ln.strip.split(' ', 2) } ]
end.select{|sect| sect["segname"] == "__DATA" and sect["sectname"] =~ /^data_\d+$/ }
dats = sections.map do |sect|
{
name: sect["sectname"],
fileoffset: sect["offset"].to_i,
size: sect["size"].hex,
}
end
f = File.open(fname, "r")
dats.each do |dat|
f.pos = dat[:fileoffset]
File.open(dat[:name] + ".gz", 'w'){|o| o.write(f.read(dat[:size])) }
end
@emonti
Copy link
Author

emonti commented Jan 10, 2014

FWIW: TaiG was data_10.gz inside the version I used this on...

@enzocaggiano
Copy link

how to use?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment