Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- # Nasty little Core OS pkg unpacker
- # By Anomaly, NYE 2010/2011
- if (ARGV[0] == "") || (ARGV[0] == nil)
- puts "usage: #{$0} "
- exit
- end
- fd = open(ARGV[0],'r')
- hdr = fd.read(4)
- itemcount = fd.read(4).unpack('N')[0]
- dummy = fd.read(4)
- pkglen = fd.read(4).unpack('N')[0]
- puts "pkg length:\t%d bytes" % pkglen
- puts "items:\t\t%d\n\n" % itemcount
- files = {}
- for x in (1..itemcount)
- fd.read(4)
- offset = fd.read(4).unpack('N')[0]
- fd.read(4)
- len = fd.read(4).unpack('N')[0]
- fname = fd.read(32).strip
- files.update fname => [offset,len]
- end
- for file in files.keys
- puts "Filename: %s" % file
- puts "Offset: %d" % files[file][0]
- puts "Length: %d" % files[file][1]
- begin
- fd.seek(files[file][0],0)
- tmpfd = open(file,'w')
- tmpfd.write(fd.read(files[file][1]))
- tmpfd.flush()
- tmpfd.close()
- puts "write succeeded\n\n"
- rescue
- puts "write failed:"
- puts "#{$!}\n\n"
- end
- end
- fd.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement