Class: NTLM::Message
- Inherits:
-
Object
show all
- Includes:
- Util
- Defined in:
- lib/ntlm/message.rb
Defined Under Namespace
Classes: Authenticate, Challenge, Negotiate, ParseError
Constant Summary
collapse
- SSP_SIGNATURE =
"NTLMSSP\0"
- FLAGS =
{
:NEGOTIATE_UNICODE => 0x00000001, :NEGOTIATE_OEM => 0x00000002, :REQUEST_TARGET => 0x00000004, :UNUSED10 => 0x00000008,
:NEGOTIATE_SIGN => 0x00000010, :NEGOTIATE_SEAL => 0x00000020, :NEGOTIATE_DATAGRAM => 0x00000040, :NEGOTIATE_LM_KEY => 0x00000080, :UNUSED9 => 0x00000100,
:NEGOTIATE_NTLM => 0x00000200, :UNUSED8 => 0x00000400,
:ANONYMOUS => 0x00000800, :OEM_DOMAIN_SUPPLIED => 0x00001000, :OEM_WORKSTATION_SUPPLIED => 0x00002000, :UNUSED7 => 0x00004000,
:NEGOTIATE_ALWAYS_SIGN => 0x00008000,
:TARGET_TYPE_DOMAIN => 0x00010000, :TARGET_TYPE_SERVER => 0x00020000, :UNUSED6 => 0x00040000,
:NEGOTIATE_EXTENDED_SECURITY => 0x00080000, :NEGOTIATE_IDENTIFY => 0x00100000, :UNUSED5 => 0x00200000,
:REQUEST_NON_NT_SESSION_KEY => 0x00400000, :NEGOTIATE_TARGET_INFO => 0x00800000, :UNUSED4 => 0x01000000,
:NEGOTIATE_VERSION => 0x02000000, :UNUSED3 => 0x04000000,
:UNUSED2 => 0x08000000,
:UNUSED1 => 0x10000000,
:NEGOTIATE_128 => 0x20000000, :NEGOTIATE_KEY_EXCH => 0x40000000, :NEGOTIATE_56 => 0x80000000, }
- AV_PAIRS =
{
:AV_EOL => 0,
:AV_NB_COMPUTER_NAME => 1,
:AV_NB_DOMAIN_NAME => 2,
:AV_DNS_COMPUTER_NAME => 3,
:AV_DNS_DOMAIN_NAME => 4,
:AV_DNS_TREE_NAME => 5,
:AV_FLAGS => 6,
:AV_TIMESTAMP => 7,
:AV_RESTRICTIONS => 8,
:AV_TARGET_NAME => 9,
:AV_CHANNEL_BINDINGS => 10,
}
- AV_PAIR_NAMES =
AV_PAIRS.invert
Constants included
from Util
Util::LM_MAGIC_TEXT
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Util
create_des_keys, #decode_utf16, #encode_utf16, encrypt, lm_v1_hash, nt_v1_hash, nt_v2_hash, ntlm_v1_response, ntlm_v2_response
Constructor Details
#initialize(args = {}) ⇒ Message
Returns a new instance of Message.
81
82
83
84
85
86
87
88
89
|
# File 'lib/ntlm/message.rb', line 81
def initialize(args = {})
@buffer = ''
@offset = 0
@flag = args[:flag] || self.class::DEFAULT_FLAGS
self.class::ATTRIBUTES.each do |key|
instance_variable_set("@#{key}", args[key]) if args[key]
end
end
|
Instance Attribute Details
#flag ⇒ Object
Returns the value of attribute flag.
74
75
76
|
# File 'lib/ntlm/message.rb', line 74
def flag
@flag
end
|
Class Method Details
.parse(*args) ⇒ Object
77
78
79
|
# File 'lib/ntlm/message.rb', line 77
def self.parse(*args)
new.parse(*args)
end
|
Instance Method Details
#clear(symbol) ⇒ Object
109
110
111
|
# File 'lib/ntlm/message.rb', line 109
def clear(symbol)
@flag &= ~FLAGS[symbol]
end
|
#has_flag?(symbol) ⇒ Boolean
101
102
103
|
# File 'lib/ntlm/message.rb', line 101
def has_flag?(symbol)
(@flag & FLAGS[symbol]) != 0
end
|
#inspect ⇒ Object
125
126
127
128
|
# File 'lib/ntlm/message.rb', line 125
def inspect
variables = (instance_variables.map(&:to_sym) - [:@offset, :@buffer, :@flag]).sort.map {|name| "#{name}=#{instance_variable_get(name).inspect}, " }.join
"\#<#{self.class.name} #{variables}@flag=#{inspect_flags}>"
end
|
#inspect_flags ⇒ Object
117
118
119
120
121
122
123
|
# File 'lib/ntlm/message.rb', line 117
def inspect_flags
flags = []
FLAGS.sort_by(&:last).each do |name, val|
flags << name if (@flag & val).nonzero?
end
"[#{flags.join(', ')}]"
end
|
#serialize_to_base64 ⇒ Object
Also known as:
to_base64
95
96
97
|
# File 'lib/ntlm/message.rb', line 95
def serialize_to_base64
[serialize].pack('m').delete("\r\n")
end
|
#set(symbol) ⇒ Object
105
106
107
|
# File 'lib/ntlm/message.rb', line 105
def set(symbol)
@flag |= FLAGS[symbol]
end
|
#to_s ⇒ Object
91
92
93
|
# File 'lib/ntlm/message.rb', line 91
def to_s
serialize
end
|
#unicode? ⇒ Boolean
113
114
115
|
# File 'lib/ntlm/message.rb', line 113
def unicode?
has_flag?(:NEGOTIATE_UNICODE)
end
|