Module: Rex::Proto::Http::WebSocket::AmazonSsm::UUID

Defined in:
lib/rex/proto/http/web_socket/amazon_ssm.rb

Class Method Summary collapse

Class Method Details

.pack(sbuf) ⇒ Object



48
49
50
51
52
53
54
55
# File 'lib/rex/proto/http/web_socket/amazon_ssm.rb', line 48

def self.pack(sbuf)
  parts = sbuf.split('-').map do |seg|
    seg.chars.each_slice(2).map {|e| "\\x#{e.join}"}.join
  end
  [3, 4, 0, 1, 2].map do |part|
    Rex::Text.hex_to_raw(parts[part])
  end.join
end

.randObject



57
58
59
# File 'lib/rex/proto/http/web_socket/amazon_ssm.rb', line 57

def self.rand
  self.unpack(Rex::Text.rand_text(16))
end

.unpack(bbuf) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/rex/proto/http/web_socket/amazon_ssm.rb', line 24

def self.unpack(bbuf)
  sbuf = ""
  [8...12].each do |idx|
    sbuf << Rex::Text.to_hex(bbuf[idx])
  end
  sbuf << '-'
  [12...14].each do |idx|
    sbuf << Rex::Text.to_hex(bbuf[idx])
  end
  sbuf << '-'
  [14...16].each do |idx|
    sbuf << Rex::Text.to_hex(bbuf[idx])
  end
  sbuf << '-'
  [0...2].each do |idx|
    sbuf << Rex::Text.to_hex(bbuf[idx])
  end
  sbuf << '-'
  [2...8].each do |idx|
    sbuf << Rex::Text.to_hex(bbuf[idx])
  end
  sbuf.gsub("\\x",'')
end