Method: Rex::Text.to_vbapplication

Defined in:
lib/rex/text/lang.rb

.to_vbapplication(str, name = "buf") ⇒ Object

Converts a raw string into a vba buffer



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/rex/text/lang.rb', line 181

def self.to_vbapplication(str, name = "buf")
  return "#{name} = Array()" if str.nil? or str.empty?

  code  = str.unpack('C*')
  buff = "#{name} = Array("
  maxbytes = 80

  0.upto(code.length-1) do |idx|
    buff << code[idx].to_s
    buff << "," if idx < code.length - 1
    buff << " _\r\n" if (idx > 1 and (idx % maxbytes) == 0)
  end

  buff << ")\r\n"

  return buff
end