Class: Rex::Proto::MsDtyp::MsDtypAccessMask
- Inherits:
-
BinData::Record
- Object
- BinData::Record
- Rex::Proto::MsDtyp::MsDtypAccessMask
- Defined in:
- lib/rex/proto/ms_dtyp.rb
Overview
Constant Summary collapse
- ALL =
MsDtypAccessMask.new({ gr: 1, gw: 1, gx: 1, ga: 1, ma: 1, as: 1, sy: 1, wo: 1, wd: 1, rc: 1, de: 1, protocol: 0xffff })
- NONE =
MsDtypAccessMask.new({ gr: 0, gw: 0, gx: 0, ga: 0, ma: 0, as: 0, sy: 0, wo: 0, wd: 0, rc: 0, de: 0, protocol: 0 })
Class Method Summary collapse
Instance Method Summary collapse
-
#permissions ⇒ Object
Obtain an array of the abbreviated names of permissions that the access mask specifies.
- #to_sddl_text ⇒ Object
Class Method Details
.from_sddl_text(sddl_text) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/rex/proto/ms_dtyp.rb', line 90 def self.from_sddl_text(sddl_text) if sddl_text =~ /\A0x[0-9a-fA-F]{1,8}\Z/ return self.read([sddl_text.delete_prefix('0x').to_i(16)].pack('L<')) end access_mask = self.new sddl_text.split(/(G[ARWX]|RC|SD|WD|WO|RP|WP|CC|DC|LC|SW|LO|DT|CR|F[ARWX]|K[ARWX]|N[RWX])/).each do |right| case right # generic access rights when 'GA', 'GR', 'GW', 'GX' access_mask.send("#{right.downcase}=", true) # standard access rights when 'RC' access_mask.rc = true when 'SD' access_mask.de = true when 'WD', 'WO' access_mask.send("#{right.downcase}=", true) # directory service object access rights when 'RP' access_mask.protocol |= 16 when 'WP' access_mask.protocol |= 32 when 'CC' access_mask.protocol |= 1 when 'DC' access_mask.protocol |= 2 when 'LC' access_mask.protocol |= 4 when 'SW' access_mask.protocol |= 8 when 'LO' access_mask.protocol |= 128 when 'DT' access_mask.protocol |= 64 when 'CR' access_mask.protocol |= 256 # file access rights when 'FA' access_mask.protocol |= 0x1ff access_mask.de = true access_mask.rc = true access_mask.wd = true access_mask.wo = true access_mask.sy = true when 'FR' access_mask.protocol |= 0x89 when 'FW' access_mask.protocol |= 0x116 when 'FX' access_mask.protocol |= 0xa0 # registry key access rights when 'KA' access_mask.protocol |= 0x3f access_mask.de = true access_mask.rc = true access_mask.wd = true access_mask.wo = true when 'KR' access_mask.protocol |= 0x19 when 'KW' access_mask.protocol |= 0x06 when 'KX' access_mask.protocol |= 0x19 when 'NR', 'NW', 'NX' raise SDDLParseError.new('unsupported ACE access right: ' + right) when '' else raise SDDLParseError.new('unknown ACE access right: ' + right) end end access_mask end |
Instance Method Details
#permissions ⇒ Object
Obtain an array of the abbreviated names of permissions that the access mask specifies.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/rex/proto/ms_dtyp.rb', line 41 def if (protocol & 0b1111111000000000) != 0 || ma == 1 || as == 1 return nil end = [] << :GA if ga == 1 << :GR if gr == 1 << :GW if gw == 1 << :GX if gx == 1 file_access_mask = protocol & 0b000111111111 << :FA if file_access_mask == 0b000111111111 && de == 1 && rc == 1 && wd == 1 && wo == 1 && sy == 1 << :FR if file_access_mask == 0b000010001001 << :FW if file_access_mask == 0b000100010110 << :FX if file_access_mask == 0b000010100000 # windows does not reduce registry access flags (i.e. KA, KR, KW) so ignore them here to match it << :CC if (protocol & 0b000000000001) != 0 && !.include?(:FA) && !.include?(:FR) << :DC if (protocol & 0b000000000010) != 0 && !.include?(:FA) && !.include?(:FW) << :LC if (protocol & 0b000000000100) != 0 && !.include?(:FA) && !.include?(:FW) << :SW if (protocol & 0b000000001000) != 0 && !.include?(:FA) && !.include?(:FR) << :RP if (protocol & 0b000000010000) != 0 && !.include?(:FA) && !.include?(:FW) << :WP if (protocol & 0b000000100000) != 0 && !.include?(:FA) && !.include?(:FX) << :DT if (protocol & 0b000001000000) != 0 && !.include?(:FA) << :LO if (protocol & 0b000010000000) != 0 && !.include?(:FA) << :CR if (protocol & 0b000100000000) != 0 && !.include?(:FA) << :SD if de == 1 && !.include?(:FA) << :RC if rc == 1 && !.include?(:FA) << :WD if wd == 1 && !.include?(:FA) << :WO if wo == 1 && !.include?(:FA) end |
#to_sddl_text ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/rex/proto/ms_dtyp.rb', line 78 def to_sddl_text perms = if perms.nil? # if one of these conditions are true, we can't reduce this to a set of flags so dump it as hex return "0x#{to_binary_s.unpack1('L<').to_s(16).rjust(8, '0')}" end .map(&:to_s).join end |