Sha256: f561453e0d002f6fba24b4691e31a69340cd00aafb973fe5a98e50393b792900
Contents?: true
Size: 1.43 KB
Versions: 2
Compression:
Stored size: 1.43 KB
Contents
# -*- coding: binary -*- ## # $Id: minifat.rb 15548 2012-06-29 06:08:20Z rapid7 $ # Version: $Revision: 15548 $ ## ## # Rex::OLE - an OLE implementation # written in 2010 by Joshua J. Drake <jduck [at] metasploit.com> ## module Rex module OLE class MiniFAT < DIFAT # # low-level functions # def read @entries = [] visited = [] sect = @stg.header._sectMiniFatStart @stg.header._csectMiniFat.times { |idx| break if sect == SECT_END if (visited.include?(sect)) raise RuntimeError, 'Sector chain loop detected (0x%08x)' % sect end visited << sect buf = @stg.read_sector(sect, @stg.header.sector_size) @stg.header.idx_per_sect.times { |idx| @entries << Util.get32(buf, (idx*4)) } sect = @stg.next_sector(sect) } end def allocate_sector idx = @entries.index(SECT_FREE) if (not idx) # add a sector worth idx = @entries.length @stg.header.idx_per_sect.times { @entries << SECT_FREE } end # default mini-sectors to end of chain @entries[idx] = SECT_END idx end def write return if (@entries.length < 1) mf_start = nil mfs_count = 0 prev_sect = nil copy = @entries.dup while (copy.length > 0) part = copy.slice!(0, @stg.header.idx_per_sect) sbuf = Util.pack32array(part) idx = @stg.write_sector(sbuf, nil, prev_sect) mfs_count += 1 mf_start ||= idx end @stg.header._sectMiniFatStart = mf_start @stg.header._csectMiniFat = mfs_count end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
librex-0.0.68 | lib/rex/ole/minifat.rb |
librex-0.0.66 | lib/rex/ole/minifat.rb |