Exploit database

GH-b8ef63dfc23baf13f31679e3d915c856

sfewer-r7/cve-2026-20127

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-20127

8 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files4

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

lib/vdaemon_exploit/protocol/header.rb

Ruby · 3,849 bytes
# frozen_string_literal: true

require_relative 'constants'

module VdaemonExploit
  module Protocol
    # Represents the 12-byte vdaemon DTLS protocol header.
    #
    # Wire format:
    #   Byte  0      : (version << 4) | msg_type
    #   Byte  1      : device_type << 4
    #   Byte  2      : flags (0xA0 = standard)
    #   Byte  3      : 0x00 (reserved)
    #   Bytes 4 – 7  : domain_id  (big-endian u32)
    #   Bytes 8 – 11 : site_id    (big-endian u32)
    class Header
      HEADER_SIZE = 12

      attr_reader :version, :msg_type, :device_type, :has_frag,
                  :flags, :domain_id, :site_id

      # @param version     [Integer] protocol version (upper nibble of byte 0)
      # @param msg_type    [Integer] message type (lower nibble of byte 0)
      # @param device_type [Integer] device type (upper nibble of byte 1)
      # @param has_frag    [Integer] fragmentation bit from flags (bit 6)
      # @param flags       [Integer] raw flags byte (byte 2)
      # @param domain_id   [Integer] domain identifier (big-endian u32)
      # @param site_id     [Integer] site identifier (big-endian u32)
      def initialize(version: 0,
                     msg_type: Constants::MSG_HELLO,
                     device_type: Constants::DEFAULT_DEVICE_TYPE,
                     has_frag: 0,
                     flags: Constants::HDR_FLAGS,
                     domain_id: Constants::DEFAULT_DOMAIN_ID,
                     site_id: Constants::DEFAULT_SITE_ID)
        @version     = version
        @msg_type    = msg_type
        @device_type = device_type
        @has_frag    = has_frag
        @flags       = flags
        @domain_id   = domain_id
        @site_id     = site_id
      end

      # Serializes the header to a 12-byte binary string.
      #
      # @return [String] 12 bytes in ASCII-8BIT encoding
      def to_binary
        byte0 = ((version & 0xF) << 4) | (msg_type & 0xF)
        byte1 = (device_type & 0xF) << 4
        effective_flags = (flags & 0xBF) | ((has_frag & 1) << 6)
        [byte0, byte1, effective_flags, 0x00, domain_id, site_id].pack('CCCCN2')
      end

      # Parses a 12-byte binary string into a Header instance.
      #
      # @param data [String] at least 12 bytes of binary data
      # @return [Header]
      # @raise [ArgumentError] when data is shorter than HEADER_SIZE
      def self.parse(data)
        raise ArgumentError, "need >= #{HEADER_SIZE} bytes, got #{data.bytesize}" if data.bytesize < HEADER_SIZE

        bytes = data.unpack('CCCCN2')

        new(
          version: (bytes[0] >> 4) & 0xF,
          msg_type: bytes[0] & 0xF,
          device_type: (bytes[1] >> 4) & 0xF,
          has_frag: (bytes[2] >> 6) & 1,
          flags: bytes[2],
          domain_id: bytes[4],
          site_id: bytes[5]
        )
      end

      # Human-readable message type name.
      def msg_name
        Constants.msg_name(msg_type)
      end

      # Human-readable device type name.
      def dev_name
        Constants.dev_name(device_type)
      end

      def ==(other)
        other.is_a?(self.class) &&
          version == other.version &&
          msg_type == other.msg_type &&
          device_type == other.device_type &&
          has_frag == other.has_frag &&
          flags == other.flags &&
          domain_id == other.domain_id &&
          site_id == other.site_id
      end
      alias eql? ==

      def hash
        [version, msg_type, device_type, has_frag, flags, domain_id, site_id].hash
      end

      def inspect
        format(
          '#<%<cls>s %<msg>s dev=%<dev>s v=%<ver>d frag=%<frag>d ' \
          'flags=0x%<fl>02X domain=%<dom>d site=%<site>d>',
          cls: self.class.name, msg: msg_name, dev: dev_name,
          ver: version, frag: has_frag, fl: flags,
          dom: domain_id, site: site_id
        )
      end
    end
  end
end