-
Notifications
You must be signed in to change notification settings - Fork 67
/
nrpc.py
2873 lines (2534 loc) · 91.6 KB
/
nrpc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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
77
78
79
80
81
82
83
84
85
86
87
88
89
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# SECUREAUTH LABS. Copyright 2018 SecureAuth Corporation. All rights reserved.
#
# This software is provided under under a slightly modified version
# of the Apache Software License. See the accompanying LICENSE file
# for more information.
#
# Author: Alberto Solino (@agsolino)
#
# Description:
# [MS-NRPC] Interface implementation
#
# Best way to learn how to use these calls is to grab the protocol standard
# so you understand what the call does, and then read the test case located
# at https://github.com/SecureAuthCorp/impacket/tree/master/tests/SMB_RPC
#
# Some calls have helper functions, which makes it even easier to use.
# They are located at the end of this file.
# Helper functions start with "h"<name of the call>.
# There are test cases for them too.
#
from struct import pack
from six import b
from impacket.dcerpc.v5.ndr import NDRCALL, NDRSTRUCT, NDRENUM, NDRUNION, NDRPOINTER, NDRUniConformantArray, \
NDRUniFixedArray, NDRUniConformantVaryingArray
from impacket.dcerpc.v5.dtypes import WSTR, LPWSTR, DWORD, ULONG, USHORT, PGUID, NTSTATUS, NULL, LONG, UCHAR, PRPC_SID, \
GUID, RPC_UNICODE_STRING, SECURITY_INFORMATION, LPULONG
from impacket import system_errors, nt_errors
from impacket.uuid import uuidtup_to_bin
from impacket.dcerpc.v5.enum import Enum
from impacket.dcerpc.v5.samr import OLD_LARGE_INTEGER
from impacket.dcerpc.v5.lsad import PLSA_FOREST_TRUST_INFORMATION
from impacket.dcerpc.v5.rpcrt import DCERPCException
from impacket.structure import Structure
from impacket import ntlm, crypto, LOG
import hmac
import hashlib
try:
from Cryptodome.Cipher import DES, AES, ARC4
except ImportError:
LOG.critical("Warning: You don't have any crypto installed. You need pycryptodomex")
LOG.critical("See https://pypi.org/project/pycryptodomex/")
MSRPC_UUID_NRPC = uuidtup_to_bin(('12345678-1234-ABCD-EF00-01234567CFFB', '1.0'))
class DCERPCSessionError(DCERPCException):
def __init__(self, error_string=None, error_code=None, packet=None):
DCERPCException.__init__(self, error_string, error_code, packet)
def __str__( self ):
key = self.error_code
if key in system_errors.ERROR_MESSAGES:
error_msg_short = system_errors.ERROR_MESSAGES[key][0]
error_msg_verbose = system_errors.ERROR_MESSAGES[key][1]
return 'NRPC SessionError: code: 0x%x - %s - %s' % (self.error_code, error_msg_short, error_msg_verbose)
elif key in nt_errors.ERROR_MESSAGES:
error_msg_short = nt_errors.ERROR_MESSAGES[key][0]
error_msg_verbose = nt_errors.ERROR_MESSAGES[key][1]
return 'NRPC SessionError: code: 0x%x - %s - %s' % (self.error_code, error_msg_short, error_msg_verbose)
else:
return 'NRPC SessionError: unknown error code: 0x%x' % (self.error_code)
################################################################################
# CONSTANTS
################################################################################
# 2.2.1.2.5 NL_DNS_NAME_INFO
# Type
NlDnsLdapAtSite = 22
NlDnsGcAtSite = 25
NlDnsDsaCname = 28
NlDnsKdcAtSite = 30
NlDnsDcAtSite = 32
NlDnsRfc1510KdcAtSite = 34
NlDnsGenericGcAtSite = 36
# DnsDomainInfoType
NlDnsDomainName = 1
NlDnsDomainNameAlias = 2
NlDnsForestName = 3
NlDnsForestNameAlias = 4
NlDnsNdncDomainName = 5
NlDnsRecordName = 6
# 2.2.1.3.15 NL_OSVERSIONINFO_V1
# wSuiteMask
VER_SUITE_BACKOFFICE = 0x00000004
VER_SUITE_BLADE = 0x00000400
VER_SUITE_COMPUTE_SERVER = 0x00004000
VER_SUITE_DATACENTER = 0x00000080
VER_SUITE_ENTERPRISE = 0x00000002
VER_SUITE_EMBEDDEDNT = 0x00000040
VER_SUITE_PERSONAL = 0x00000200
VER_SUITE_SINGLEUSERTS = 0x00000100
VER_SUITE_SMALLBUSINESS = 0x00000001
VER_SUITE_SMALLBUSINESS_RESTRICTED = 0x00000020
VER_SUITE_STORAGE_SERVER = 0x00002000
VER_SUITE_TERMINAL = 0x00000010
# wProductType
VER_NT_DOMAIN_CONTROLLER = 0x00000002
VER_NT_SERVER = 0x00000003
VER_NT_WORKSTATION = 0x00000001
# 2.2.1.4.18 NETLOGON Specific Access Masks
NETLOGON_UAS_LOGON_ACCESS = 0x0001
NETLOGON_UAS_LOGOFF_ACCESS = 0x0002
NETLOGON_CONTROL_ACCESS = 0x0004
NETLOGON_QUERY_ACCESS = 0x0008
NETLOGON_SERVICE_ACCESS = 0x0010
NETLOGON_FTINFO_ACCESS = 0x0020
NETLOGON_WKSTA_RPC_ACCESS = 0x0040
# 3.5.4.9.1 NetrLogonControl2Ex (Opnum 18)
# FunctionCode
NETLOGON_CONTROL_QUERY = 0x00000001
NETLOGON_CONTROL_REPLICATE = 0x00000002
NETLOGON_CONTROL_SYNCHRONIZE = 0x00000003
NETLOGON_CONTROL_PDC_REPLICATE = 0x00000004
NETLOGON_CONTROL_REDISCOVER = 0x00000005
NETLOGON_CONTROL_TC_QUERY = 0x00000006
NETLOGON_CONTROL_TRANSPORT_NOTIFY = 0x00000007
NETLOGON_CONTROL_FIND_USER = 0x00000008
NETLOGON_CONTROL_CHANGE_PASSWORD = 0x00000009
NETLOGON_CONTROL_TC_VERIFY = 0x0000000A
NETLOGON_CONTROL_FORCE_DNS_REG = 0x0000000B
NETLOGON_CONTROL_QUERY_DNS_REG = 0x0000000C
NETLOGON_CONTROL_BACKUP_CHANGE_LOG = 0x0000FFFC
NETLOGON_CONTROL_TRUNCATE_LOG = 0x0000FFFD
NETLOGON_CONTROL_SET_DBFLAG = 0x0000FFFE
NETLOGON_CONTROL_BREAKPOINT = 0x0000FFFF
################################################################################
# STRUCTURES
################################################################################
# 3.5.4.1 RPC Binding Handles for Netlogon Methods
LOGONSRV_HANDLE = WSTR
PLOGONSRV_HANDLE = LPWSTR
# 2.2.1.1.1 CYPHER_BLOCK
class CYPHER_BLOCK(NDRSTRUCT):
structure = (
('Data', '8s=b""'),
)
def getAlignment(self):
return 1
NET_API_STATUS = DWORD
# 2.2.1.1.2 STRING
from impacket.dcerpc.v5.lsad import STRING
# 2.2.1.1.3 LM_OWF_PASSWORD
class CYPHER_BLOCK_ARRAY(NDRUniFixedArray):
def getDataLen(self, data):
return len(CYPHER_BLOCK())*2
class LM_OWF_PASSWORD(NDRSTRUCT):
structure = (
('Data', CYPHER_BLOCK_ARRAY),
)
# 2.2.1.1.4 NT_OWF_PASSWORD
NT_OWF_PASSWORD = LM_OWF_PASSWORD
ENCRYPTED_NT_OWF_PASSWORD = NT_OWF_PASSWORD
# 2.2.1.3.4 NETLOGON_CREDENTIAL
class UCHAR_FIXED_ARRAY(NDRUniFixedArray):
align = 1
def getDataLen(self, data):
return len(CYPHER_BLOCK())
class NETLOGON_CREDENTIAL(NDRSTRUCT):
structure = (
('Data',UCHAR_FIXED_ARRAY),
)
def getAlignment(self):
return 1
# 2.2.1.1.5 NETLOGON_AUTHENTICATOR
class NETLOGON_AUTHENTICATOR(NDRSTRUCT):
structure = (
('Credential', NETLOGON_CREDENTIAL),
('Timestamp', DWORD),
)
class PNETLOGON_AUTHENTICATOR(NDRPOINTER):
referent = (
('Data', NETLOGON_AUTHENTICATOR),
)
# 2.2.1.2.1 DOMAIN_CONTROLLER_INFOW
class DOMAIN_CONTROLLER_INFOW(NDRSTRUCT):
structure = (
('DomainControllerName', LPWSTR),
('DomainControllerAddress', LPWSTR),
('DomainControllerAddressType', ULONG),
('DomainGuid', GUID),
('DomainName', LPWSTR),
('DnsForestName', LPWSTR),
('Flags', ULONG),
('DcSiteName', LPWSTR),
('ClientSiteName', LPWSTR),
)
class PDOMAIN_CONTROLLER_INFOW(NDRPOINTER):
referent = (
('Data', DOMAIN_CONTROLLER_INFOW),
)
# 2.2.1.2.2 NL_SITE_NAME_ARRAY
class RPC_UNICODE_STRING_ARRAY(NDRUniConformantArray):
item = RPC_UNICODE_STRING
class PRPC_UNICODE_STRING_ARRAY(NDRPOINTER):
referent = (
('Data', RPC_UNICODE_STRING_ARRAY),
)
class NL_SITE_NAME_ARRAY(NDRSTRUCT):
structure = (
('EntryCount', ULONG),
('SiteNames', PRPC_UNICODE_STRING_ARRAY),
)
class PNL_SITE_NAME_ARRAY(NDRPOINTER):
referent = (
('Data', NL_SITE_NAME_ARRAY),
)
# 2.2.1.2.3 NL_SITE_NAME_EX_ARRAY
class RPC_UNICODE_STRING_ARRAY(NDRUniConformantArray):
item = RPC_UNICODE_STRING
class NL_SITE_NAME_EX_ARRAY(NDRSTRUCT):
structure = (
('EntryCount', ULONG),
('SiteNames', PRPC_UNICODE_STRING_ARRAY),
('SubnetNames', PRPC_UNICODE_STRING_ARRAY),
)
class PNL_SITE_NAME_EX_ARRAY(NDRPOINTER):
referent = (
('Data', NL_SITE_NAME_EX_ARRAY),
)
# 2.2.1.2.4 NL_SOCKET_ADDRESS
# 2.2.1.2.4.1 IPv4 Address Structure
class IPv4Address(Structure):
structure = (
('AddressFamily', '<H=0'),
('Port', '<H=0'),
('Address', '<L=0'),
('Padding', '<L=0'),
)
class UCHAR_ARRAY(NDRUniConformantArray):
item = 'c'
class PUCHAR_ARRAY(NDRPOINTER):
referent = (
('Data', UCHAR_ARRAY),
)
class NL_SOCKET_ADDRESS(NDRSTRUCT):
structure = (
('lpSockaddr', PUCHAR_ARRAY),
('iSockaddrLength', ULONG),
)
class NL_SOCKET_ADDRESS_ARRAY(NDRUniConformantArray):
item = NL_SOCKET_ADDRESS
# 2.2.1.2.5 NL_DNS_NAME_INFO
class NL_DNS_NAME_INFO(NDRSTRUCT):
structure = (
('Type', ULONG),
('DnsDomainInfoType', WSTR),
('Priority', ULONG),
('Weight', ULONG),
('Port', ULONG),
('Register', UCHAR),
('Status', ULONG),
)
# 2.2.1.2.6 NL_DNS_NAME_INFO_ARRAY
class NL_DNS_NAME_INFO_ARRAY(NDRUniConformantArray):
item = NL_DNS_NAME_INFO
class PNL_DNS_NAME_INFO_ARRAY(NDRPOINTER):
referent = (
('Data', NL_DNS_NAME_INFO_ARRAY),
)
class NL_DNS_NAME_INFO_ARRAY(NDRSTRUCT):
structure = (
('EntryCount', ULONG),
('DnsNamesInfo', PNL_DNS_NAME_INFO_ARRAY),
)
# 2.2.1.3 Secure Channel Establishment and Maintenance Structures
# ToDo
# 2.2.1.3.5 NETLOGON_LSA_POLICY_INFO
class NETLOGON_LSA_POLICY_INFO(NDRSTRUCT):
structure = (
('LsaPolicySize', ULONG),
('LsaPolicy', PUCHAR_ARRAY),
)
class PNETLOGON_LSA_POLICY_INFO(NDRPOINTER):
referent = (
('Data', NETLOGON_LSA_POLICY_INFO),
)
# 2.2.1.3.6 NETLOGON_WORKSTATION_INFO
class NETLOGON_WORKSTATION_INFO(NDRSTRUCT):
structure = (
('LsaPolicy', NETLOGON_LSA_POLICY_INFO),
('DnsHostName', LPWSTR),
('SiteName', LPWSTR),
('Dummy1', LPWSTR),
('Dummy2', LPWSTR),
('Dummy3', LPWSTR),
('Dummy4', LPWSTR),
('OsVersion', RPC_UNICODE_STRING),
('OsName', RPC_UNICODE_STRING),
('DummyString3', RPC_UNICODE_STRING),
('DummyString4', RPC_UNICODE_STRING),
('WorkstationFlags', ULONG),
('KerberosSupportedEncryptionTypes', ULONG),
('DummyLong3', ULONG),
('DummyLong4', ULONG),
)
class PNETLOGON_WORKSTATION_INFO(NDRPOINTER):
referent = (
('Data', NETLOGON_WORKSTATION_INFO),
)
# 2.2.1.3.7 NL_TRUST_PASSWORD
class WCHAR_ARRAY(NDRUniFixedArray):
def getDataLen(self, data):
return 512
class NL_TRUST_PASSWORD(NDRSTRUCT):
structure = (
('Buffer', WCHAR_ARRAY),
('Length', LPWSTR),
)
# 2.2.1.3.8 NL_PASSWORD_VERSION
class NL_PASSWORD_VERSION(NDRSTRUCT):
structure = (
('ReservedField', ULONG),
('PasswordVersionNumber', ULONG),
('PasswordVersionPresent', ULONG),
)
# 2.2.1.3.9 NETLOGON_WORKSTATION_INFORMATION
class NETLOGON_WORKSTATION_INFORMATION(NDRUNION):
commonHdr = (
('tag', DWORD),
)
union = {
1 : ('WorkstationInfo', PNETLOGON_WORKSTATION_INFO),
2 : ('LsaPolicyInfo', PNETLOGON_LSA_POLICY_INFO),
}
# 2.2.1.3.10 NETLOGON_ONE_DOMAIN_INFO
class NETLOGON_ONE_DOMAIN_INFO(NDRSTRUCT):
structure = (
('DomainName', RPC_UNICODE_STRING),
('DnsDomainName', RPC_UNICODE_STRING),
('DnsForestName', RPC_UNICODE_STRING),
('DomainGuid', GUID),
('DomainSid', PRPC_SID),
('TrustExtension', RPC_UNICODE_STRING),
('DummyString2', RPC_UNICODE_STRING),
('DummyString3', RPC_UNICODE_STRING),
('DummyString4', RPC_UNICODE_STRING),
('DummyLong1', ULONG),
('DummyLong2', ULONG),
('DummyLong3', ULONG),
('DummyLong4', ULONG),
)
class NETLOGON_ONE_DOMAIN_INFO_ARRAY(NDRUniConformantArray):
item = NETLOGON_ONE_DOMAIN_INFO
class PNETLOGON_ONE_DOMAIN_INFO_ARRAY(NDRPOINTER):
referent = (
('Data', NETLOGON_ONE_DOMAIN_INFO_ARRAY),
)
# 2.2.1.3.11 NETLOGON_DOMAIN_INFO
class NETLOGON_DOMAIN_INFO(NDRSTRUCT):
structure = (
('PrimaryDomain', NETLOGON_ONE_DOMAIN_INFO),
('TrustedDomainCount', ULONG),
('TrustedDomains', PNETLOGON_ONE_DOMAIN_INFO_ARRAY),
('LsaPolicy', NETLOGON_LSA_POLICY_INFO),
('DnsHostNameInDs', RPC_UNICODE_STRING),
('DummyString2', RPC_UNICODE_STRING),
('DummyString3', RPC_UNICODE_STRING),
('DummyString4', RPC_UNICODE_STRING),
('WorkstationFlags', ULONG),
('SupportedEncTypes', ULONG),
('DummyLong3', ULONG),
('DummyLong4', ULONG),
)
class PNETLOGON_DOMAIN_INFO(NDRPOINTER):
referent = (
('Data', NETLOGON_DOMAIN_INFO),
)
# 2.2.1.3.12 NETLOGON_DOMAIN_INFORMATION
class NETLOGON_DOMAIN_INFORMATION(NDRUNION):
commonHdr = (
('tag', DWORD),
)
union = {
1 : ('DomainInfo', PNETLOGON_DOMAIN_INFO),
2 : ('LsaPolicyInfo', PNETLOGON_LSA_POLICY_INFO),
}
# 2.2.1.3.13 NETLOGON_SECURE_CHANNEL_TYPE
class NETLOGON_SECURE_CHANNEL_TYPE(NDRENUM):
class enumItems(Enum):
NullSecureChannel = 0
MsvApSecureChannel = 1
WorkstationSecureChannel = 2
TrustedDnsDomainSecureChannel = 3
TrustedDomainSecureChannel = 4
UasServerSecureChannel = 5
ServerSecureChannel = 6
CdcServerSecureChannel = 7
# 2.2.1.3.14 NETLOGON_CAPABILITIES
class NETLOGON_CAPABILITIES(NDRUNION):
commonHdr = (
('tag', DWORD),
)
union = {
1 : ('ServerCapabilities', ULONG),
}
# 2.2.1.3.15 NL_OSVERSIONINFO_V1
class UCHAR_FIXED_ARRAY(NDRUniFixedArray):
def getDataLen(self, data):
return 128
class NL_OSVERSIONINFO_V1(NDRSTRUCT):
structure = (
('dwOSVersionInfoSize', DWORD),
('dwMajorVersion', DWORD),
('dwMinorVersion', DWORD),
('dwBuildNumber', DWORD),
('dwPlatformId', DWORD),
('szCSDVersion', UCHAR_FIXED_ARRAY),
('wServicePackMajor', USHORT),
('wServicePackMinor', USHORT),
('wSuiteMask', USHORT),
('wProductType', UCHAR),
('wReserved', UCHAR),
)
class PNL_OSVERSIONINFO_V1(NDRPOINTER):
referent = (
('Data', NL_OSVERSIONINFO_V1),
)
# 2.2.1.3.16 NL_IN_CHAIN_SET_CLIENT_ATTRIBUTES_V1
class PLPWSTR(NDRPOINTER):
referent = (
('Data', LPWSTR),
)
class NL_IN_CHAIN_SET_CLIENT_ATTRIBUTES_V1(NDRSTRUCT):
structure = (
('ClientDnsHostName', PLPWSTR),
('OsVersionInfo', PNL_OSVERSIONINFO_V1),
('OsName', PLPWSTR),
)
# 2.2.1.3.17 NL_IN_CHAIN_SET_CLIENT_ATTRIBUTES
class NL_IN_CHAIN_SET_CLIENT_ATTRIBUTES(NDRUNION):
commonHdr = (
('tag', DWORD),
)
union = {
1 : ('V1', NL_IN_CHAIN_SET_CLIENT_ATTRIBUTES_V1),
}
# 2.2.1.3.18 NL_OUT_CHAIN_SET_CLIENT_ATTRIBUTES_V1
class NL_OUT_CHAIN_SET_CLIENT_ATTRIBUTES_V1(NDRSTRUCT):
structure = (
('HubName', PLPWSTR),
('OldDnsHostName', PLPWSTR),
('SupportedEncTypes', LPULONG),
)
# 2.2.1.3.19 NL_OUT_CHAIN_SET_CLIENT_ATTRIBUTES
class NL_OUT_CHAIN_SET_CLIENT_ATTRIBUTES(NDRUNION):
commonHdr = (
('tag', DWORD),
)
union = {
1 : ('V1', NL_OUT_CHAIN_SET_CLIENT_ATTRIBUTES_V1),
}
# 2.2.1.4.1 LM_CHALLENGE
class CHAR_FIXED_8_ARRAY(NDRUniFixedArray):
def getDataLen(self, data):
return 8
class LM_CHALLENGE(NDRSTRUCT):
structure = (
('Data', CHAR_FIXED_8_ARRAY),
)
# 2.2.1.4.15 NETLOGON_LOGON_IDENTITY_INFO
class NETLOGON_LOGON_IDENTITY_INFO(NDRSTRUCT):
structure = (
('LogonDomainName', RPC_UNICODE_STRING),
('ParameterControl', ULONG),
('Reserved', OLD_LARGE_INTEGER),
('UserName', RPC_UNICODE_STRING),
('Workstation', RPC_UNICODE_STRING),
)
class PNETLOGON_LOGON_IDENTITY_INFO(NDRPOINTER):
referent = (
('Data', NETLOGON_LOGON_IDENTITY_INFO),
)
# 2.2.1.4.2 NETLOGON_GENERIC_INFO
class NETLOGON_GENERIC_INFO(NDRSTRUCT):
structure = (
('Identity', NETLOGON_LOGON_IDENTITY_INFO),
('PackageName', RPC_UNICODE_STRING),
('DataLength', ULONG),
('LogonData', PUCHAR_ARRAY),
)
class PNETLOGON_GENERIC_INFO(NDRPOINTER):
referent = (
('Data', NETLOGON_GENERIC_INFO),
)
# 2.2.1.4.3 NETLOGON_INTERACTIVE_INFO
class NETLOGON_INTERACTIVE_INFO(NDRSTRUCT):
structure = (
('Identity', NETLOGON_LOGON_IDENTITY_INFO),
('LmOwfPassword', LM_OWF_PASSWORD),
('NtOwfPassword', NT_OWF_PASSWORD),
)
class PNETLOGON_INTERACTIVE_INFO(NDRPOINTER):
referent = (
('Data', NETLOGON_INTERACTIVE_INFO),
)
# 2.2.1.4.4 NETLOGON_SERVICE_INFO
class NETLOGON_SERVICE_INFO(NDRSTRUCT):
structure = (
('Identity', NETLOGON_LOGON_IDENTITY_INFO),
('LmOwfPassword', LM_OWF_PASSWORD),
('NtOwfPassword', NT_OWF_PASSWORD),
)
class PNETLOGON_SERVICE_INFO(NDRPOINTER):
referent = (
('Data', NETLOGON_SERVICE_INFO),
)
# 2.2.1.4.5 NETLOGON_NETWORK_INFO
class NETLOGON_NETWORK_INFO(NDRSTRUCT):
structure = (
('Identity', NETLOGON_LOGON_IDENTITY_INFO),
('LmChallenge', LM_CHALLENGE),
('NtChallengeResponse', STRING),
('LmChallengeResponse', STRING),
)
class PNETLOGON_NETWORK_INFO(NDRPOINTER):
referent = (
('Data', NETLOGON_NETWORK_INFO),
)
# 2.2.1.4.16 NETLOGON_LOGON_INFO_CLASS
class NETLOGON_LOGON_INFO_CLASS(NDRENUM):
class enumItems(Enum):
NetlogonInteractiveInformation = 1
NetlogonNetworkInformation = 2
NetlogonServiceInformation = 3
NetlogonGenericInformation = 4
NetlogonInteractiveTransitiveInformation = 5
NetlogonNetworkTransitiveInformation = 6
NetlogonServiceTransitiveInformation = 7
# 2.2.1.4.6 NETLOGON_LEVEL
class NETLOGON_LEVEL(NDRUNION):
union = {
NETLOGON_LOGON_INFO_CLASS.NetlogonInteractiveInformation : ('LogonInteractive', PNETLOGON_INTERACTIVE_INFO),
NETLOGON_LOGON_INFO_CLASS.NetlogonInteractiveTransitiveInformation : ('LogonInteractiveTransitive', PNETLOGON_INTERACTIVE_INFO),
NETLOGON_LOGON_INFO_CLASS.NetlogonServiceInformation : ('LogonService', PNETLOGON_SERVICE_INFO),
NETLOGON_LOGON_INFO_CLASS.NetlogonServiceTransitiveInformation : ('LogonServiceTransitive', PNETLOGON_SERVICE_INFO),
NETLOGON_LOGON_INFO_CLASS.NetlogonNetworkInformation : ('LogonNetwork', PNETLOGON_NETWORK_INFO),
NETLOGON_LOGON_INFO_CLASS.NetlogonNetworkTransitiveInformation : ('LogonNetworkTransitive', PNETLOGON_NETWORK_INFO),
NETLOGON_LOGON_INFO_CLASS.NetlogonGenericInformation : ('LogonGeneric', PNETLOGON_GENERIC_INFO),
}
# 2.2.1.4.7 NETLOGON_SID_AND_ATTRIBUTES
class NETLOGON_SID_AND_ATTRIBUTES(NDRSTRUCT):
structure = (
('Sid', PRPC_SID),
('Attributes', ULONG),
)
# 2.2.1.4.8 NETLOGON_VALIDATION_GENERIC_INFO2
class NETLOGON_VALIDATION_GENERIC_INFO2(NDRSTRUCT):
structure = (
('DataLength', ULONG),
('ValidationData', PUCHAR_ARRAY),
)
class PNETLOGON_VALIDATION_GENERIC_INFO2(NDRPOINTER):
referent = (
('Data', NETLOGON_VALIDATION_GENERIC_INFO2),
)
# 2.2.1.4.9 USER_SESSION_KEY
USER_SESSION_KEY = LM_OWF_PASSWORD
# 2.2.1.4.10 GROUP_MEMBERSHIP
class GROUP_MEMBERSHIP(NDRSTRUCT):
structure = (
('RelativeId', ULONG),
('Attributes', ULONG),
)
class GROUP_MEMBERSHIP_ARRAY(NDRUniConformantArray):
item = GROUP_MEMBERSHIP
class PGROUP_MEMBERSHIP_ARRAY(NDRPOINTER):
referent = (
('Data', GROUP_MEMBERSHIP_ARRAY),
)
# 2.2.1.4.11 NETLOGON_VALIDATION_SAM_INFO
class LONG_ARRAY(NDRUniFixedArray):
def getDataLen(self, data):
return 4*10
class NETLOGON_VALIDATION_SAM_INFO(NDRSTRUCT):
structure = (
('LogonTime', OLD_LARGE_INTEGER),
('LogoffTime', OLD_LARGE_INTEGER),
('KickOffTime', OLD_LARGE_INTEGER),
('PasswordLastSet', OLD_LARGE_INTEGER),
('PasswordCanChange', OLD_LARGE_INTEGER),
('PasswordMustChange', OLD_LARGE_INTEGER),
('EffectiveName', RPC_UNICODE_STRING),
('FullName', RPC_UNICODE_STRING),
('LogonScript', RPC_UNICODE_STRING),
('ProfilePath', RPC_UNICODE_STRING),
('HomeDirectory', RPC_UNICODE_STRING),
('HomeDirectoryDrive', RPC_UNICODE_STRING),
('LogonCount', USHORT),
('BadPasswordCount', USHORT),
('UserId', ULONG),
('PrimaryGroupId', ULONG),
('GroupCount', ULONG),
('GroupIds', PGROUP_MEMBERSHIP_ARRAY),
('UserFlags', ULONG),
('UserSessionKey', USER_SESSION_KEY),
('LogonServer', RPC_UNICODE_STRING),
('LogonDomainName', RPC_UNICODE_STRING),
('LogonDomainId', PRPC_SID),
('ExpansionRoom', LONG_ARRAY),
)
class PNETLOGON_VALIDATION_SAM_INFO(NDRPOINTER):
referent = (
('Data', NETLOGON_VALIDATION_SAM_INFO),
)
# 2.2.1.4.12 NETLOGON_VALIDATION_SAM_INFO2
class NETLOGON_SID_AND_ATTRIBUTES_ARRAY(NDRUniConformantArray):
item = NETLOGON_SID_AND_ATTRIBUTES
class PNETLOGON_SID_AND_ATTRIBUTES_ARRAY(NDRPOINTER):
referent = (
('Data', NETLOGON_SID_AND_ATTRIBUTES_ARRAY),
)
class NETLOGON_VALIDATION_SAM_INFO2(NDRSTRUCT):
structure = (
('LogonTime', OLD_LARGE_INTEGER),
('LogoffTime', OLD_LARGE_INTEGER),
('KickOffTime', OLD_LARGE_INTEGER),
('PasswordLastSet', OLD_LARGE_INTEGER),
('PasswordCanChange', OLD_LARGE_INTEGER),
('PasswordMustChange', OLD_LARGE_INTEGER),
('EffectiveName', RPC_UNICODE_STRING),
('FullName', RPC_UNICODE_STRING),
('LogonScript', RPC_UNICODE_STRING),
('ProfilePath', RPC_UNICODE_STRING),
('HomeDirectory', RPC_UNICODE_STRING),
('HomeDirectoryDrive', RPC_UNICODE_STRING),
('LogonCount', USHORT),
('BadPasswordCount', USHORT),
('UserId', ULONG),
('PrimaryGroupId', ULONG),
('GroupCount', ULONG),
('GroupIds', PGROUP_MEMBERSHIP_ARRAY),
('UserFlags', ULONG),
('UserSessionKey', USER_SESSION_KEY),
('LogonServer', RPC_UNICODE_STRING),
('LogonDomainName', RPC_UNICODE_STRING),
('LogonDomainId', PRPC_SID),
('ExpansionRoom', LONG_ARRAY),
('SidCount', ULONG),
('ExtraSids', PNETLOGON_SID_AND_ATTRIBUTES_ARRAY),
)
class PNETLOGON_VALIDATION_SAM_INFO2(NDRPOINTER):
referent = (
('Data', NETLOGON_VALIDATION_SAM_INFO2),
)
# 2.2.1.4.13 NETLOGON_VALIDATION_SAM_INFO4
class NETLOGON_VALIDATION_SAM_INFO4(NDRSTRUCT):
structure = (
('LogonTime', OLD_LARGE_INTEGER),
('LogoffTime', OLD_LARGE_INTEGER),
('KickOffTime', OLD_LARGE_INTEGER),
('PasswordLastSet', OLD_LARGE_INTEGER),
('PasswordCanChange', OLD_LARGE_INTEGER),
('PasswordMustChange', OLD_LARGE_INTEGER),
('EffectiveName', RPC_UNICODE_STRING),
('FullName', RPC_UNICODE_STRING),
('LogonScript', RPC_UNICODE_STRING),
('ProfilePath', RPC_UNICODE_STRING),
('HomeDirectory', RPC_UNICODE_STRING),
('HomeDirectoryDrive', RPC_UNICODE_STRING),
('LogonCount', USHORT),
('BadPasswordCount', USHORT),
('UserId', ULONG),
('PrimaryGroupId', ULONG),
('GroupCount', ULONG),
('GroupIds', PGROUP_MEMBERSHIP_ARRAY),
('UserFlags', ULONG),
('UserSessionKey', USER_SESSION_KEY),
('LogonServer', RPC_UNICODE_STRING),
('LogonDomainName', RPC_UNICODE_STRING),
('LogonDomainId', PRPC_SID),
('LMKey', CHAR_FIXED_8_ARRAY),
('UserAccountControl', ULONG),
('SubAuthStatus', ULONG),
('LastSuccessfulILogon', OLD_LARGE_INTEGER),
('LastFailedILogon', OLD_LARGE_INTEGER),
('FailedILogonCount', ULONG),
('Reserved4', ULONG),
('SidCount', ULONG),
('ExtraSids', PNETLOGON_SID_AND_ATTRIBUTES_ARRAY),
('DnsLogonDomainName', RPC_UNICODE_STRING),
('Upn', RPC_UNICODE_STRING),
('ExpansionString1', RPC_UNICODE_STRING),
('ExpansionString2', RPC_UNICODE_STRING),
('ExpansionString3', RPC_UNICODE_STRING),
('ExpansionString4', RPC_UNICODE_STRING),
('ExpansionString5', RPC_UNICODE_STRING),
('ExpansionString6', RPC_UNICODE_STRING),
('ExpansionString7', RPC_UNICODE_STRING),
('ExpansionString8', RPC_UNICODE_STRING),
('ExpansionString9', RPC_UNICODE_STRING),
('ExpansionString10', RPC_UNICODE_STRING),
)
class PNETLOGON_VALIDATION_SAM_INFO4(NDRPOINTER):
referent = (
('Data', NETLOGON_VALIDATION_SAM_INFO4),
)
# 2.2.1.4.17 NETLOGON_VALIDATION_INFO_CLASS
class NETLOGON_VALIDATION_INFO_CLASS(NDRENUM):
class enumItems(Enum):
NetlogonValidationUasInfo = 1
NetlogonValidationSamInfo = 2
NetlogonValidationSamInfo2 = 3
NetlogonValidationGenericInfo = 4
NetlogonValidationGenericInfo2 = 5
NetlogonValidationSamInfo4 = 6
# 2.2.1.4.14 NETLOGON_VALIDATION
class NETLOGON_VALIDATION(NDRUNION):
union = {
NETLOGON_VALIDATION_INFO_CLASS.NetlogonValidationSamInfo : ('ValidationSam', PNETLOGON_VALIDATION_SAM_INFO),
NETLOGON_VALIDATION_INFO_CLASS.NetlogonValidationSamInfo2 : ('ValidationSam2', PNETLOGON_VALIDATION_SAM_INFO2),
NETLOGON_VALIDATION_INFO_CLASS.NetlogonValidationGenericInfo2: ('ValidationGeneric2', PNETLOGON_VALIDATION_GENERIC_INFO2),
NETLOGON_VALIDATION_INFO_CLASS.NetlogonValidationSamInfo4 : ('ValidationSam4', PNETLOGON_VALIDATION_SAM_INFO4),
}
# 2.2.1.5.2 NLPR_QUOTA_LIMITS
class NLPR_QUOTA_LIMITS(NDRSTRUCT):
structure = (
('PagedPoolLimit', ULONG),
('NonPagedPoolLimit', ULONG),
('MinimumWorkingSetSize', ULONG),
('MaximumWorkingSetSize', ULONG),
('PagefileLimit', ULONG),
('Reserved', OLD_LARGE_INTEGER),
)
# 2.2.1.5.3 NETLOGON_DELTA_ACCOUNTS
class ULONG_ARRAY(NDRUniConformantArray):
item = ULONG
class PULONG_ARRAY(NDRPOINTER):
referent = (
('Data', ULONG_ARRAY),
)
class NETLOGON_DELTA_ACCOUNTS(NDRSTRUCT):
structure = (
('PrivilegeEntries', ULONG),
('PrivilegeControl', ULONG),
('PrivilegeAttributes', PULONG_ARRAY),
('PrivilegeNames', PRPC_UNICODE_STRING_ARRAY),
('QuotaLimits', NLPR_QUOTA_LIMITS),
('SystemAccessFlags', ULONG),
('SecurityInformation', SECURITY_INFORMATION),
('SecuritySize', ULONG),
('SecurityDescriptor', PUCHAR_ARRAY),
('DummyString1', RPC_UNICODE_STRING),
('DummyString2', RPC_UNICODE_STRING),
('DummyString3', RPC_UNICODE_STRING),
('DummyString4', RPC_UNICODE_STRING),
('DummyLong1', ULONG),
('DummyLong2', ULONG),
('DummyLong3', ULONG),
('DummyLong4', ULONG),
)
class PNETLOGON_DELTA_ACCOUNTS(NDRPOINTER):
referent = (
('Data', NETLOGON_DELTA_ACCOUNTS),
)
# 2.2.1.5.5 NLPR_SID_INFORMATION
class NLPR_SID_INFORMATION(NDRSTRUCT):
structure = (
('SidPointer', PRPC_SID),
)
# 2.2.1.5.6 NLPR_SID_ARRAY
class NLPR_SID_INFORMATION_ARRAY(NDRUniConformantArray):
item = NLPR_SID_INFORMATION
class PNLPR_SID_INFORMATION_ARRAY(NDRPOINTER):
referent = (
('Data', NLPR_SID_INFORMATION_ARRAY),
)
class NLPR_SID_ARRAY(NDRSTRUCT):
referent = (
('Count', ULONG),
('Sids', PNLPR_SID_INFORMATION_ARRAY),
)
# 2.2.1.5.7 NETLOGON_DELTA_ALIAS_MEMBER
class NETLOGON_DELTA_ALIAS_MEMBER(NDRSTRUCT):
structure = (
('Members', NLPR_SID_ARRAY),
('DummyLong1', ULONG),
('DummyLong2', ULONG),
('DummyLong3', ULONG),
('DummyLong4', ULONG),
)
class PNETLOGON_DELTA_ALIAS_MEMBER(NDRPOINTER):
referent = (
('Data', NETLOGON_DELTA_ALIAS_MEMBER),
)
# 2.2.1.5.8 NETLOGON_DELTA_DELETE_GROUP
class NETLOGON_DELTA_DELETE_GROUP(NDRSTRUCT):
structure = (
('AccountName', LPWSTR),
('DummyString1', RPC_UNICODE_STRING),
('DummyString2', RPC_UNICODE_STRING),
('DummyString3', RPC_UNICODE_STRING),
('DummyString4', RPC_UNICODE_STRING),
('DummyLong1', ULONG),
('DummyLong2', ULONG),
('DummyLong3', ULONG),
('DummyLong4', ULONG),
)
class PNETLOGON_DELTA_DELETE_GROUP(NDRPOINTER):
referent = (
('Data', NETLOGON_DELTA_DELETE_GROUP),
)
# 2.2.1.5.9 NETLOGON_DELTA_DELETE_USER
class NETLOGON_DELTA_DELETE_USER(NDRSTRUCT):
structure = (
('AccountName', LPWSTR),
('DummyString1', RPC_UNICODE_STRING),
('DummyString2', RPC_UNICODE_STRING),
('DummyString3', RPC_UNICODE_STRING),
('DummyString4', RPC_UNICODE_STRING),
('DummyLong1', ULONG),
('DummyLong2', ULONG),
('DummyLong3', ULONG),
('DummyLong4', ULONG),
)
class PNETLOGON_DELTA_DELETE_USER(NDRPOINTER):
referent = (
('Data', NETLOGON_DELTA_DELETE_USER),
)
# 2.2.1.5.10 NETLOGON_DELTA_DOMAIN
class NETLOGON_DELTA_DOMAIN(NDRSTRUCT):
structure = (
('DomainName', RPC_UNICODE_STRING),
('OemInformation', RPC_UNICODE_STRING),
('ForceLogoff', OLD_LARGE_INTEGER),
('MinPasswordLength', USHORT),
('PasswordHistoryLength', USHORT),
('MaxPasswordAge', OLD_LARGE_INTEGER),
('MinPasswordAge', OLD_LARGE_INTEGER),
('DomainModifiedCount', OLD_LARGE_INTEGER),
('DomainCreationTime', OLD_LARGE_INTEGER),
('SecurityInformation', SECURITY_INFORMATION),
('SecuritySize', ULONG),
('SecurityDescriptor', PUCHAR_ARRAY),
('DomainLockoutInformation', RPC_UNICODE_STRING),
('DummyString2', RPC_UNICODE_STRING),
('DummyString3', RPC_UNICODE_STRING),
('DummyString4', RPC_UNICODE_STRING),
('PasswordProperties', ULONG),
('DummyLong2', ULONG),
('DummyLong3', ULONG),
('DummyLong4', ULONG),
)
class PNETLOGON_DELTA_DOMAIN(NDRPOINTER):
referent = (
('Data', NETLOGON_DELTA_DOMAIN),
)
# 2.2.1.5.13 NETLOGON_DELTA_GROUP
class NETLOGON_DELTA_GROUP(NDRSTRUCT):
structure = (
('Name', RPC_UNICODE_STRING),
('RelativeId', ULONG),
('Attributes', ULONG),
('AdminComment', RPC_UNICODE_STRING),
('SecurityInformation', USHORT),
('SecuritySize', ULONG),
('SecurityDescriptor', SECURITY_INFORMATION),
('DummyString1', RPC_UNICODE_STRING),
('DummyString2', RPC_UNICODE_STRING),
('DummyString3', RPC_UNICODE_STRING),
('DummyString4', RPC_UNICODE_STRING),
('DummyLong1', ULONG),
('DummyLong2', ULONG),
('DummyLong3', ULONG),
('DummyLong4', ULONG),
)
class PNETLOGON_DELTA_GROUP(NDRPOINTER):
referent = (
('Data', NETLOGON_DELTA_GROUP),
)
# 2.2.1.5.24 NETLOGON_RENAME_GROUP
class NETLOGON_RENAME_GROUP(NDRSTRUCT):
structure = (
('OldName', RPC_UNICODE_STRING),
('NewName', RPC_UNICODE_STRING),
('DummyString1', RPC_UNICODE_STRING),
('DummyString2', RPC_UNICODE_STRING),
('DummyString3', RPC_UNICODE_STRING),
('DummyString4', RPC_UNICODE_STRING),
('DummyLong1', ULONG),
('DummyLong2', ULONG),
('DummyLong3', ULONG),
('DummyLong4', ULONG),
)