Before

…lines 1–24 unchanged (24 lines)
25
26 #[Authorisation Services](https://pubs.opengroup.org/onlinepubs/9629399/chap13.htm#tagcjh_18_01_02_03)
27 DCE_C_AUTHZ_NAME = 1
28 DCE_C_AUTHZ_DCE = 2
29
30 require 'windows_error/win32'
31 require 'ruby_smb/dcerpc/error'
32 require 'ruby_smb/dcerpc/fault'
33 require 'ruby_smb/dcerpc/uuid'
34 require 'ruby_smb/dcerpc/ndr'
35 require 'ruby_smb/dcerpc/ptypes'
36 require 'ruby_smb/dcerpc/p_syntax_id_t'
37 require 'ruby_smb/dcerpc/rrp_rpc_unicode_string'
…lines 38–185 unchanged (148 lines)
186 # @return [BindAck] the BindAck response packet
187 # @raise [Error::InvalidPacket] if an invalid packet is received
188 # @raise [Error::BindError] if the response is not a BindAck packet or if the Bind result code is not ACCEPTANCE
189 # @raise [ArgumentError] if `:auth_type` is unknown
190 # @raise [NotImplementedError] if `:auth_type` is not implemented (yet)
191 def bind(options={})
192 @call_id ||= 1
193 bind_req = Bind.new(options)
194 bind_req.pdu_header.call_id = @call_id
195 auth_type = options.fetch(:auth_type) { RPC_C_AUTHN_WINNT }
196 auth_level = options.fetch(:auth_level) { RPC_C_AUTHN_LEVEL_NONE }
197
198 force_set_auth_params(auth_type, auth_level)
…lines 199–367 unchanged (169 lines)

After

…lines 1–24 unchanged (24 lines)
25
26 #[Authorisation Services](https://pubs.opengroup.org/onlinepubs/9629399/chap13.htm#tagcjh_18_01_02_03)
27 DCE_C_AUTHZ_NAME = 1
28 DCE_C_AUTHZ_DCE = 2
29
30 require 'windows_error/win32'
31 require 'ruby_smb/dcerpc/client'
32 require 'ruby_smb/dcerpc/error'
33 require 'ruby_smb/dcerpc/fault'
34 require 'ruby_smb/dcerpc/uuid'
35 require 'ruby_smb/dcerpc/ndr'
36 require 'ruby_smb/dcerpc/ptypes'
37 require 'ruby_smb/dcerpc/p_syntax_id_t'
…lines 38–186 unchanged (149 lines)
187 # @return [BindAck] the BindAck response packet
188 # @raise [Error::InvalidPacket] if an invalid packet is received
189 # @raise [Error::BindError] if the response is not a BindAck packet or if the Bind result code is not ACCEPTANCE
190 # @raise [ArgumentError] if `:auth_type` is unknown
191 # @raise [NotImplementedError] if `:auth_type` is not implemented (yet)
192 def bind(options={})
193 options = options.merge(endpoint: @endpoint) if !options[:endpoint] && defined?(:@endpoint) && @endpoint
194
195 @call_id ||= 1
196 bind_req = Bind.new(options)
197 bind_req.pdu_header.call_id = @call_id
198 auth_type = options.fetch(:auth_type) { RPC_C_AUTHN_WINNT }
199 auth_level = options.fetch(:auth_level) { RPC_C_AUTHN_LEVEL_NONE }
…lines 200–370 unchanged (171 lines)

Before

