Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/rex/proto/ldap/auth_adapter/rex_kerberos.rb
Views: 11766
# frozen_string_literal: true12require 'net/ldap/auth_adapter'3require 'net/ldap/auth_adapter/sasl'4require 'rubyntlm'56module Rex::Proto::LDAP::AuthAdapter7class RexKerberos < Net::LDAP::AuthAdapter8def bind(auth)9kerberos_authenticator = auth[:kerberos_authenticator]10unless kerberos_authenticator11raise Net::LDAP::BindingInformationInvalidError, 'Invalid binding information (missing kerberos authenticator)'12end1314options = {}15if @connection.socket.respond_to?(:peer_cert)16options = {17gss_channel_binding: Rex::Proto::Gss::ChannelBinding.from_tls_cert(18@connection.socket.peer_cert19),20# when TLS channel binding is in use, disable the sign and seal flags21gss_flag_confidential: false,22gss_flag_integrity: false23}24end2526kerberos_result = kerberos_authenticator.authenticate(options)27initial_credential = kerberos_result[:security_blob]2829result = Net::LDAP::AuthAdapter::Sasl.new(@connection).bind(30method: :sasl,31mechanism: 'GSS-SPNEGO',32initial_credential: initial_credential,33challenge_response: true34)3536if auth[:sign_and_seal]37encryptor = Encryptor.new(kerberos_authenticator)38encryptor.setup(@connection, kerberos_result, result.result[:serverSaslCreds])39end4041result42end43end44end4546Net::LDAP::AuthAdapter.register(:rex_kerberos, Rex::Proto::LDAP::AuthAdapter::RexKerberos)474849