Method: Rex::OLE::Header#read

Defined in:
lib/rex/ole/header.rb

#read(fd) ⇒ Object

low-level functions



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/rex/ole/header.rb', line 125

def read(fd)
  buf = fd.read(HDR_SZ)

  @_abSig        = buf[0x00,8]
  if (@_abSig != SIG) and (@_abSig != SIG_BETA)
    raise RuntimeError, 'Invalid signature for OLE file'
  end
  @_clid = CLSID.new(buf[0x08,16])

  @_uByteOrder   = Util.get16(buf, 0x1c)
  Util.set_endian(@_uByteOrder)

  @_uMinorVersion       = Util.get16(buf, 0x18)
  @_uMajorVersion       = Util.get16(buf, 0x1a)

  @_uSectorShift        = Util.get16(buf, 0x1e)
  @_uMiniSectorShift    = Util.get16(buf, 0x20)

  # ignore reserved bytes

  @_csectDir            = Util.get32(buf, 0x28) # NOTE: only for v4 files

  @_csectFat            = Util.get32(buf, 0x2c)
  @_sectDirStart        = Util.get32(buf, 0x30)

  @_signature           = Util.get32(buf, 0x34)

  @_ulMiniSectorCutoff  = Util.get32(buf, 0x38)
  @_sectMiniFatStart    = Util.get32(buf, 0x3c)
  @_csectMiniFat        = Util.get32(buf, 0x40)

  @_sectDifStart        = Util.get32(buf, 0x44)
  @_csectDif            = Util.get32(buf, 0x48)

  @_sectFat = Util.get32array(buf[0x4c, (109 * 4)])
end