CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/spec/lib/rex/proto/kerberos/model/ticket_spec.rb
Views: 11791
1
# -*- coding:binary -*-
2
require 'spec_helper'
3
4
5
RSpec.describe Rex::Proto::Kerberos::Model::Ticket do
6
7
subject(:ticket) do
8
described_class.new
9
end
10
11
=begin
12
#<OpenSSL::ASN1::ASN1Data:0x007f93b206ed78
13
@infinite_length=false,
14
@tag=1,
15
@tag_class=:APPLICATION,
16
@value=
17
[#<OpenSSL::ASN1::Sequence:0x007f93b206eda0
18
@infinite_length=false,
19
@tag=16,
20
@tag_class=:UNIVERSAL,
21
@tagging=nil,
22
@value=
23
[#<OpenSSL::ASN1::ASN1Data:0x007f93b2094ca8
24
@infinite_length=false,
25
@tag=0,
26
@tag_class=:CONTEXT_SPECIFIC,
27
@value=
28
[#<OpenSSL::ASN1::Integer:0x007f93b2094cd0
29
@infinite_length=false,
30
@tag=2,
31
@tag_class=:UNIVERSAL,
32
@tagging=nil,
33
@value=#<OpenSSL::BN:0x007f93b2094e10>>]>,
34
#<OpenSSL::ASN1::ASN1Data:0x007f93b2094b90
35
@infinite_length=false,
36
@tag=1,
37
@tag_class=:CONTEXT_SPECIFIC,
38
@value=
39
[#<OpenSSL::ASN1::GeneralString:0x007f93b2094bb8
40
@infinite_length=false,
41
@tag=27,
42
@tag_class=:UNIVERSAL,
43
@tagging=nil,
44
@value="DEMO.LOCAL">]>,
45
#<OpenSSL::ASN1::ASN1Data:0x007f93b2094078
46
@infinite_length=false,
47
@tag=2,
48
@tag_class=:CONTEXT_SPECIFIC,
49
@value=
50
[#<OpenSSL::ASN1::Sequence:0x007f93b2094230
51
@infinite_length=false,
52
@tag=16,
53
@tag_class=:UNIVERSAL,
54
@tagging=nil,
55
@value=
56
[#<OpenSSL::ASN1::ASN1Data:0x007f93b2094870
57
@infinite_length=false,
58
@tag=0,
59
@tag_class=:CONTEXT_SPECIFIC,
60
@value=
61
[#<OpenSSL::ASN1::Integer:0x007f93b20948c0
62
@infinite_length=false,
63
@tag=2,
64
@tag_class=:UNIVERSAL,
65
@tagging=nil,
66
@value=#<OpenSSL::BN:0x007f93b2094988>>]>,
67
#<OpenSSL::ASN1::ASN1Data:0x007f93b2094280
68
@infinite_length=false,
69
@tag=1,
70
@tag_class=:CONTEXT_SPECIFIC,
71
@value=
72
[#<OpenSSL::ASN1::Sequence:0x007f93b20943e8
73
@infinite_length=false,
74
@tag=16,
75
@tag_class=:UNIVERSAL,
76
@tagging=nil,
77
@value=
78
[#<OpenSSL::ASN1::GeneralString:0x007f93b20944d8
79
@infinite_length=false,
80
@tag=27,
81
@tag_class=:UNIVERSAL,
82
@tagging=nil,
83
@value="krbtgt">,
84
#<OpenSSL::ASN1::GeneralString:0x007f93b2094410
85
@infinite_length=false,
86
@tag=27,
87
@tag_class=:UNIVERSAL,
88
@tagging=nil,
89
@value="DEMO.LOCAL">]>]>]>]>,
90
#<OpenSSL::ASN1::ASN1Data:0x007f93b206f728
91
@infinite_length=false,
92
@tag=3,
93
@tag_class=:CONTEXT_SPECIFIC,
94
@value=
95
[#<OpenSSL::ASN1::Sequence:0x007f93b206f8e0
96
@infinite_length=false,
97
@tag=16,
98
@tag_class=:UNIVERSAL,
99
@tagging=nil,
100
@value=
101
[#<OpenSSL::ASN1::ASN1Data:0x007f93b206fbd8
102
@infinite_length=false,
103
@tag=0,
104
@tag_class=:CONTEXT_SPECIFIC,
105
@value=
106
[#<OpenSSL::ASN1::Integer:0x007f93b206fc28
107
@infinite_length=false,
108
@tag=2,
109
@tag_class=:UNIVERSAL,
110
@tagging=nil,
111
@value=#<OpenSSL::BN:0x007f93b206fc50>>]>,
112
#<OpenSSL::ASN1::ASN1Data:0x007f93b206fae8
113
@infinite_length=false,
114
@tag=1,
115
@tag_class=:CONTEXT_SPECIFIC,
116
@value=
117
[#<OpenSSL::ASN1::Integer:0x007f93b206fb60
118
@infinite_length=false,
119
@tag=2,
120
@tag_class=:UNIVERSAL,
121
@tagging=nil,
122
@value=#<OpenSSL::BN:0x007f93b206fb88>>]>,
123
#<OpenSSL::ASN1::ASN1Data:0x007f93b206f9f8
124
@infinite_length=false,
125
@tag=2,
126
@tag_class=:CONTEXT_SPECIFIC,
127
@value=
128
[#<OpenSSL::ASN1::OctetString:0x007f93b206fa20
129
@infinite_length=false,
130
@tag=4,
131
@tag_class=:UNIVERSAL,
132
@tagging=nil,
133
@value=
134
"U\xE7E\xC3o\xA2(G\xAB\x9C\x86\x13\xEB\x1D\xA8\x98\xECg\x1C\x1F\x15Fk\xE0J\xF2M=\xF7\xE41zO\x15/`\xDD\x98\xA8\xE1\x97ko\xC1$Fl\xA9\x1E\xE26'\xE3\xFA\x99\f\x9Bw\f\xE2X\x02h\xC4T*,]lK\xC8\xBC\x04\x8F\nD'x\xDCK>\x01\xBE\xAC\xF7\x8EzP\xC6>w\xD9e$\xD5\x1A\x18\xA1\x84q\x85\x98/T\x8BV\xE3\xFB,\xE20\x84\x06UU\xEA1\x8B\x84\x00\xE3\x1A\xC3\xA8\xC2\xAC\xC0x?Ght\xCCb\xA6\xCF\xF4k\xAE\xAF'\xDE\x1AM\xB7\xA8\x9Fvzy*B\x12{\xD2\xBE\xC9\x98|D8@\xBDI\xCD>\xDCe\xC7\x8BD\xF5\xA5\xD4f\x0E\xFDX\x9D19'\xD7\xFC\x81\a\xA3*\x1C<">]>]>]>]>]>
135
=end
136
let(:as_ticket) do
137
"\x61\x82\x01\x0c" +
138
"\x30\x82\x01\x08\xa0\x03\x02\x01\x05\xa1\x0c\x1b\x0a\x44\x45\x4d" +
139
"\x4f\x2e\x4c\x4f\x43\x41\x4c\xa2\x1f\x30\x1d\xa0\x03\x02\x01\x01" +
140
"\xa1\x16\x30\x14\x1b\x06\x6b\x72\x62\x74\x67\x74\x1b\x0a\x44\x45" +
141
"\x4d\x4f\x2e\x4c\x4f\x43\x41\x4c\xa3\x81\xd1\x30\x81\xce\xa0\x03" +
142
"\x02\x01\x17\xa1\x03\x02\x01\x02\xa2\x81\xc1\x04\x81\xbe\x55\xe7" +
143
"\x45\xc3\x6f\xa2\x28\x47\xab\x9c\x86\x13\xeb\x1d\xa8\x98\xec\x67" +
144
"\x1c\x1f\x15\x46\x6b\xe0\x4a\xf2\x4d\x3d\xf7\xe4\x31\x7a\x4f\x15" +
145
"\x2f\x60\xdd\x98\xa8\xe1\x97\x6b\x6f\xc1\x24\x46\x6c\xa9\x1e\xe2" +
146
"\x36\x27\xe3\xfa\x99\x0c\x9b\x77\x0c\xe2\x58\x02\x68\xc4\x54\x2a" +
147
"\x2c\x5d\x6c\x4b\xc8\xbc\x04\x8f\x0a\x44\x27\x78\xdc\x4b\x3e\x01" +
148
"\xbe\xac\xf7\x8e\x7a\x50\xc6\x3e\x77\xd9\x65\x24\xd5\x1a\x18\xa1" +
149
"\x84\x71\x85\x98\x2f\x54\x8b\x56\xe3\xfb\x2c\xe2\x30\x84\x06\x55" +
150
"\x55\xea\x31\x8b\x84\x00\xe3\x1a\xc3\xa8\xc2\xac\xc0\x78\x3f\x47" +
151
"\x68\x74\xcc\x62\xa6\xcf\xf4\x6b\xae\xaf\x27\xde\x1a\x4d\xb7\xa8" +
152
"\x9f\x76\x7a\x79\x2a\x42\x12\x7b\xd2\xbe\xc9\x98\x7c\x44\x38\x40" +
153
"\xbd\x49\xcd\x3e\xdc\x65\xc7\x8b\x44\xf5\xa5\xd4\x66\x0e\xfd\x58" +
154
"\x9d\x31\x39\x27\xd7\xfc\x81\x07\xa3\x2a\x1c\x3c"
155
end
156
157
describe "#decode" do
158
context "when decoding AS Response ticket" do
159
it "returns the Rex::Proto::Kerberos::Model::Ticket decoded" do
160
expect(ticket.decode(as_ticket)).to eq(ticket)
161
end
162
163
it "decodes tkt_vno correctly" do
164
ticket.decode(as_ticket)
165
expect(ticket.tkt_vno).to eq(5)
166
end
167
168
it "decodes realm correctly" do
169
ticket.decode(as_ticket)
170
expect(ticket.realm).to eq('DEMO.LOCAL')
171
end
172
173
it "decodes sname correctly" do
174
ticket.decode(as_ticket)
175
expect(ticket.sname.name_string).to eq(['krbtgt', 'DEMO.LOCAL'])
176
end
177
178
it "retrieves the encrypted part" do
179
ticket.decode(as_ticket)
180
expect(ticket.enc_part.cipher.length).to eq(190)
181
end
182
end
183
end
184
185
describe "#encode" do
186
context "when encoding TGS Request ticket" do
187
it "re-encodes the AS-RESP ticket correctly" do
188
ticket.decode(as_ticket)
189
expect(ticket.encode).to eq(as_ticket)
190
end
191
end
192
end
193
194
end
195
196