Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

OBB Extractor by Pinkazoid

By: a guest on Nov 14th, 2012  |  syntax: Perl  |  size: 1.24 KB  |  views: 340  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/perl
  2.  
  3. #OBB Extractor by Pinkazoid
  4.  
  5. use Fcntl;
  6. use File::Path;
  7. use File::Basename;
  8.  
  9. $basepath = 'ponydata/';
  10.  
  11. open(INFILE,"<main.1050.com.gameloft.android.ANMP.GloftPOHM.obb");
  12. binmode(INFILE);
  13. open(IDXFILE,'>ponydata.txt');
  14. if (read(INFILE,$fat,9) == 9) {
  15.   seek (INFILE,$fat,SEEK_SET);
  16.   while ($data = <INFILE>) {
  17.     print IDXFILE $data;
  18.     chomp($data);
  19.     push @filelist,$data;
  20.   }
  21. } else {
  22.   print "Unable to read first 9 bytes for file table location, aborting.\n";
  23.   end;
  24. }
  25. close(IDXFILE);
  26.  
  27. foreach $data (@filelist) {
  28.   ($start,$end,$junk,$junk,$filepath) = split(/\s+/,$data,5);
  29.   if ($filepath =~ /\//) {
  30.     my ($filename, $filedir) = fileparse($filepath);
  31.     $filedir = $basepath . $filedir;
  32.     if (!(-e $filedir)) {
  33.       mkpath($filedir);
  34.     }
  35.   }
  36.   if (open(OUTFILE,">$basepath$filepath")) {
  37.     binmode(OUTFILE);
  38.     seek (INFILE,$start,SEEK_SET);
  39.     $size = $end - $start;
  40.     if (read(INFILE,$buffer,$size) == $size) {
  41.       print OUTFILE $buffer;
  42.     } else {
  43.       print "Unable to read $size bytes at location $start, aborting.\n";
  44.       end;
  45.     }
  46.     close(OUTFILE);
  47.   } else {
  48.     print "Unable to open $basepath$filepath for writing, aborting.\n";
  49.     end;
  50.   }
  51. }
  52.  
  53. close(INFILE);