Skip to content

Commit e537804

Browse files
committed
Add the #to_sddl_text method for security descriptors
1 parent 31b8fad commit e537804

File tree

6 files changed

+913
-510
lines changed

6 files changed

+913
-510
lines changed

lib/rex/proto/ms_dtyp.rb

Lines changed: 413 additions & 315 deletions
Large diffs are not rendered by default.

lib/rex/proto/secauthz/well_known_sids.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module WellKnownSids
4242
SECURITY_BUILTIN_DOMAIN_SID = "#{SECURITY_NT_AUTHORITY}-32"
4343
SECURITY_WRITE_RESTRICTED_CODE_SID = "#{SECURITY_NT_AUTHORITY}-33"
4444

45-
SECURITY_USERMODEDRIVERHOST_ID_BASE_SID = "#{SECURITY_NT_AUTHORITY}-0"
45+
SECURITY_USERMODEDRIVERHOST_ID_BASE_SID = "S-1-5-84-0-0-0-0-0"
4646
SECURITY_ALL_APP_PACKAGES = 'S-1-15-2-1'
4747
SECURITY_MANDATORY_SYSTEM_SID = 'S-1-16-16384'
4848
SECURITY_AUTHENTICATION_SERVICE_ASSERTED_SID = "S-1-18-2"
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
RSpec.describe Rex::Proto::MsDtyp::MsDtypAccessMask do
2+
subject(:instance) { described_class.from_sddl_text(sddl_text) }
3+
4+
describe '.from_sddl_text' do
5+
context 'when the text is FA' do
6+
let(:sddl_text) { 'FA' }
7+
subject(:instance) { described_class.from_sddl_text(sddl_text) }
8+
9+
it 'sets the protocol to 0x1ff' do
10+
expect(instance.protocol).to eq 0x1ff
11+
end
12+
13+
it 'sets the de flag' do
14+
expect(instance.de).to eq 1
15+
end
16+
17+
it 'sets the rc flag' do
18+
expect(instance.rc).to eq 1
19+
end
20+
21+
it 'sets the wd flag' do
22+
expect(instance.wd).to eq 1
23+
end
24+
25+
it 'sets the wo flag' do
26+
expect(instance.wo).to eq 1
27+
end
28+
29+
it 'sets the sy flag' do
30+
expect(instance.sy).to eq 1
31+
end
32+
33+
it 'does not set the ma flag' do
34+
expect(instance.ma).to eq 0
35+
end
36+
37+
it 'does not set the as flag' do
38+
expect(instance.as).to eq 0
39+
end
40+
end
41+
42+
context 'when the text is KA' do
43+
let(:sddl_text) { 'KA' }
44+
45+
it 'sets the protocol to 0x3f' do
46+
expect(instance.protocol).to eq 0x3f
47+
end
48+
49+
it 'sets the de flag' do
50+
expect(instance.de).to eq 1
51+
end
52+
53+
it 'sets the rc flag' do
54+
expect(instance.rc).to eq 1
55+
end
56+
57+
it 'sets the wd flag' do
58+
expect(instance.wd).to eq 1
59+
end
60+
61+
it 'sets the wo flag' do
62+
expect(instance.wo).to eq 1
63+
end
64+
65+
it 'does not set the sy flag' do
66+
expect(instance.sy).to eq 0
67+
end
68+
69+
it 'does not set the ma flag' do
70+
expect(instance.ma).to eq 0
71+
end
72+
73+
it 'does not set the as flag' do
74+
expect(instance.as).to eq 0
75+
end
76+
end
77+
78+
context 'when the text is 0x00001234' do
79+
let(:sddl_text) { '0x00001234' }
80+
81+
it 'sets the protocol to 0x1234' do
82+
expect(instance.protocol).to eq 0x1234
83+
end
84+
end
85+
end
86+
87+
describe '#to_sddl_text' do
88+
context 'when high protocol bits are set' do
89+
subject(:instance) { described_class.new(protocol: 0x1234) }
90+
it 'dumps the value in hex' do
91+
expect(instance.to_sddl_text).to eq "0x00001234"
92+
end
93+
end
94+
end
95+
end

0 commit comments

Comments
 (0)