diff --git a/impacket/examples/secretsdump.py b/impacket/examples/secretsdump.py index 536a8fe19a..ceb34be89b 100644 --- a/impacket/examples/secretsdump.py +++ b/impacket/examples/secretsdump.py @@ -69,7 +69,7 @@ from impacket.ldap.ldap import SimplePagedResultsControl, LDAPSearchError from impacket.ldap.ldapasn1 import SearchResultEntry from impacket.dcerpc.v5 import transport, rrp, scmr, wkst, samr, epm, drsuapi -from impacket.dcerpc.v5.dtypes import NULL +from impacket.dcerpc.v5.dtypes import NULL, SID from impacket.dcerpc.v5.rpcrt import RPC_C_AUTHN_LEVEL_PKT_PRIVACY, DCERPCException, RPC_C_AUTHN_GSS_NEGOTIATE from impacket.dcerpc.v5.dcom import wmi from impacket.dcerpc.v5.dcom.oaut import IID_IDispatch, IDispatch, DISPPARAMS, DISPATCH_PROPERTYGET, \ @@ -535,7 +535,40 @@ def DRSCrackNames(self, formatOffered=drsuapi.DS_NAME_FORMAT.DS_DISPLAY_NAME, resp = drsuapi.hDRSCrackNames(self.__drsr, self.__hDrs, 0, formatOffered, formatDesired, (name,)) return resp - def DRSGetNCChanges(self, userEntry): + # Wrapper for calling _DRSGetNCChanges with a GUID + def DRSGetNCChangesGuid(self, userGuid): + dsName = drsuapi.DSNAME() + dsName['SidLen'] = 0 + dsName['Guid'] = string_to_bin(userGuid[1:-1]) + dsName['Sid'] = '' + dsName['NameLen'] = 0 + dsName['StringName'] = ('\x00') + dsName['structLen'] = len(dsName.getData()) + + return self._DRSGetNCChanges(userGuid, dsName) + + # Wrapper for calling _DRSGetNCChanges with a SID + def DRSGetNCChangesSid(self, userSid): + + # Convert string SID to 2.4.2.2 packet SID + tsid = SID() + tsid.fromCanonical(userSid) + packetSid = pack("