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

Untitled

By: a guest on Dec 31st, 2010  |  syntax: None  |  size: 0.97 KB  |  views: 142  |  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/env ruby
  2.  
  3. # Nasty little Core OS pkg unpacker
  4. # By Anomaly, NYE 2010/2011
  5.  
  6. if (ARGV[0] == "") || (ARGV[0] == nil)
  7.   puts "usage: #{$0} "
  8.   exit
  9. end
  10.  
  11. fd = open(ARGV[0],'r')
  12. hdr = fd.read(4)
  13. itemcount = fd.read(4).unpack('N')[0]
  14. dummy = fd.read(4)
  15. pkglen = fd.read(4).unpack('N')[0]
  16.  
  17. puts "pkg length:\t%d bytes" % pkglen
  18. puts "items:\t\t%d\n\n" % itemcount
  19.  
  20. files = {}
  21. for x in (1..itemcount)
  22.   fd.read(4)
  23.   offset = fd.read(4).unpack('N')[0]
  24.   fd.read(4)
  25.   len = fd.read(4).unpack('N')[0]
  26.   fname = fd.read(32).strip
  27.   files.update fname => [offset,len]
  28. end
  29.  
  30. for file in files.keys
  31.   puts "Filename: %s" % file
  32.   puts "Offset: %d" % files[file][0]
  33.   puts "Length: %d" % files[file][1]
  34.   begin
  35.     fd.seek(files[file][0],0)
  36.     tmpfd = open(file,'w')
  37.     tmpfd.write(fd.read(files[file][1]))
  38.     tmpfd.flush()
  39.     tmpfd.close()
  40.     puts "write succeeded\n\n"
  41.   rescue
  42.     puts "write failed:"
  43.     puts "#{$!}\n\n"
  44.   end
  45. end
  46.  
  47. fd.close()
clone this paste RAW Paste Data