program
module
module "module"
constant "RubySMB"
body_statement
module
module "module"
constant "Dcerpc"
body_statement
assignment
constant "MAX_XMIT_FRAG"
= "="
integer "4280"
assignment
constant "MAX_RECV_FRAG"
= "="
integer "4280"
comment "# Auth Levels"
comment "#[2.2.1.1.8 Authentication Levels](https://docs.microsoft.co"...
assignment
constant "RPC_C_AUTHN_LEVEL_DEFAULT"
= "="
integer "0"
assignment
constant "RPC_C_AUTHN_LEVEL_NONE"
= "="
integer "1"
assignment
constant "RPC_C_AUTHN_LEVEL_CONNECT"
= "="
integer "2"
assignment
constant "RPC_C_AUTHN_LEVEL_CALL"
= "="
integer "3"
assignment
constant "RPC_C_AUTHN_LEVEL_PKT"
= "="
integer "4"
assignment
constant "RPC_C_AUTHN_LEVEL_PKT_INTEGRITY"
= "="
integer "5"
assignment
constant "RPC_C_AUTHN_LEVEL_PKT_PRIVACY"
= "="
integer "6"
comment "## Auth Types"
comment "# [2.2.1.1.7 Security Providers](https://docs.microsoft.com/"...
assignment
constant "RPC_C_AUTHN_NONE"
= "="
integer "0x00"
assignment
constant "RPC_C_AUTHN_GSS_NEGOTIATE"
= "="
integer "0x09"
assignment
constant "RPC_C_AUTHN_WINNT"
= "="
integer "0x0A"
assignment
constant "RPC_C_AUTHN_GSS_SCHANNEL"
= "="
integer "0x0E"
assignment
constant "RPC_C_AUTHN_GSS_KERBEROS"
= "="
integer "0x10"
assignment
constant "RPC_C_AUTHN_NETLOGON"
= "="
integer "0x44"
assignment
constant "RPC_C_AUTHN_DEFAULT"
= "="
integer "0xFF"
comment "#[Authorisation Services](https://pubs.opengroup.org/onlinep"...
assignment
constant "DCE_C_AUTHZ_NAME"
= "="
integer "1"
assignment
constant "DCE_C_AUTHZ_DCE"
= "="
integer "2"
call
identifier "require"
argument_list
string
" "'"
string_content "windows_error/win32"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/error"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/fault"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/uuid"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/ndr"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/ptypes"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/p_syntax_id_t"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/rrp_rpc_unicode_string"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/rpc_security_attributes"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/pdu_header"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/srvsvc"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/svcctl"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/winreg"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/netlogon"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/samr"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/wkssvc"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/epm"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/drsr"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/sec_trailer"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/dfsnm"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/icpr"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/efsrpc"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/lsarpc"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/request"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/response"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/rpc_auth3"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/port_any_t"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/p_cont_list_t"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/p_result_t"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/p_result_list_t"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/alter_context"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/bind"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/bind_ack"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/alter_context_resp"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/print_system"
" "'"
comment "# Initialize the auth provider using NTLM. This function sho"...
comment "# @raise ArgumentError If @ntlm_client isn't initialized wit"...
comment "# @return Serialized message for initializing the auth provi"...
method (+28 nodes collapsed)
comment "# Encrypt the value in dcerpc_req.stub, and add a valid sign"...
comment "# This function modifies the request object in-place, and do"...
comment "# This function should be overriden for other providers (e.g"...
comment "# @param dcerpc_req [Request] The Request object to be encry"...
method (+229 nodes collapsed)
comment "# Get the response's full stub value (which will include the"...
comment "# @param dcerpc_response [Response] The Response object to e"...
comment "# @return [String] The full stub, including auth_pad"
method (+25 nodes collapsed)
comment "# Decrypt the value in dcerpc_req.stub, and validate its sig"...
comment "# This function modifies the request object in-place, and re"...
comment "# This function should be overriden for other providers (e.g"...
comment "# @param dcerpc_response [Response] The Response packet to d"...
comment "# @raise ArgumentError If the auth type is not NTLM"
comment "# @return [Boolean] Is the packet's signature valid?"
method (+177 nodes collapsed)
comment "# Completes local initialisation of @ntlm_client using the s"...
comment "#"
comment "# @param type2_message [String] NTLM type 2 message sent fro"...
comment "# @return [String] Type 3 message to be sent to the server t"...
method (+82 nodes collapsed)
comment "# Send a rpc_auth3 PDU that ends the authentication handshak"...
comment "# This function should be overriden for other providers (e.g"...
comment "#"
comment "# @param response [BindAck] the BindAck response packet"
comment "# @param options [Hash] Unused by the NTLM auth provider"
method (+61 nodes collapsed)
method
def "def"
identifier "force_set_auth_params"
method_parameters
( "("
identifier "auth_type"
, ","
identifier "auth_level"
) ")"
body_statement
assignment
instance_variable "@auth_type"
= "="
identifier "auth_type"
assignment
instance_variable "@auth_level"
= "="
identifier "auth_level"
end "end"
comment "# Bind to the remote server interface endpoint. It takes car"...
comment "# the necessary authentication verifier if `:auth_level` is "...
comment "# anything different than RPC_C_AUTHN_LEVEL_NONE"
comment "#"
comment "# @param [Hash] options"
comment "# @option options [Module] :endpoint the endpoint to bind to"...
comment "# class with UUID, VER_MAJOR and VER_MINOR constants defin"...
comment "# @option options [Integer] :auth_level the authentication l"...
comment "# @option options [Integer] :auth_type the authentication ty"...
comment "# @return [BindAck] the BindAck response packet"
comment "# @raise [Error::InvalidPacket] if an invalid packet is rece"...
comment "# @raise [Error::BindError] if the response is not a BindAck"...
comment "# @raise [ArgumentError] if `:auth_type` is unknown"
comment "# @raise [NotImplementedError] if `:auth_type` is not implem"...
method
def "def"
identifier "bind"
method_parameters
( "("
optional_parameter
identifier "options"
= "="
hash
{ "{"
} "}"
) ")"
body_statement
operator_assignment
instance_variable "@call_id"
||= "||="
integer "1"
assignment
identifier "bind_req"
= "="
call
constant "Bind"
. "."
identifier "new"
argument_list
( "("
identifier "options"
) ")"
assignment
call
call
identifier "bind_req"
. "."
identifier "pdu_header"
. "."
identifier "call_id"
= "="
instance_variable "@call_id"
assignment
identifier "auth_type"
= "="
call
identifier "options"
. "."
identifier "fetch"
argument_list
( "("
simple_symbol ":auth_type"
) ")"
block
{ "{"
block_body
constant "RPC_C_AUTHN_WINNT"
} "}"
assignment
identifier "auth_level"
= "="
call
identifier "options"
. "."
identifier "fetch"
argument_list
( "("
simple_symbol ":auth_level"
) ")"
block
{ "{"
block_body
constant "RPC_C_AUTHN_LEVEL_NONE"
} "}"
call
identifier "force_set_auth_params"
argument_list
( "("
identifier "auth_type"
, ","
identifier "auth_level"
) ")"
if (+33 nodes collapsed)
call
identifier "send_packet"
argument_list
( "("
identifier "bind_req"
) ")"
begin (+28 nodes collapsed)
comment "# TODO: see if BindNack response should be handled too"
assignment
identifier "res_list"
= "="
call
identifier "dcerpc_response"
. "."
identifier "p_result_list"
if (+72 nodes collapsed)
assignment
call
self "self"
. "."
identifier "max_buffer_size"
= "="
call
identifier "dcerpc_response"
. "."
identifier "max_xmit_frag"
assignment
instance_variable "@call_id"
= "="
call
call
identifier "dcerpc_response"
. "."
identifier "pdu_header"
. "."
identifier "call_id"
if
if "if"
binary
identifier "auth_level"
!= "!="
constant "RPC_C_AUTHN_LEVEL_NONE"
comment "# The number of legs needed to build the security context is"...
comment "# by the security provider"
comment "# (see [2.2.1.1.7 Security Providers](https://learn.microsof"...
then
call
identifier "auth_provider_complete_handshake"
argument_list
( "("
identifier "dcerpc_response"
, ","
identifier "options"
) ")"
end "end"
identifier "dcerpc_response"
end "end"
method (+21 nodes collapsed)
comment "# Receive a packet from the remote host and parse it accordi"...
comment "#"
comment "# @param struct [Class] the structure class to parse the res"...
method (+84 nodes collapsed)
comment "# Send a packet to the remote host"
comment "#"
comment "# @param packet [BinData::Record] the packet to send"
comment "# @raise [Error::CommunicationError] if socket-related error"...
method (+23 nodes collapsed)
method (+25 nodes collapsed)
comment "# Add the authentication verifier to a Request packet. This "...
comment "# sec trailer and the signature of the packet. This also enc"...
comment "# Request stub if privacy is required (`:auth_level` option "...
comment "# RPC_C_AUTHN_LEVEL_PKT_PRIVACY)."
comment "#"
comment "# @param dcerpc_req [Request] the Request packet to be updat"...
comment "# @param opts [Hash] the authentication options: `:auth_type"...
comment "# @raise [NotImplementedError] if `:auth_type` is not implem"...
comment "# @raise [ArgumentError] if `:auth_type` is unknown"
method (+102 nodes collapsed)
method (+31 nodes collapsed)
method (+76 nodes collapsed)
method (+78 nodes collapsed)
comment "# Process the security context received in a response. It de"...
comment "# encrypted stub if `:auth_level` is set to anything differe"...
comment "# RPC_C_AUTHN_LEVEL_PKT_PRIVACY. It also checks the packet s"...
comment "# raises an InvalidPacket error if it fails. Note that the e"...
comment "# disabled by default and can be enabled with the"
comment "# `:raise_signature_error` option"
comment "#"
comment "# @param dcerpc_response [Response] the Response packet"
comment "# containing the security context to process"
comment "# @param opts [Hash] the authentication options: `:auth_type"...
comment "# `:auth_level`. To enable errors when signature check fai"...
comment "# `:raise_signature_error` option to true"
comment "# @raise [NotImplementedError] if `:auth_type` is not implem"...
comment "# @raise [Error::CommunicationError] if socket-related error"...
method (+94 nodes collapsed)
comment "# Add the authentication verifier to the packet. This includ"...
comment "# trailer and the actual authentication data."
comment "#"
comment "# @param req [BinData::Record] the request to be updated"
comment "# @param auth [String] the authentication data"
method (+59 nodes collapsed)
end "end"
end "end"

