Skip to content

Commit

Permalink
fixing addentry structures
Browse files Browse the repository at this point in the history
  • Loading branch information
ShutdownRepo committed Feb 7, 2024
1 parent 0473b58 commit 83f8b7b
Showing 1 changed file with 45 additions and 5 deletions.
50 changes: 45 additions & 5 deletions impacket/dcerpc/v5/drsuapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@
from six import PY2

from impacket import LOG
from impacket.dcerpc.v5.ndr import NDRCALL, NDRSTRUCT, NDRPOINTER, NDRUniConformantArray, NDRUNION, NDR, NDRENUM, NDRUniFixedArray
from impacket.dcerpc.v5.ndr import NDRCALL, NDRSTRUCT, NDRPOINTER, NDRUniConformantArray, NDRUNION, NDR, NDRENUM, \
NDRUniFixedArray, NDRArray
from impacket.dcerpc.v5.dtypes import PUUID, DWORD, NULL, GUID, LPWSTR, BOOL, ULONG, UUID, LONGLONG, ULARGE_INTEGER, \
LARGE_INTEGER, ULONGLONG, LPCSTR, LPDWORD, SID, USHORT, ULONG_ARRAY, UCHAR, PRPC_UNICODE_STRING, FILETIME
LARGE_INTEGER, ULONGLONG, LPCSTR, USHORT, UCHAR, PRPC_UNICODE_STRING, FILETIME
from impacket import hresult_errors, system_errors
from impacket.structure import Structure
from impacket.uuid import uuidtup_to_bin, string_to_bin
Expand Down Expand Up @@ -809,8 +810,6 @@ def __getitem__(self, key):
return NDR.__getitem__(self, key)




class DSNAME(NDRSTRUCT):
structure = (
('structLen', ULONG),
Expand Down Expand Up @@ -843,7 +842,6 @@ class PPDSNAME_ARRAY(NDRPOINTER):
('Data', PDSNAME_ARRAY),
)


class ATTRTYP_ARRAY(NDRUniConformantArray):
item = ATTRTYP

Expand Down Expand Up @@ -1019,6 +1017,48 @@ class DRS_MSG_GETCHGREQ(NDRUNION):
}


# WCHAR ARRAY that's neither NDRUniConformantArray nor NDRUniConformantVaryingArray. This can most probably be better coded...
class WCHAR_ARRAY_BINARY(NDRArray):
item = 'H'

structure = (
# ('MaximumCount', '<L=len(Data)'),
('Data', '*MaximumCount'),
)

structure64 = (
# ('MaximumCount', '<Q=len(Data)'),
('Data', '*MaximumCount'),
)

def __setitem__(self, key, value):
self.fields['MaximumCount'] = None
self.data = None # force recompute
return NDRUniConformantArray.__setitem__(self, key, [ord(c) for c in value])

def __getitem__(self, key):
if key == 'Data':
try:
return ''.join([six.unichr(i) for i in self.fields[key]])
except ValueError as e:
LOG.debug("ValueError Exception", exc_info=True)
LOG.error(str(e))
else:
return NDR.__getitem__(self, key)


# 5.16.3.11 Object(DN-Binary)
class DSNAME_BINARY(DSNAME):
structure = (
('structLen', ULONG),
('SidLen', ULONG),
('Guid', GUID),
('Sid', NT4SID),
('NameLen', ULONG),
('StringName', WCHAR_ARRAY_BINARY),
)


# 5.16 ATTRVAL
class ATTRVAL(NDRSTRUCT):
structure = (
Expand Down

0 comments on commit 83f8b7b

Please sign in to comment.