@@ -198,8 +198,9 @@ def action_remove(obj)
198198 return
199199 end
200200
201+ delegate_from_sid = Rex ::Proto ::MsDtyp ::MsDtypSid . read ( delegate_from [ :objectSid ] . first )
201202 aces = security_descriptor . dacl . aces . snapshot
202- aces . delete_if { |ace | ace . body . sid == delegate_from [ :objectSid ] . first }
203+ aces . delete_if { |ace | ace . body . sid == delegate_from_sid }
203204 delta = security_descriptor . dacl . aces . length - aces . length
204205 if delta == 0
205206 print_status ( 'No DACL ACEs matched. No changes are necessary.' )
@@ -268,8 +269,10 @@ def _action_write_update(obj, delegate_from)
268269 vprint_status ( "Old #{ ATTRIBUTE } : #{ sddl } " )
269270 end
270271
272+ delegate_from_sid = Rex ::Proto ::MsDtyp ::MsDtypSid . read ( delegate_from [ :objectSid ] . first )
273+
271274 if security_descriptor . dacl
272- if security_descriptor . dacl . aces . any? { |ace | ace . body . sid == delegate_from [ :objectSid ] . first }
275+ if security_descriptor . dacl . aces . any? { |ace | ace . body . sid == delegate_from_sid }
273276 print_status ( "Delegation from #{ delegate_from [ :sAMAccountName ] . first } to #{ obj [ :sAMAccountName ] . first } is already configured." )
274277 end
275278 # clear these fields so they'll be calculated automatically after the update
@@ -281,7 +284,6 @@ def _action_write_update(obj, delegate_from)
281284 security_descriptor . dacl . acl_revision = Rex ::Proto ::MsDtyp ::MsDtypAcl ::ACL_REVISION_DS
282285 end
283286
284- delegate_from_sid = Rex ::Proto ::MsDtyp ::MsDtypSid . read ( delegate_from [ :objectSid ] . first )
285287 security_descriptor . dacl . aces << build_ace ( delegate_from_sid )
286288
287289 if ( sddl = sd_to_sddl ( security_descriptor ) )
0 commit comments