10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/ntlm_decoder.rb', line 10
def self.decode(string)
hex = to_hex(string)
tid = hex[60..-1].split("\x00")
domain_start = tid.index("\x02") + 2
domain_end = tid.index("\x01") - 1
server_start = tid.index("\x01") + 2
server_end = tid.index("\x04") - 1
dns_domain_start = tid.index("\x04") + 2
dns_domain_end = tid.index("\x03") - 1
dns_server_start = tid.index("\x03") + 2
begin
dns_server_end = tid.index("\x05") - 1
rescue NoMethodError
dns_server_end = -1
end
return {
domain: tid[domain_start..domain_end].join,
server: tid[server_start..server_end].join,
dns: tid[dns_domain_start..dns_domain_end].join,
fqdn: tid[dns_server_start..dns_server_end].join
}
end
|