After

program
module
module "module"
constant "RubySMB"
body_statement
module
module "module"
constant "Dcerpc"
body_statement
assignment
constant "MAX_XMIT_FRAG"
= "="
integer "4280"
assignment
constant "MAX_RECV_FRAG"
= "="
integer "4280"
comment "# Auth Levels"
comment "#[2.2.1.1.8 Authentication Levels](https://docs.microsoft.co"...
assignment
constant "RPC_C_AUTHN_LEVEL_DEFAULT"
= "="
integer "0"
assignment
constant "RPC_C_AUTHN_LEVEL_NONE"
= "="
integer "1"
assignment
constant "RPC_C_AUTHN_LEVEL_CONNECT"
= "="
integer "2"
assignment
constant "RPC_C_AUTHN_LEVEL_CALL"
= "="
integer "3"
assignment
constant "RPC_C_AUTHN_LEVEL_PKT"
= "="
integer "4"
assignment
constant "RPC_C_AUTHN_LEVEL_PKT_INTEGRITY"
= "="
integer "5"
assignment
constant "RPC_C_AUTHN_LEVEL_PKT_PRIVACY"
= "="
integer "6"
comment "## Auth Types"
comment "# [2.2.1.1.7 Security Providers](https://docs.microsoft.com/"...
assignment
constant "RPC_C_AUTHN_NONE"
= "="
integer "0x00"
assignment
constant "RPC_C_AUTHN_GSS_NEGOTIATE"
= "="
integer "0x09"
assignment
constant "RPC_C_AUTHN_WINNT"
= "="
integer "0x0A"
assignment
constant "RPC_C_AUTHN_GSS_SCHANNEL"
= "="
integer "0x0E"
assignment
constant "RPC_C_AUTHN_GSS_KERBEROS"
= "="
integer "0x10"
assignment
constant "RPC_C_AUTHN_NETLOGON"
= "="
integer "0x44"
assignment
constant "RPC_C_AUTHN_DEFAULT"
= "="
integer "0xFF"
comment "#[Authorisation Services](https://pubs.opengroup.org/onlinep"...
assignment
constant "DCE_C_AUTHZ_NAME"
= "="
integer "1"
assignment
constant "DCE_C_AUTHZ_DCE"
= "="
integer "2"
call
identifier "require"
argument_list
string
" "'"
string_content "windows_error/win32"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/client"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/error"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/fault"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/uuid"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/ndr"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/ptypes"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/p_syntax_id_t"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/rrp_rpc_unicode_string"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/rpc_security_attributes"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/pdu_header"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/srvsvc"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/svcctl"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/winreg"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/netlogon"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/samr"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/wkssvc"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/epm"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/drsr"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/sec_trailer"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/dfsnm"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/icpr"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/efsrpc"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/lsarpc"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/request"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/response"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/rpc_auth3"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/port_any_t"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/p_cont_list_t"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/p_result_t"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/p_result_list_t"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/alter_context"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/bind"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/bind_ack"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/alter_context_resp"
" "'"
call
identifier "require"
argument_list
string
" "'"
string_content "ruby_smb/dcerpc/print_system"
" "'"
comment "# Initialize the auth provider using NTLM. This function sho"...
comment "# @raise ArgumentError If @ntlm_client isn't initialized wit"...
comment "# @return Serialized message for initializing the auth provi"...
method (+28 nodes collapsed)
comment "# Encrypt the value in dcerpc_req.stub, and add a valid sign"...
comment "# This function modifies the request object in-place, and do"...
comment "# This function should be overriden for other providers (e.g"...
comment "# @param dcerpc_req [Request] The Request object to be encry"...
method (+229 nodes collapsed)
comment "# Get the response's full stub value (which will include the"...
comment "# @param dcerpc_response [Response] The Response object to e"...
comment "# @return [String] The full stub, including auth_pad"
method (+25 nodes collapsed)
comment "# Decrypt the value in dcerpc_req.stub, and validate its sig"...
comment "# This function modifies the request object in-place, and re"...
comment "# This function should be overriden for other providers (e.g"...
comment "# @param dcerpc_response [Response] The Response packet to d"...
comment "# @raise ArgumentError If the auth type is not NTLM"
comment "# @return [Boolean] Is the packet's signature valid?"
method (+177 nodes collapsed)
comment "# Completes local initialisation of @ntlm_client using the s"...
comment "#"
comment "# @param type2_message [String] NTLM type 2 message sent fro"...
comment "# @return [String] Type 3 message to be sent to the server t"...
method (+82 nodes collapsed)
comment "# Send a rpc_auth3 PDU that ends the authentication handshak"...
comment "# This function should be overriden for other providers (e.g"...
comment "#"
comment "# @param response [BindAck] the BindAck response packet"
comment "# @param options [Hash] Unused by the NTLM auth provider"
method (+61 nodes collapsed)
method
def "def"
identifier "force_set_auth_params"
method_parameters
( "("
identifier "auth_type"
, ","
identifier "auth_level"
) ")"
body_statement
assignment
instance_variable "@auth_type"
= "="
identifier "auth_type"
assignment
instance_variable "@auth_level"
= "="
identifier "auth_level"
end "end"
comment "# Bind to the remote server interface endpoint. It takes car"...
comment "# the necessary authentication verifier if `:auth_level` is "...
comment "# anything different than RPC_C_AUTHN_LEVEL_NONE"
comment "#"
comment "# @param [Hash] options"
comment "# @option options [Module] :endpoint the endpoint to bind to"...
comment "# class with UUID, VER_MAJOR and VER_MINOR constants defin"...
comment "# @option options [Integer] :auth_level the authentication l"...
comment "# @option options [Integer] :auth_type the authentication ty"...
comment "# @return [BindAck] the BindAck response packet"
comment "# @raise [Error::InvalidPacket] if an invalid packet is rece"...
comment "# @raise [Error::BindError] if the response is not a BindAck"...
comment "# @raise [ArgumentError] if `:auth_type` is unknown"
comment "# @raise [NotImplementedError] if `:auth_type` is not implem"...
method
def "def"
identifier "bind"
method_parameters
( "("
optional_parameter
identifier "options"
= "="
hash
{ "{"
} "}"
) ")"
body_statement
if_modifier
assignment
identifier "options"
= "="
call
identifier "options"
. "."
identifier "merge"
argument_list
( "("
pair
hash_key_symbol "endpoint"
: ":"
instance_variable "@endpoint"
) ")"
if "if"
binary
binary
unary
! "!"
element_reference
identifier "options"
[ "["
simple_symbol ":endpoint"
] "]"
&& "&&"
unary
defined? "defined?"
parenthesized_statements
( "("
simple_symbol ":@endpoint"
) ")"
&& "&&"
instance_variable "@endpoint"
operator_assignment
instance_variable "@call_id"
||= "||="
integer "1"
assignment
identifier "bind_req"
= "="
call
constant "Bind"
. "."
identifier "new"
argument_list
( "("
identifier "options"
) ")"
assignment
call
call
identifier "bind_req"
. "."
identifier "pdu_header"
. "."
identifier "call_id"
= "="
instance_variable "@call_id"
assignment
identifier "auth_type"
= "="
call
identifier "options"
. "."
identifier "fetch"
argument_list
( "("
simple_symbol ":auth_type"
) ")"
block
{ "{"
block_body
constant "RPC_C_AUTHN_WINNT"
} "}"
assignment
identifier "auth_level"
= "="
call
identifier "options"
. "."
identifier "fetch"
argument_list
( "("
simple_symbol ":auth_level"
) ")"
block
{ "{"
block_body
constant "RPC_C_AUTHN_LEVEL_NONE"
} "}"
call
identifier "force_set_auth_params"
argument_list
( "("
identifier "auth_type"
, ","
identifier "auth_level"
) ")"
if (+33 nodes collapsed)
call
identifier "send_packet"
argument_list
( "("
identifier "bind_req"
) ")"
begin (+28 nodes collapsed)
comment "# TODO: see if BindNack response should be handled too"
assignment
identifier "res_list"
= "="
call
identifier "dcerpc_response"
. "."
identifier "p_result_list"
if (+72 nodes collapsed)
assignment
call
self "self"
. "."
identifier "max_buffer_size"
= "="
call
identifier "dcerpc_response"
. "."
identifier "max_xmit_frag"
assignment
instance_variable "@call_id"
= "="
call
call
identifier "dcerpc_response"
. "."
identifier "pdu_header"
. "."
identifier "call_id"
if
if "if"
binary
identifier "auth_level"
!= "!="
constant "RPC_C_AUTHN_LEVEL_NONE"
comment "# The number of legs needed to build the security context is"...
comment "# by the security provider"
comment "# (see [2.2.1.1.7 Security Providers](https://learn.microsof"...
then
call
identifier "auth_provider_complete_handshake"
argument_list
( "("
identifier "dcerpc_response"
, ","
identifier "options"
) ")"
end "end"
identifier "dcerpc_response"
end "end"
method (+21 nodes collapsed)
comment "# Receive a packet from the remote host and parse it accordi"...
comment "#"
comment "# @param struct [Class] the structure class to parse the res"...
method (+84 nodes collapsed)
comment "# Send a packet to the remote host"
comment "#"
comment "# @param packet [BinData::Record] the packet to send"
comment "# @raise [Error::CommunicationError] if socket-related error"...
method (+23 nodes collapsed)
method (+25 nodes collapsed)
comment "# Add the authentication verifier to a Request packet. This "...
comment "# sec trailer and the signature of the packet. This also enc"...
comment "# Request stub if privacy is required (`:auth_level` option "...
comment "# RPC_C_AUTHN_LEVEL_PKT_PRIVACY)."
comment "#"
comment "# @param dcerpc_req [Request] the Request packet to be updat"...
comment "# @param opts [Hash] the authentication options: `:auth_type"...
comment "# @raise [NotImplementedError] if `:auth_type` is not implem"...
comment "# @raise [ArgumentError] if `:auth_type` is unknown"
method (+102 nodes collapsed)
method (+31 nodes collapsed)
method (+76 nodes collapsed)
method (+78 nodes collapsed)
comment "# Process the security context received in a response. It de"...
comment "# encrypted stub if `:auth_level` is set to anything differe"...
comment "# RPC_C_AUTHN_LEVEL_PKT_PRIVACY. It also checks the packet s"...
comment "# raises an InvalidPacket error if it fails. Note that the e"...
comment "# disabled by default and can be enabled with the"
comment "# `:raise_signature_error` option"
comment "#"
comment "# @param dcerpc_response [Response] the Response packet"
comment "# containing the security context to process"
comment "# @param opts [Hash] the authentication options: `:auth_type"...
comment "# `:auth_level`. To enable errors when signature check fai"...
comment "# `:raise_signature_error` option to true"
comment "# @raise [NotImplementedError] if `:auth_type` is not implem"...
comment "# @raise [Error::CommunicationError] if socket-related error"...
method (+94 nodes collapsed)
comment "# Add the authentication verifier to the packet. This includ"...
comment "# trailer and the actual authentication data."
comment "#"
comment "# @param req [BinData::Record] the request to be updated"
comment "# @param auth [String] the authentication data"
method (+59 nodes collapsed)
end "end"
end "end"