Parent

Class/Module Index [+]

Quicksearch

Rex::OLE::Util

Public Class Methods

Hexify32array(arr) click to toggle source
# File lib/rex/ole/util.rb, line 16
def self.Hexify32array(arr)
        ret = ""
        arr.each { |dw|
                ret << " " if ret.length > 0
                ret << "0x%08x" % dw
        }
        ret
end
Printable(buf) click to toggle source
# File lib/rex/ole/util.rb, line 25
def self.Printable(buf)
        ret = ""
        buf.unpack('C*').each { |byte|
                ch = byte.chr
                if (byte < 0x20 || byte > 0x7e)
                        ret << "\\x" + ch.unpack('H*')[0]
                else
                        ret << ch
                end
        }
        ret
end
get16(buf, offset) click to toggle source
# File lib/rex/ole/util.rb, line 102
def self.get16(buf, offset)
        @endian = LITTLE_ENDIAN if not @endian
        if (@endian == LITTLE_ENDIAN)
                buf[offset,2].unpack('v')[0]
        else
                buf[offset,2].unpack('n')[0]
        end
end
get32(buf, offset) click to toggle source
# File lib/rex/ole/util.rb, line 66
def self.get32(buf, offset)
        @endian = LITTLE_ENDIAN if not @endian
        if (@endian == LITTLE_ENDIAN)
                buf[offset,4].unpack('V')[0]
        else
                buf[offset,4].unpack('N')[0]
        end
end
get32array(buf) click to toggle source
# File lib/rex/ole/util.rb, line 84
def self.get32array(buf)
        @endian = LITTLE_ENDIAN if not @endian
        if (@endian == LITTLE_ENDIAN)
                buf.unpack('V*')
        else
                buf.unpack('N*')
        end
end
get64(buf, offset) click to toggle source
# File lib/rex/ole/util.rb, line 43
def self.get64(buf, offset)
        @endian = LITTLE_ENDIAN if not @endian
        if (@endian == LITTLE_ENDIAN)
                arr = buf[offset,8].unpack('VV')
                return (arr[0] + (arr[1] << 32))
        else
                arr = buf[offset,8].unpack('NN')
                return ((arr[0] << 32) + arr[1])
        end
end
get8(buf, offset) click to toggle source
# File lib/rex/ole/util.rb, line 120
def self.get8(buf, offset)
        buf[offset,1].unpack('C')[0]
end
getUnicodeString(buf) click to toggle source
# File lib/rex/ole/util.rb, line 129
def self.getUnicodeString(buf)
        buf = buf.unpack('S*').pack('C*')
        if (idx = buf.index(0x00.chr))
                buf.slice!(idx, buf.length)
        end
        buf
end
name_is_valid(name) click to toggle source
# File lib/rex/ole/util.rb, line 146
def self.name_is_valid(name)
        return nil if (name.length > 31)
        (0..0x1f).to_a.each { |x|
                return nil if (name.include?(x.chr))
        }
        return true
end
pack16(value) click to toggle source
# File lib/rex/ole/util.rb, line 111
def self.pack16(value)
        @endian = LITTLE_ENDIAN if not @endian
        if (@endian == LITTLE_ENDIAN)
                [value].pack('v')
        else
                [value].pack('n')
        end
end
pack32(value) click to toggle source
# File lib/rex/ole/util.rb, line 75
def self.pack32(value)
        @endian = LITTLE_ENDIAN if not @endian
        if (@endian == LITTLE_ENDIAN)
                [value].pack('V')
        else
                [value].pack('N')
        end
end
pack32array(arr) click to toggle source
# File lib/rex/ole/util.rb, line 93
def self.pack32array(arr)
        @endian = LITTLE_ENDIAN if not @endian
        if (@endian == LITTLE_ENDIAN)
                arr.pack('V*')
        else
                arr.pack('N*')
        end
end
pack64(value) click to toggle source
# File lib/rex/ole/util.rb, line 54
def self.pack64(value)
        @endian = LITTLE_ENDIAN if not @endian
        arr = []
        arr << (value & 0xffffffff)
        arr << (value >> 32)
        if (@endian == LITTLE_ENDIAN)
                arr.pack('VV')
        else
                arr.reverse.pack('NN')
        end
end
pack8(value) click to toggle source
# File lib/rex/ole/util.rb, line 124
def self.pack8(value)
        [value].pack('C')
end
putUnicodeString(buf) click to toggle source
# File lib/rex/ole/util.rb, line 137
def self.putUnicodeString(buf)
        buf = buf.unpack('C*').pack('S*')
        if (buf.length < 0x40)
                buf << "\x00" * (0x40 - buf.length)
        end
        buf
end
set_endian(endian) click to toggle source
# File lib/rex/ole/util.rb, line 39
def self.set_endian(endian)
        @endian = endian
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.