class WinRM::PSRP::MessageData::PipelineOutput
Handles decoding a raw powershell output response
Public Instance Methods
output()
click to toggle source
# File lib/winrm/psrp/message_data/pipeline_output.rb, line 22 def output extract_out_string(remove_bom(raw.force_encoding('utf-8'))) end
Private Instance Methods
extract_out_string(text)
click to toggle source
# File lib/winrm/psrp/message_data/pipeline_output.rb, line 28 def extract_out_string(text) doc = REXML::Document.new(text) doc.root.get_elements('//S').map do |node| text = '' if node.text text << node.text.gsub(/(_x\h\h\h\h_)+/) do |match| match.scan(/_x(\h\h\h\h)_/).flatten.map(&:hex) .pack('S*').force_encoding('utf-16le').encode('utf-8') end.chomp end text << "\r\n" end.join end
remove_bom(text)
click to toggle source
# File lib/winrm/psrp/message_data/pipeline_output.rb, line 42 def remove_bom(text) text.sub("\xEF\xBB\xBF", '') end