Method: PSRP::MessageDecoder#initialize

Defined in:
lib/wsmv/psrp_message.rb

#initialize(raw_text) ⇒ MessageDecoder

Returns a new instance of MessageDecoder.



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/wsmv/psrp_message.rb', line 92

def initialize(raw_text)
  # Message ID - 8bytes
  # Fragment ID - 8bytes
  # reserved - 6bits
  # end fragment - 1bit
  # start fragment - 1bit
  # blob_length - 4bytes
  # destination - 4bytes
  # message_type - 4bytes
  # client runspace GUID - 16bytes
  # client PID GUID - 16bytes
  # BOM 3bytes
  # 
  # Data - blob_length - 43 bytes (40 blob bytes + BOM)
  unencoded = Base64.decode64(raw_text)
  fields = unencoded.unpack('Q>2CL>L<2h32h32C3A*')

  @message_id = fields[0]
  @fragment_id = fields[1]
  @fragment_flags = fields[2]
  @blob_length = fields[3]
  
  if is_start_fragment?
    @destination = fields[4]
    @message_type = fields[5]
    @client_runspace = fields[6]
    @client_pid = fields[7]
    @data = fields[11]
  else
    fields = unencoded.unpack('Q>2CL>A*')
    @destination = nil
    @message_type = nil
    @client_runspace = nil
    @client_pid = nil
    @data = fields[4]
  end
end