1 <?xml version="1.0" encoding="iso-8859-1"?>
2 <!DOCTYPE chapter PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc">
3 <chapter id="ntdomain">
6 <firstname>Luke</firstname><surname>Leighton</surname>
7 <affiliation><address><email>lkcl@switchboard.net</email></address></affiliation>
10 <firstname>Paul</firstname><surname>Ashton</surname>
11 <affiliation><address><email>paul@argo.demon.co.uk</email></address></affiliation>
14 <firstname>Duncan</firstname><surname>Stansfield</surname>
15 <affiliation><address><email>duncans@sco.com</email></address></affiliation>
18 <pubdate>01 November 97(version 0.0.24)</pubdate>
21 <title>NT Domain RPC's</title>
24 <title>Introduction</title>
28 This document contains information to provide an NT workstation with login
29 services, without the need for an NT server. It is the sgml version of <ulink url="http://mailhost.cb1.com/~lkcl/cifsntdomain.txt">http://mailhost.cb1.com/~lkcl/cifsntdomain.txt</ulink>, controlled by Luke.
33 It should be possible to select a domain instead of a workgroup (in the NT
34 workstation's TCP/IP settings) and after the obligatory reboot, type in a
35 username, password, select a domain and successfully log in. I would
36 appreciate any feedback on your experiences with this process, and any
37 comments, corrections and additions to this document.
41 The packets described here can be easily derived from (and are probably
42 better understood using) Netmon.exe. You will need to use the version
43 of Netmon that matches your system, in order to correctly decode the
44 NETLOGON, lsarpc and srvsvc Transact pipes. This document is derived from
45 NT Service Pack 1 and its corresponding version of Netmon. It is intended
46 that an annotated packet trace be produced, which will likely be more
47 instructive than this document.
51 Also needed, to fully implement NT Domain Login Services, is the
52 document describing the cryptographic part of the NT authentication.
53 This document is available from comp.protocols.smb; from the ntsecurity.net
54 digest and from the samba digest, amongst other sources.
58 A copy is available from:
61 <para><ulink url="http://ntbugtraq.rc.on.ca/SCRIPTS/WA.EXE?A2=ind9708;L=ntbugtraq;O=A;P=2935">http://ntbugtraq.rc.on.ca/SCRIPTS/WA.EXE?A2=ind9708;L=ntbugtraq;O=A;P=2935</ulink></para>
63 <para><ulink url="http://mailhost.cb1.com/~lkcl/crypt.html">http://mailhost.cb1.com/~lkcl/crypt.html</ulink></para>
66 A c-code implementation, provided by <ulink url="mailto:linus@incolumitas.se">Linus Nordberg</ulink>
67 of this protocol is available from:
70 <para><ulink url="https://www.samba.org/cgi-bin/mfs/01/digest/1997/97aug/0391.html">https://www.samba.org/cgi-bin/mfs/01/digest/1997/97aug/0391.html</ulink></para>
71 <para><ulink url="http://mailhost.cb1.com/~lkcl/crypt.txt">http://mailhost.cb1.com/~lkcl/crypt.txt</ulink></para>
74 Also used to provide debugging information is the Check Build version of
75 NT workstation, and enabling full debugging in NETLOGON. This is
76 achieved by setting the following REG_SZ registry key to 0x1ffffff:
79 <para><filename>HKLM\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters</filename></para>
81 <para><emphasis>Incorrect direct editing of the registry can cause your
82 machine to fail. Then again, so can incorrect implementation of this
83 protocol. See "Liability:" above.</emphasis></para>
86 Bear in mind that each packet over-the-wire will have its origin in an
87 API call. Therefore, there are likely to be structures, enumerations
88 and defines that are usefully documented elsewhere.
92 This document is by no means complete or authoritative. Missing sections
93 include, but are not limited to:
99 <listitem><para>Mappings of RIDs to usernames (and vice-versa).</para></listitem>
101 <listitem><para>What a User ID is and what a Group ID is.</para></listitem>
103 <listitem><para>The exact meaning/definition of various magic constants or enumerations.</para></listitem>
105 <listitem><para>The reply error code and use of that error code when a
106 workstation becomes a member of a domain (to be described later).
107 Failure to return this error code will make the workstation report
108 that it is already a member of the domain.</para></listitem>
110 <listitem><para>the cryptographic side of the NetrServerPasswordSet command,
111 which would allow the workstation to change its password. This password is
112 used to generate the long-term session key. [It is possible to reject this
113 command, and keep the default workstation password].</para></listitem>
118 <title>Sources</title>
121 <member>cket Traces from Netmonitor (Service Pack 1 and above)</member>
122 <member>ul Ashton and Luke Leighton's other "NT Domain" doc.</member>
123 <member>FS documentation - cifs6.txt</member>
124 <member>FS documentation - cifsrap2.txt</member>
130 <title>Credits</title>
133 <member>Paul Ashton: loads of work with Net Monitor; understanding the NT authentication system; reference implementation of the NT domain support on which this document is originally based.</member>
134 <member>Duncan Stansfield: low-level analysis of MSRPC Pipes.</member>
135 <member>Linus Nordberg: producing c-code from Paul's crypto spec.</member>
136 <member>Windows Sourcer development team</member>
144 <title>Notes and Structures</title>
151 In the SMB Transact pipes, some "Structures", described here, appear to be
152 4-byte aligned with the SMB header, at their start. Exactly which
153 "Structures" need aligning is not precisely known or documented.
157 In the UDP NTLOGON Mailslots, some "Structures", described here, appear to be
158 2-byte aligned with the start of the mailslot, at their start.
162 Domain SID is of the format S-revision-version-auth1-auth2...authN.
163 e.g S-1-5-123-456-789-123-456. the 5 could be a sub-revision.
167 any undocumented buffer pointers must be non-zero if the string buffer it
168 refers to contains characters. exactly what value they should be is unknown.
169 0x0000 0002 seems to do the trick to indicate that the buffer exists. a
170 NULL buffer pointer indicates that the string buffer is of zero length.
171 If the buffer pointer is NULL, then it is suspected that the structure it
172 refers to is NOT put into (or taken out of) the SMB data stream. This is
173 empirically derived from, for example, the LSA SAM Logon response packet,
174 where if the buffer pointer is NULL, the user information is not inserted
175 into the data stream. Exactly what happens with an array of buffer pointers
176 is not known, although an educated guess can be made.
180 an array of structures (a container) appears to have a count and a pointer.
181 if the count is zero, the pointer is also zero. no further data is put
182 into or taken out of the SMB data stream. if the count is non-zero, then
183 the pointer is also non-zero. immediately following the pointer is the
184 count again, followed by an array of container sub-structures. the count
185 appears a third time after the last sub-structure.
192 <title>Enumerations</title>
195 <title>MSRPC Header type</title>
196 <para>command number in the msrpc packet header</para>
200 <term>MSRPC_Request:</term>
201 <listitem><para>0x00</para></listitem>
204 <term>MSRPC_Response:</term>
205 <listitem><para>0x02</para></listitem>
208 <term>MSRPC_Bind:</term>
209 <listitem><para>0x0B</para></listitem>
212 <term>MSRPC_BindAck:</term>
213 <listitem><para>0x0C</para></listitem>
219 <title>MSRPC Packet info</title>
221 <para>The meaning of these flags is undocumented</para>
225 <term>FirstFrag:</term>
226 <listitem><para>0x01 </para></listitem>
229 <term>LastFrag:</term>
230 <listitem><para>0x02 </para></listitem>
233 <term>NotaFrag:</term>
234 <listitem><para>0x04 </para></listitem>
237 <term>RecRespond:</term>
238 <listitem><para>0x08 </para></listitem>
241 <term>NoMultiplex:</term>
242 <listitem><para>0x10 </para></listitem>
245 <term>NotForIdemp:</term>
246 <listitem><para>0x20 </para></listitem>
249 <term>NotforBcast:</term>
250 <listitem><para>0x40 </para></listitem>
254 <listitem><para>0x80 </para></listitem>
263 <title>Structures</title>
265 <sect3><title>VOID *</title>
266 <para>sizeof VOID* is 32 bits.</para>
269 <sect3><title>char</title>
270 <para>sizeof char is 8 bits.</para>
273 <sect3><title>UTIME</title>
274 <para>UTIME is 32 bits, indicating time in seconds since 01jan1970. documented in cifs6.txt (section 3.5 page, page 30).</para>
277 <sect3><title>NTTIME</title>
278 <para>NTTIME is 64 bits. documented in cifs6.txt (section 3.5 page, page 30).</para>
282 <title>DOM_SID (domain SID structure)</title>
288 <listitem><para>num of sub-authorities in domain SID</para></listitem>
293 <listitem><para>SID revision number</para></listitem>
297 <listitem><para>num of sub-authorities in domain SID</para></listitem>
300 <term>UINT8[6]</term>
301 <listitem><para>6 bytes for domain SID - Identifier Authority.</para></listitem>
305 <term>UINT16[n_subauths]</term>
306 <listitem><para>domain SID sub-authorities</para></listitem>
311 <para><emphasis>Note: the domain SID is documented elsewhere.</emphasis>
317 <title>STR (string)</title>
319 <para>STR (string) is a char[] : a null-terminated string of ascii characters.</para>
324 <title>UNIHDR (unicode string header) </title>
330 <listitem><para>length of unicode string</para></listitem>
335 <listitem><para>max length of unicode string</para></listitem>
340 <listitem><para>4 - undocumented.</para></listitem>
348 <title>UNIHDR2 (unicode string header plus buffer pointer)</title>
354 <listitem><para>unicode string header</para></listitem>
360 <listitem><para>undocumented buffer pointer</para></listitem>
368 <title>UNISTR (unicode string)</title>
373 <term>UINT16[]</term>
374 <listitem><para>null-terminated string of unicode characters.</para></listitem>
382 <title>NAME (length-indicated unicode string)</title>
388 <listitem><para>length of unicode string</para></listitem>
391 <term>UINT16[]</term>
392 <listitem><para>null-terminated string of unicode characters.</para></listitem>
400 <title>UNISTR2 (aligned unicode string)</title>
405 <listitem><para>padding to get unicode string 4-byte aligned with the start of the SMB header.</para></listitem>
409 <listitem><para>max length of unicode string</para></listitem>
413 <listitem><para>0 - undocumented</para></listitem>
417 <listitem><para>length of unicode string</para></listitem>
420 <term>UINT16[]</term>
421 <listitem><para>string of uncode characters</para></listitem>
429 <title>OBJ_ATTR (object attributes)</title>
434 <listitem><para>0x18 - length (in bytes) including the length field.</para></listitem></varlistentry>
437 <listitem><para>0 - root directory (pointer)</para></listitem></varlistentry>
440 <listitem><para>0 - object name (pointer)</para></listitem></varlistentry>
443 <listitem><para>0 - attributes (undocumented)</para></listitem></varlistentry>
446 <listitem><para>0 - security descriptor (pointer)</para></listitem></varlistentry>
449 <listitem><para>0 - security quality of service</para></listitem>
457 <title>POL_HND (LSA policy handle)</title>
461 <term>char[20]</term>
462 <listitem><para>policy handle</para></listitem>
469 <title>DOM_SID2 (domain SID structure, SIDS stored in unicode)</title>
474 <listitem><para>5 - SID type</para></listitem>
478 <listitem><para>0 - undocumented</para></listitem>
482 <listitem><para>domain SID unicode string header</para></listitem>
486 <listitem><para>domain SID unicode string</para></listitem>
490 <para><emphasis>Note: there is a conflict between the unicode string header and the unicode string itself as to which to use to indicate string length. this will need to be resolved.</emphasis></para>
492 <para><emphasis>Note: the SID type indicates, for example, an alias; a well-known group etc. this is documented somewhere.</emphasis></para>
497 <title>DOM_RID (domain RID structure)</title>
502 <listitem><para>5 - well-known SID. 1 - user SID (see ShowACLs)</para></listitem></varlistentry>
505 <listitem><para>5 - undocumented</para></listitem>
509 <listitem><para>domain RID </para></listitem>
513 <listitem><para>0 - domain index out of above reference domains</para></listitem>
520 <title>LOG_INFO (server, account, client structure)</title>
522 <para><emphasis>Note: logon server name starts with two '\' characters and is upper case.</emphasis></para>
524 <para><emphasis>Note: account name is the logon client name from the LSA Request Challenge, with a $ on the end of it, in upper case.</emphasis></para>
529 <listitem><para>undocumented buffer pointer</para></listitem>
533 <listitem><para>logon server unicode string</para></listitem>
537 <listitem><para>account name unicode string</para></listitem>
541 <listitem><para>sec_chan - security channel type</para></listitem>
545 <listitem><para>logon client machine unicode string</para></listitem>
552 <title>CLNT_SRV (server, client names structure)</title>
554 <para><emphasis>Note: logon server name starts with two '\' characters and is upper case.</emphasis></para>
559 <listitem><para>undocumented buffer pointer</para></listitem>
563 <listitem><para>logon server unicode string</para></listitem>
567 <listitem><para>undocumented buffer pointer</para></listitem>
571 <listitem><para>logon client machine unicode string</para></listitem>
578 <title>CREDS (credentials + time stamp)</title>
583 <listitem><para>credentials</para></listitem>
587 <listitem><para>time stamp</para></listitem>
594 <title>CLNT_INFO2 (server, client structure, client credentials)</title>
596 <para><emphasis>Note: whenever this structure appears in a request, you must take a copy of the client-calculated credentials received, because they will beused in subsequent credential checks. the presumed intention is to
597 maintain an authenticated request/response trail.</emphasis></para>
601 <term>CLNT_SRV</term>
602 <listitem><para>client and server names</para></listitem>
606 <listitem><para>???? padding, for 4-byte alignment with SMB header.</para></listitem>
610 <listitem><para>pointer to client credentials.</para></listitem>
614 <listitem><para>client-calculated credentials + client time</para></listitem>
621 <title>CLNT_INFO (server, account, client structure, client credentials)</title>
622 <para><emphasis>Note: whenever this structure appears in a request, you must take a copy of the client-calculated credentials received, because they will be used in subsequent credential checks. the presumed intention is to maintain an authenticated request/response trail.</emphasis></para>
626 <term>LOG_INFO</term>
627 <listitem><para>logon account info</para></listitem>
631 <listitem><para>client-calculated credentials + client time</para></listitem>
638 <title>ID_INFO_1 (id info structure, auth level 1)</title>
643 <listitem><para>ptr_id_info_1</para></listitem>
647 <listitem><para>domain name unicode header</para></listitem>
651 <listitem><para>param control</para></listitem>
655 <listitem><para>logon ID</para></listitem>
659 <listitem><para>user name unicode header</para></listitem>
663 <listitem><para>workgroup name unicode header</para></listitem>
666 <term>char[16]</term>
667 <listitem><para>arc4 LM OWF Password</para></listitem>
670 <term>char[16]</term>
671 <listitem><para>arc4 NT OWF Password</para></listitem>
675 <listitem><para>domain name unicode string</para></listitem>
679 <listitem><para>user name unicode string</para></listitem>
683 <listitem><para>workstation name unicode string</para></listitem>
690 <title>SAM_INFO (sam logon/logoff id info structure)</title>
692 <para><emphasis>Note: presumably, the return credentials is supposedly for the server to verify that the credential chain hasn't been compromised.</emphasis></para>
696 <term>CLNT_INFO2</term>
697 <listitem><para>client identification/authentication info</para></listitem>
701 <listitem><para>pointer to return credentials.</para></listitem>
705 <listitem><para>return credentials - ignored.</para></listitem>
709 <listitem><para>logon level</para></listitem>
713 <listitem><para>switch value</para></listitem>
718 <para><programlisting>
719 switch (switch_value)
724 </programlisting></para>
729 <title>GID (group id info)</title>
734 <listitem><para>group id</para></listitem></varlistentry>
737 <listitem><para>user attributes (only used by NT 3.1 and 3.51)</para></listitem></varlistentry>
743 <title>DOM_REF (domain reference info)</title>
748 <listitem><para>undocumented buffer pointer.</para></listitem>
752 <listitem><para>num referenced domains?</para></listitem>
756 <listitem><para>undocumented domain name buffer pointer.</para></listitem>
760 <listitem><para>32 - max number of entries</para></listitem>
764 <listitem><para>4 - num referenced domains?</para></listitem>
768 <listitem><para>domain name unicode string header</para></listitem>
771 <term>UNIHDR2[num_ref_doms-1]</term>
772 <listitem><para>referenced domain unicode string headers</para></listitem>
776 <listitem><para>domain name unicode string</para></listitem>
779 <term>DOM_SID[num_ref_doms]</term>
780 <listitem><para>referenced domain SIDs</para></listitem>
787 <title>DOM_INFO (domain info, levels 3 and 5 are the same))</title>
792 <listitem><para>??? padding to get 4-byte alignment with start of SMB header</para></listitem>
796 <listitem><para>domain name string length * 2</para></listitem>
800 <listitem><para>domain name string length * 2</para></listitem>
804 <listitem><para>undocumented domain name string buffer pointer</para></listitem>
808 <listitem><para>undocumented domain SID string buffer pointer</para></listitem></varlistentry>
811 <listitem><para>domain name (unicode string)</para></listitem></varlistentry>
814 <listitem><para>domain SID</para></listitem>
821 <title>USER_INFO (user logon info)</title>
823 <para><emphasis>Note: it would be nice to know what the 16 byte user session key is for.</emphasis></para>
828 <listitem><para>logon time</para></listitem>
832 <listitem><para>logoff time</para></listitem>
836 <listitem><para>kickoff time</para></listitem>
840 <listitem><para>password last set time</para></listitem>
844 <listitem><para>password can change time</para></listitem>
848 <listitem><para>password must change time</para></listitem>
852 <listitem><para>username unicode string header</para></listitem>
856 <listitem><para>user's full name unicode string header</para></listitem>
860 <listitem><para>logon script unicode string header</para></listitem>
864 <listitem><para>profile path unicode string header</para></listitem>
868 <listitem><para>home directory unicode string header</para></listitem>
872 <listitem><para>home directory drive unicode string header</para></listitem>
876 <listitem><para>logon count</para></listitem>
880 <listitem><para>bad password count</para></listitem>
884 <listitem><para>User ID</para></listitem>
888 <listitem><para>Group ID</para></listitem>
892 <listitem><para>num groups</para></listitem>
896 <listitem><para>undocumented buffer pointer to groups.</para></listitem>
900 <listitem><para>user flags</para></listitem>
903 <term>char[16]</term>
904 <listitem><para>user session key</para></listitem>
908 <listitem><para>logon server unicode string header</para></listitem>
912 <listitem><para>logon domain unicode string header</para></listitem>
916 <listitem><para>undocumented logon domain id pointer</para></listitem>
919 <term>char[40]</term>
920 <listitem><para>40 undocumented padding bytes. future expansion?</para></listitem>
924 <listitem><para>0 - num_other_sids?</para></listitem>
928 <listitem><para>NULL - undocumented pointer to other domain SIDs.</para></listitem>
932 <listitem><para>username unicode string</para></listitem>
936 <listitem><para>user's full name unicode string</para></listitem>
940 <listitem><para>logon script unicode string</para></listitem>
944 <listitem><para>profile path unicode string</para></listitem>
948 <listitem><para>home directory unicode string</para></listitem>
952 <listitem><para>home directory drive unicode string</para></listitem>
956 <listitem><para>num groups</para></listitem>
959 <term>GID[num_groups]</term>
960 <listitem><para>group info</para></listitem>
964 <listitem><para>logon server unicode string</para></listitem>
968 <listitem><para>logon domain unicode string</para></listitem>
972 <listitem><para>domain SID</para></listitem>
975 <term>DOM_SID[num_sids]</term>
976 <listitem><para>other domain SIDs?</para></listitem>
983 <title>SH_INFO_1_PTR (pointers to level 1 share info strings)</title>
985 <para><emphasis>Note: see cifsrap2.txt section5, page 10.</emphasis></para>
988 <member>0 for shi1_type indicates a Disk.</member>
989 <member>1 for shi1_type indicates a Print Queue.</member>
990 <member>2 for shi1_type indicates a Device.</member>
991 <member>3 for shi1_type indicates an IPC pipe.</member>
992 <member>0x8000 0000 (top bit set in shi1_type) indicates a hidden share.</member>
999 <listitem><para>shi1_netname - pointer to net name</para></listitem>
1003 <listitem><para>shi1_type - type of share. 0 - undocumented.</para></listitem>
1007 <listitem><para>shi1_remark - pointer to comment.</para></listitem>
1015 <title>SH_INFO_1_STR (level 1 share info strings)</title>
1019 <term>UNISTR2</term>
1020 <listitem><para>shi1_netname - unicode string of net name</para></listitem>
1023 <term>UNISTR2</term>
1024 <listitem><para>shi1_remark - unicode string of comment.</para></listitem>
1031 <title>SHARE_INFO_1_CTR</title>
1033 <para>share container with 0 entries:</para>
1038 <listitem><para>0 - EntriesRead</para></listitem>
1042 <listitem><para>0 - Buffer</para></listitem>
1046 <para>share container with > 0 entries:</para>
1051 <listitem><para>EntriesRead</para></listitem>
1055 <listitem><para>non-zero - Buffer</para></listitem>
1059 <listitem><para>EntriesRead</para></listitem>
1062 <term>SH_INFO_1_PTR[EntriesRead]</term>
1063 <listitem><para>share entry pointers</para></listitem>
1066 <term>SH_INFO_1_STR[EntriesRead]</term>
1067 <listitem><para>share entry strings</para></listitem>
1070 <term>UINT8[]</term>
1071 <listitem><para>padding to get unicode string 4-byte aligned with start of the SMB header.</para></listitem>
1075 <listitem><para>EntriesRead</para></listitem>
1079 <listitem><para>0 - padding</para></listitem>
1087 <title>SERVER_INFO_101</title>
1089 <para><emphasis>Note: see cifs6.txt section 6.4 - the fields described therein will be of assistance here. for example, the type listed below is the same as fServerType, which is described in 6.4.1. </emphasis></para>
1093 <term>SV_TYPE_WORKSTATION</term>
1094 <listitem><para>0x00000001 All workstations</para></listitem>
1097 <term>SV_TYPE_SERVER</term>
1098 <listitem><para>0x00000002 All servers</para></listitem>
1101 <term>SV_TYPE_SQLSERVER</term>
1102 <listitem><para>0x00000004 Any server running with SQL server</para></listitem>
1105 <term>SV_TYPE_DOMAIN_CTRL</term>
1106 <listitem><para>0x00000008 Primary domain controller</para></listitem>
1109 <term>SV_TYPE_DOMAIN_BAKCTRL</term>
1110 <listitem><para>0x00000010 Backup domain controller</para></listitem>
1113 <term>SV_TYPE_TIME_SOURCE</term>
1114 <listitem><para>0x00000020 Server running the timesource service</para></listitem>
1117 <term>SV_TYPE_AFP</term>
1118 <listitem><para>0x00000040 Apple File Protocol servers</para></listitem>
1121 <term>SV_TYPE_NOVELL</term>
1122 <listitem><para>0x00000080 Novell servers</para></listitem>
1125 <term>SV_TYPE_DOMAIN_MEMBER</term>
1126 <listitem><para>0x00000100 Domain Member</para></listitem>
1129 <term>SV_TYPE_PRINTQ_SERVER</term>
1130 <listitem><para>0x00000200 Server sharing print queue</para></listitem>
1133 <term>SV_TYPE_DIALIN_SERVER</term>
1134 <listitem><para>0x00000400 Server running dialin service.</para></listitem>
1137 <term>SV_TYPE_XENIX_SERVER</term>
1138 <listitem><para>0x00000800 Xenix server</para></listitem>
1141 <term>SV_TYPE_NT</term>
1142 <listitem><para>0x00001000 NT server</para></listitem>
1145 <term>SV_TYPE_WFW</term>
1146 <listitem><para>0x00002000 Server running Windows for </para></listitem>
1149 <term>SV_TYPE_SERVER_NT</term>
1150 <listitem><para>0x00008000 Windows NT non DC server</para></listitem>
1153 <term>SV_TYPE_POTENTIAL_BROWSER</term>
1154 <listitem><para>0x00010000 Server that can run the browser service</para></listitem>
1157 <term>SV_TYPE_BACKUP_BROWSER</term>
1158 <listitem><para>0x00020000 Backup browser server</para></listitem>
1161 <term>SV_TYPE_MASTER_BROWSER</term>
1162 <listitem><para>0x00040000 Master browser server</para></listitem>
1165 <term>SV_TYPE_DOMAIN_MASTER</term>
1166 <listitem><para>0x00080000 Domain Master Browser server</para></listitem>
1169 <term>SV_TYPE_LOCAL_LIST_ONLY</term>
1170 <listitem><para>0x40000000 Enumerate only entries marked "local"</para></listitem>
1173 <term>SV_TYPE_DOMAIN_ENUM</term>
1174 <listitem><para>0x80000000 Enumerate Domains. The pszServer and pszDomain parameters must be NULL.</para></listitem>
1182 <listitem><para>500 - platform_id</para></listitem>
1186 <listitem><para>pointer to name</para></listitem>
1190 <listitem><para>5 - major version</para></listitem>
1194 <listitem><para>4 - minor version</para></listitem></varlistentry>
1197 <listitem><para>type (SV_TYPE_... bit field)</para></listitem></varlistentry>
1200 <listitem><para>pointer to comment</para></listitem>
1203 <term>UNISTR2</term>
1204 <listitem><para>sv101_name - unicode string of server name</para></listitem>
1207 <term>UNISTR2</term>
1208 <listitem><para>sv_101_comment - unicode string of server comment.</para></listitem>
1211 <term>UINT8[]</term>
1212 <listitem><para>padding to get unicode string 4-byte aligned with start of the SMB header.</para></listitem>
1221 <title>MSRPC over Transact Named Pipe</title>
1223 <para>For details on the SMB Transact Named Pipe, see cifs6.txt</para>
1226 <title>MSRPC Pipes</title>
1229 The MSRPC is conducted over an SMB Transact Pipe with a name of
1230 <filename>\PIPE\</filename>. You must first obtain a 16 bit file handle, by
1231 sending a SMBopenX with the pipe name <filename>\PIPE\srvsvc</filename> for
1232 example. You can then perform an SMB Trans,
1233 and must carry out an SMBclose on the file handle once you are finished.
1237 Trans Requests must be sent with two setup UINT16s, no UINT16 params (none
1238 known about), and UINT8 data parameters sufficient to contain the MSRPC
1239 header, and MSRPC data. The first UINT16 setup parameter must be either
1240 0x0026 to indicate an RPC, or 0x0001 to indicate Set Named Pipe Handle
1241 state. The second UINT16 parameter must be the file handle for the pipe,
1246 The Data section for an API Command of 0x0026 (RPC pipe) in the Trans
1247 Request is the RPC Header, followed by the RPC Data. The Data section for
1248 an API Command of 0x0001 (Set Named Pipe Handle state) is two bytes. The
1249 only value seen for these two bytes is 0x00 0x43.
1253 MSRPC Responses are sent as response data inside standard SMB Trans
1254 responses, with the MSRPC Header, MSRPC Data and MSRPC tail.
1258 It is suspected that the Trans Requests will need to be at least 2-byte
1259 aligned (probably 4-byte). This is standard practice for SMBs. It is also
1260 independent of the observed 4-byte alignments with the start of the MSRPC
1261 header, including the 4-byte alignment between the MSRPC header and the
1266 First, an SMBtconX connection is made to the IPC$ share. The connection
1267 must be made using encrypted passwords, not clear-text. Then, an SMBopenX
1268 is made on the pipe. Then, a Set Named Pipe Handle State must be sent,
1269 after which the pipe is ready to accept API commands. Lastly, and SMBclose
1278 lkcl/01nov97 there appear to be two additional bytes after the null-terminated \PIPE\ name for the RPC pipe. Values seen so far are
1279 listed below:</para>
1281 <para><programlisting>
1282 initial SMBopenX request: RPC API command 0x26 params:
1283 "\\PIPE\\lsarpc" 0x65 0x63; 0x72 0x70; 0x44 0x65;
1284 "\\PIPE\\srvsvc" 0x73 0x76; 0x4E 0x00; 0x5C 0x43;
1285 </programlisting></para>
1290 <title>Header</title>
1292 <para>[section to be rewritten, following receipt of work by Duncan Stansfield]</para>
1294 <para>Interesting note: if you set packed data representation to 0x0100 0000
1295 then all 4-byte and 2-byte word ordering is turned around!</para>
1297 <para>The start of each of the NTLSA and NETLOGON named pipes begins with:</para>
1300 <segtitle>offset</segtitle><segtitle>Variable type</segtitle><segtitle>Variable data</segtitle>
1301 <seglistitem><seg>00</seg><seg>UINT8</seg><seg>5 - RPC major version</seg></seglistitem>
1302 <seglistitem><seg>01</seg><seg>UINT8</seg><seg>0 - RPC minor version</seg></seglistitem>
1303 <seglistitem><seg>02</seg><seg>UINT8</seg><seg>2 - RPC response packet</seg></seglistitem>
1304 <seglistitem><seg>03</seg><seg>UINT8</seg><seg>3 - (FirstFrag bit-wise or with LastFrag)</seg></seglistitem>
1305 <seglistitem><seg>04</seg><seg>UINT32</seg><seg>0x1000 0000 - packed data representation</seg></seglistitem>
1306 <seglistitem><seg>08</seg><seg>UINT16</seg><seg>fragment length - data size (bytes) inc header and tail.</seg></seglistitem>
1307 <seglistitem><seg>0A</seg><seg>UINT16</seg><seg>0 - authentication length </seg></seglistitem>
1308 <seglistitem><seg>0C</seg><seg>UINT32</seg><seg>call identifier. matches 12th UINT32 of incoming RPC data.</seg></seglistitem>
1309 <seglistitem><seg>10</seg><seg>UINT32</seg><seg>allocation hint - data size (bytes) minus header and tail.</seg></seglistitem>
1310 <seglistitem><seg>14</seg><seg>UINT16</seg><seg>0 - presentation context identifier</seg></seglistitem>
1311 <seglistitem><seg>16</seg><seg>UINT8</seg><seg>0 - cancel count</seg></seglistitem>
1312 <seglistitem><seg>17</seg><seg>UINT8</seg><seg>in replies: 0 - reserved; in requests: opnum - see #defines.</seg></seglistitem>
1313 <seglistitem><seg>18</seg><seg>......</seg><seg>start of data (goes on for allocation_hint bytes)</seg></seglistitem>
1317 <title>RPC_Packet for request, response, bind and bind acknowledgement</title>
1321 <term>UINT8 versionmaj</term>
1322 <listitem><para>reply same as request (0x05)</para></listitem></varlistentry>
1324 <term>UINT8 versionmin</term>
1325 <listitem><para>reply same as request (0x00)</para></listitem></varlistentry>
1327 <term>UINT8 type</term>
1328 <listitem><para>one of the MSRPC_Type enums</para></listitem></varlistentry>
1330 <term>UINT8 flags</term>
1331 <listitem><para>reply same as request (0x00 for Bind, 0x03 for Request)</para></listitem></varlistentry>
1333 <term>UINT32 representation</term>
1334 <listitem><para>reply same as request (0x00000010)</para></listitem></varlistentry>
1336 <term>UINT16 fraglength</term>
1337 <listitem><para>the length of the data section of the SMB trans packet</para></listitem></varlistentry>
1339 <term>UINT16 authlength</term>
1340 <listitem><para></para></listitem>
1343 <term>UINT32 callid</term>
1344 <listitem><para>call identifier. (e.g. 0x00149594)</para></listitem></varlistentry>
1346 <term>* stub USE TvPacket</term>
1347 <listitem><para>the remainder of the packet depending on the "type"</para></listitem></varlistentry>
1353 <title>Interface identification</title>
1355 <para>the interfaces are numbered. as yet I haven't seen more than one interface used on the same pipe name srvsvc</para>
1357 <para><programlisting>
1358 abstract (0x4B324FC8, 0x01D31670, 0x475A7812, 0x88E16EBF, 0x00000003)
1359 transfer (0x8A885D04, 0x11C91CEB, 0x0008E89F, 0x6048102B, 0x00000002)
1360 </programlisting></para>
1365 <title>RPC_Iface RW</title>
1369 <term>UINT8 byte[16]</term>
1370 <listitem><para>16 bytes of number</para></listitem></varlistentry>
1372 <term>UINT32 version</term>
1373 <listitem><para>the interface number</para></listitem></varlistentry>
1380 <title>RPC_ReqBind RW</title>
1382 <para>the remainder of the packet after the header if "type" was Bind in the response header, "type" should be BindAck</para>
1386 <term>UINT16 maxtsize</term>
1387 <listitem><para>maximum transmission fragment size (0x1630)</para></listitem></varlistentry>
1389 <term>UINT16 maxrsize</term>
1390 <listitem><para>max receive fragment size (0x1630)</para></listitem></varlistentry>
1392 <term>UINT32 assocgid</term>
1393 <listitem><para>associated group id (0x0)</para></listitem></varlistentry>
1395 <term>UINT32 numelements</term>
1396 <listitem><para>the number of elements (0x1)</para></listitem></varlistentry>
1398 <term>UINT16 contextid</term>
1399 <listitem><para>presentation context identifier (0x0)</para></listitem></varlistentry>
1401 <term>UINT8 numsyntaxes</term>
1402 <listitem><para>the number of syntaxes (has always been 1?)(0x1)</para></listitem></varlistentry>
1404 <term>UINT8[]</term>
1405 <listitem><para>4-byte alignment padding, against SMB header</para></listitem></varlistentry>
1407 <term>* abstractint USE RPC_Iface</term>
1408 <listitem><para>num and vers. of interface client is using</para></listitem></varlistentry>
1410 <term>* transferint USE RPC_Iface</term>
1411 <listitem><para>num and vers. of interface to use for replies</para></listitem>
1418 <title>RPC_Address RW</title>
1422 <term>UINT16 length</term>
1423 <listitem><para>length of the string including null terminator</para></listitem></varlistentry>
1425 <term>* port USE string</term>
1426 <listitem><para>the string above in single byte, null terminated form</para></listitem></varlistentry>
1432 <title>RPC_ResBind RW</title>
1434 <para>the response to place after the header in the reply packet</para>
1438 <term>UINT16 maxtsize</term>
1439 <listitem><para>same as request</para></listitem></varlistentry>
1441 <term>UINT16 maxrsize</term>
1442 <listitem><para>same as request</para></listitem></varlistentry>
1444 <term>UINT32 assocgid</term>
1445 <listitem><para>zero</para></listitem></varlistentry>
1447 <term>* secondaddr USE RPC_Address</term>
1448 <listitem><para>the address string, as described earlier</para></listitem></varlistentry>
1450 <term>UINT8[]</term>
1451 <listitem><para>4-byte alignment padding, against SMB header</para></listitem></varlistentry>
1453 <term>UINT8 numresults</term>
1454 <listitem><para>the number of results (0x01)</para></listitem></varlistentry>
1456 <term>UINT8[]</term>
1457 <listitem><para>4-byte alignment padding, against SMB header</para></listitem></varlistentry>
1459 <term>UINT16 result</term>
1460 <listitem><para>result (0x00 = accept)</para></listitem></varlistentry>
1462 <term>UINT16 reason</term>
1463 <listitem><para>reason (0x00 = no reason specified)</para></listitem></varlistentry>
1465 <term>* transfersyntax USE RPC_Iface</term>
1466 <listitem><para>the transfer syntax from the request</para></listitem></varlistentry>
1472 <title>RPC_ReqNorm RW</title>
1474 <para>the remainder of the packet after the header for every other other request</para>
1478 <term>UINT32 allochint</term>
1479 <listitem><para>the size of the stub data in bytes</para></listitem></varlistentry>
1481 <term>UINT16 prescontext</term>
1482 <listitem><para>presentation context identifier (0x0)</para></listitem></varlistentry>
1484 <term>UINT16 opnum</term>
1485 <listitem><para>operation number (0x15)</para></listitem></varlistentry>
1487 <term>* stub USE TvPacket</term>
1488 <listitem><para>a packet dependent on the pipe name (probably the interface) and the op number)</para></listitem></varlistentry>
1494 <title>RPC_ResNorm RW</title>
1498 <term>UINT32 allochint</term>
1499 <listitem><para># size of the stub data in bytes</para></listitem></varlistentry>
1501 <term>UINT16 prescontext</term>
1502 <listitem><para># presentation context identifier (same as request)</para></listitem></varlistentry>
1504 <term>UINT8 cancelcount</term>
1505 <listitem><para># cancel count? (0x0)</para></listitem></varlistentry>
1507 <term>UINT8 reserved</term>
1508 <listitem><para># 0 - one byte padding</para></listitem></varlistentry>
1510 <term>* stub USE TvPacket</term>
1511 <listitem><para># the remainder of the reply</para></listitem></varlistentry>
1520 <para>The end of each of the NTLSA and NETLOGON named pipes ends with:</para>
1525 <listitem><para>end of data</para></listitem>
1529 <listitem><para>return code</para></listitem>
1536 <title>RPC Bind / Bind Ack</title>
1539 RPC Binds are the process of associating an RPC pipe (e.g \PIPE\lsarpc)
1540 with a "transfer syntax" (see RPC_Iface structure). The purpose for doing
1544 <para><emphasis>Note: The RPC_ResBind SMB Transact request is sent with two uint16 setup parameters. The first is 0x0026; the second is the file handle
1545 returned by the SMBopenX Transact response.</emphasis></para>
1547 <para><emphasis>Note: The RPC_ResBind members maxtsize, maxrsize and assocgid are the same in the response as the same members in the RPC_ReqBind. The
1548 RPC_ResBind member transfersyntax is the same in the response as
1549 the</emphasis></para>
1551 <para><emphasis>Note: The RPC_ResBind response member secondaddr contains the name of what is presumed to be the service behind the RPC pipe. The
1552 mapping identified so far is:</emphasis></para>
1557 <term>initial SMBopenX request:</term>
1558 <listitem><para>RPC_ResBind response:</para></listitem>
1562 <term>"\\PIPE\\srvsvc"</term>
1563 <listitem><para>"\\PIPE\\ntsvcs"</para></listitem>
1566 <term>"\\PIPE\\samr"</term>
1567 <listitem><para>"\\PIPE\\lsass"</para></listitem>
1570 <term>"\\PIPE\\lsarpc"</term>
1571 <listitem><para>"\\PIPE\\lsass"</para></listitem>
1574 <term>"\\PIPE\\wkssvc"</term>
1575 <listitem><para>"\\PIPE\\wksvcs"</para></listitem>
1578 <term>"\\PIPE\\NETLOGON"</term>
1579 <listitem><para>"\\PIPE\\NETLOGON"</para></listitem>
1583 <para><emphasis>Note: The RPC_Packet fraglength member in both the Bind Request and Bind Acknowledgment must contain the length of the entire RPC data, including the RPC_Packet header.</emphasis></para>
1585 <para>Request:</para>
1588 <member>RPC_Packet</member>
1589 <member>RPC_ReqBind</member>
1592 <para>Response:</para>
1594 <member>RPC_Packet</member>
1595 <member>RPC_ResBind</member>
1601 <title>NTLSA Transact Named Pipe</title>
1603 <para>The sequence of actions taken on this pipe are:</para>
1606 <member>Establish a connection to the IPC$ share (SMBtconX). use encrypted passwords.</member>
1607 <member>Open an RPC Pipe with the name "\\PIPE\\lsarpc". Store the file handle.</member>
1608 <member>Using the file handle, send a Set Named Pipe Handle state to 0x4300.</member>
1609 <member>Send an LSA Open Policy request. Store the Policy Handle.</member>
1610 <member>Using the Policy Handle, send LSA Query Info Policy requests, etc.</member>
1611 <member>Using the Policy Handle, send an LSA Close.</member>
1612 <member>Close the IPC$ share.</member>
1615 <para>Defines for this pipe, identifying the query are:</para>
1618 <term>LSA Open Policy:</term>
1619 <listitem><para>0x2c</para></listitem>
1622 <term>LSA Query Info Policy:</term>
1623 <listitem><para>0x07</para></listitem>
1626 <term>LSA Enumerate Trusted Domains:</term>
1627 <listitem><para>0x0d</para></listitem>
1630 <term>LSA Open Secret:</term>
1631 <listitem><para>0xff</para></listitem>
1634 <term>LSA Lookup SIDs:</term>
1635 <listitem><para>0xfe</para></listitem>
1638 <term>LSA Lookup Names:</term>
1639 <listitem><para>0xfd</para></listitem>
1642 <term>LSA Close:</term>
1643 <listitem><para>0x00</para></listitem>
1650 <title>LSA Open Policy</title>
1652 <para><emphasis>Note: The policy handle can be anything you like.</emphasis></para>
1655 <title>Request</title>
1660 <listitem><para>buffer pointer</para></listitem>
1663 <term>UNISTR2</term>
1664 <listitem><para>server name - unicode string starting with two '\'s</para></listitem>
1667 <term>OBJ_ATTR</term>
1668 <listitem><para>object attributes</para></listitem>
1672 <listitem><para>1 - desired access</para></listitem>
1679 <title>Response</title>
1684 <term>POL_HND</term>
1685 <listitem><para>LSA policy handle</para></listitem>
1690 <listitem><para>0 - indicates success</para></listitem>
1700 <title>LSA Query Info Policy</title>
1702 <para><emphasis>Note: The info class in response must be the same as that in the request.</emphasis></para>
1705 <title>Request</title>
1709 <term>POL_HND</term>
1710 <listitem><para>LSA policy handle</para></listitem></varlistentry>
1713 <listitem><para>info class (also a policy handle?)</para></listitem></varlistentry>
1719 <title>Response</title>
1724 <listitem><para>undocumented buffer pointer</para></listitem>
1728 <listitem><para>info class (same as info class in request).</para></listitem>
1733 <para><programlisting>
1738 DOM_INFO domain info, levels 3 and 5 (are the same).
1741 return 0 - indicates success
1742 </programlisting></para>
1749 <title>LSA Enumerate Trusted Domains</title>
1752 <title>Request</title>
1754 <para>no extra data</para>
1759 <title>Response</title>
1764 <listitem><para>0 - enumeration context</para></listitem>
1768 <listitem><para>0 - entries read</para></listitem>
1772 <listitem><para>0 - trust information</para></listitem>
1776 <listitem><para>0x8000 001a - "no trusted domains" success code</para></listitem>
1784 <title>LSA Open Secret</title>
1787 <title>Request</title>
1789 <para>no extra data</para>
1794 <title>Response</title>
1799 <listitem><para>0 - undocumented</para></listitem>
1803 <listitem><para>0 - undocumented</para></listitem>
1807 <listitem><para>0 - undocumented</para></listitem>
1811 <listitem><para>0 - undocumented</para></listitem>
1815 <listitem><para>0 - undocumented</para></listitem>
1819 <para>return 0x0C00 0034 - "no such secret" success code</para>
1826 <title>LSA Close</title>
1829 <title>Request</title>
1833 <term>POL_HND</term>
1834 <listitem><para>policy handle to be closed</para></listitem>
1841 <title>Response</title>
1845 <term>POL_HND</term>
1846 <listitem><para>0s - closed policy handle (all zeros)</para></listitem></varlistentry>
1849 <para>return 0 - indicates success</para>
1855 <title>LSA Lookup SIDS</title>
1857 <para><emphasis>Note: num_entries in response must be same as num_entries in request.</emphasis></para>
1860 <title>Request</title>
1864 <term>POL_HND</term>
1865 <listitem><para>LSA policy handle</para></listitem>
1869 <listitem><para>num_entries</para></listitem>
1873 <listitem><para>undocumented domain SID buffer pointer</para></listitem>
1877 <listitem><para>undocumented domain name buffer pointer</para></listitem>
1880 <term>VOID*[num_entries] undocumented domain SID pointers to be looked up.
1882 <listitem><para>DOM_SID[num_entries] domain SIDs to be looked up.</para></listitem></varlistentry>
1884 <term>char[16]</term>
1885 <listitem><para>completely undocumented 16 bytes.</para></listitem>
1892 <title>Response</title>
1896 <term>DOM_REF</term>
1897 <listitem><para>domain reference response</para></listitem></varlistentry>
1900 <listitem><para>num_entries (listed above)</para></listitem></varlistentry>
1903 <listitem><para>undocumented buffer pointer</para></listitem></varlistentry>
1906 <listitem><para>num_entries (listed above)</para></listitem></varlistentry>
1908 <term>DOM_SID2[num_entries]</term>
1909 <listitem><para>domain SIDs (from Request, listed above).</para></listitem></varlistentry>
1912 <listitem><para>num_entries (listed above)</para></listitem></varlistentry>
1915 <para>return 0 - indicates success</para>
1922 <title>LSA Lookup Names</title>
1924 <para><emphasis>Note: num_entries in response must be same as num_entries in request.</emphasis></para>
1927 <title>Request</title>
1931 <term>POL_HND</term>
1932 <listitem><para>LSA policy handle</para></listitem>
1936 <listitem><para>num_entries</para></listitem>
1940 <listitem><para>num_entries</para></listitem>
1944 <listitem><para>undocumented domain SID buffer pointer</para></listitem>
1948 <listitem><para>undocumented domain name buffer pointer</para></listitem>
1951 <term>NAME[num_entries]</term>
1952 <listitem><para>names to be looked up.</para></listitem>
1956 <listitem><para>undocumented bytes - falsely translated SID structure?</para></listitem>
1963 <title>Response</title>
1967 <term>DOM_REF</term>
1968 <listitem><para>domain reference response</para></listitem></varlistentry>
1971 <listitem><para>num_entries (listed above)</para></listitem></varlistentry>
1974 <listitem><para>undocumented buffer pointer</para></listitem></varlistentry>
1977 <listitem><para>num_entries (listed above)</para></listitem></varlistentry>
1979 <term>DOM_RID[num_entries]</term>
1980 <listitem><para>domain SIDs (from Request, listed above).</para></listitem></varlistentry>
1983 <listitem><para>num_entries (listed above)</para></listitem></varlistentry>
1986 <para>return 0 - indicates success</para>
1993 <title>NETLOGON rpc Transact Named Pipe</title>
1995 <para>The sequence of actions taken on this pipe are:</para>
1998 <member>tablish a connection to the IPC$ share (SMBtconX). use encrypted passwords.</member>
1999 <member>en an RPC Pipe with the name "\\PIPE\\NETLOGON". Store the file handle.</member>
2000 <member>ing the file handle, send a Set Named Pipe Handle state to 0x4300.</member>
2001 <member>eate Client Challenge. Send LSA Request Challenge. Store Server Challenge.</member>
2002 <member>lculate Session Key. Send an LSA Auth 2 Challenge. Store Auth2 Challenge.</member>
2003 <member>lc/Verify Client Creds. Send LSA Srv PW Set. Calc/Verify Server Creds.</member>
2004 <member>lc/Verify Client Creds. Send LSA SAM Logon . Calc/Verify Server Creds.</member>
2005 <member>lc/Verify Client Creds. Send LSA SAM Logoff. Calc/Verify Server Creds.</member>
2006 <member>ose the IPC$ share.</member>
2009 <para>Defines for this pipe, identifying the query are</para>
2013 <term>LSA Request Challenge:</term>
2014 <listitem><para>0x04</para></listitem>
2017 <term>LSA Server Password Set:</term>
2018 <listitem><para>0x06</para></listitem>
2021 <term>LSA SAM Logon:</term>
2022 <listitem><para>0x02</para></listitem>
2025 <term>LSA SAM Logoff:</term>
2026 <listitem><para>0x03</para></listitem>
2029 <term>LSA Auth 2:</term>
2030 <listitem><para>0x0f</para></listitem>
2033 <term>LSA Logon Control:</term>
2034 <listitem><para>0x0e</para></listitem>
2039 <title>LSA Request Challenge</title>
2041 <para><emphasis>Note: logon server name starts with two '\' characters and is upper case.</emphasis></para>
2043 <para><emphasis>Note: logon client is the machine, not the user.</emphasis></para>
2045 <para><emphasis>Note: the initial LanManager password hash, against which the challenge is issued, is the machine name itself (lower case). there will becalls issued (LSA Server Password Set) which will change this, later. refusing these calls allows you to always deal with the same password (i.e the LM# of the machine name in lower case).</emphasis></para>
2048 <title>Request</title>
2053 <listitem><para>undocumented buffer pointer</para></listitem>
2056 <term>UNISTR2</term>
2057 <listitem><para>logon server unicode string</para></listitem>
2060 <term>UNISTR2</term>
2061 <listitem><para>logon client unicode string</para></listitem>
2064 <term>char[8]</term>
2065 <listitem><para>client challenge</para></listitem>
2072 <title>Response</title>
2076 <term>char[8]</term>
2077 <listitem><para>server challenge</para></listitem>
2081 <para>return 0 - indicates success</para>
2088 <title>LSA Authenticate 2</title>
2090 <para><emphasis>Note: in between request and response, calculate the client credentials, and check them against the client-calculated credentials (this process uses the previously received client credentials).</emphasis></para>
2092 <para><emphasis>Note: neg_flags in the response is the same as that in the request.</emphasis></para>
2094 <para><emphasis>Note: you must take a copy of the client-calculated credentials received here, because they will be used in subsequent authentication packets.</emphasis></para>
2097 <title>Request</title>
2101 <term>LOG_INFO</term>
2102 <listitem><para>client identification info</para></listitem>
2105 <term>char[8]</term>
2106 <listitem><para>client-calculated credentials</para></listitem>
2109 <term>UINT8[]</term>
2110 <listitem><para>padding to 4-byte align with start of SMB header.</para></listitem></varlistentry>
2113 <listitem><para>neg_flags - negotiated flags (usual value is 0x0000 01ff)</para></listitem></varlistentry>
2119 <title>Response</title>
2123 <term>char[8]</term>
2124 <listitem><para>server credentials.</para></listitem>
2128 <listitem><para>neg_flags - same as neg_flags in request.</para></listitem>
2132 <para>return 0 - indicates success. failure value unknown.</para>
2139 <title>LSA Server Password Set</title>
2141 <para><emphasis>Note: the new password is suspected to be a DES encryption using the old password to generate the key.</emphasis></para>
2143 <para><emphasis>Note: in between request and response, calculate the client credentials, and check them against the client-calculated credentials (this process uses the previously received client credentials).</emphasis></para>
2145 <para><emphasis>Note: the server credentials are constructed from the client-calculated credentials and the client time + 1 second.</emphasis></para>
2147 <para><emphasis>Note: you must take a copy of the client-calculated credentials received here, because they will be used in subsequent authentication packets.</emphasis></para>
2150 <title>Request</title>
2154 <term>CLNT_INFO</term>
2155 <listitem><para>client identification/authentication info</para></listitem>
2159 <listitem><para>new password - undocumented.</para></listitem>
2166 <title>Response</title>
2171 <listitem><para>server credentials. server time stamp appears to be ignored.</para></listitem>
2175 <para>return 0 - indicates success; 0xC000 006a indicates failure</para>
2181 <title>LSA SAM Logon</title>
2184 Note: valid_user is True iff the username and password hash are valid for
2185 the requested domain.
2189 <title>Request</title>
2192 <term>SAM_INFO</term>
2193 <listitem><para>sam_id structure</para></listitem>
2200 <title>Response</title>
2205 <listitem><para>undocumented buffer pointer</para></listitem>
2209 <listitem><para>server credentials. server time stamp appears to be ignored.</para></listitem>
2213 <para><programlisting>
2216 UINT16 3 - switch value indicating USER_INFO structure.
2217 VOID* non-zero - pointer to USER_INFO structure
2218 USER_INFO user logon information
2220 UINT32 1 - Authoritative response; 0 - Non-Auth?
2222 return 0 - indicates success
2226 UINT16 0 - switch value. value to indicate no user presumed.
2227 VOID* 0x0000 0000 - indicates no USER_INFO structure.
2229 UINT32 1 - Authoritative response; 0 - Non-Auth?
2231 return 0xC000 0064 - NT_STATUS_NO_SUCH_USER.
2233 </programlisting></para>
2240 <title>LSA SAM Logoff</title>
2243 Note: presumably, the SAM_INFO structure is validated, and a (currently
2244 undocumented) error code returned if the Logoff is invalid.
2248 <title>Request</title>
2252 <term>SAM_INFO</term>
2253 <listitem><para>sam_id structure</para></listitem>
2260 <title>Response</title>
2265 <listitem><para>undocumented buffer pointer</para></listitem>
2269 <listitem><para>server credentials. server time stamp appears to be ignored.</para></listitem>
2273 <para>return 0 - indicates success. undocumented failure indication.</para>
2280 <title>\\MAILSLOT\NET\NTLOGON</title>
2283 Note: mailslots will contain a response mailslot, to which the response
2284 should be sent. the target NetBIOS name is REQUEST_NAME<20>, where
2285 REQUEST_NAME is the name of the machine that sent the request.
2289 <title>Query for PDC</title>
2291 <para><emphasis>Note: NTversion, LMNTtoken, LM20token in response are the same as those given in the request.</emphasis></para>
2294 <title>Request</title>
2299 <listitem><para>0x0007 - Query for PDC</para></listitem>
2303 <listitem><para>machine name</para></listitem>
2307 <listitem><para>response mailslot</para></listitem>
2310 <term>UINT8[]</term>
2311 <listitem><para>padding to 2-byte align with start of mailslot.</para></listitem>
2315 <listitem><para>machine name</para></listitem>
2319 <listitem><para>NTversion</para></listitem>
2323 <listitem><para>LMNTtoken</para></listitem>
2327 <listitem><para>LM20token</para></listitem>
2334 <title>Response</title>
2339 <listitem><para>0x000A - Respose to Query for PDC</para></listitem></varlistentry>
2342 <listitem><para>machine name (in uppercase)</para></listitem></varlistentry>
2344 <term>UINT8[]</term>
2345 <listitem><para>padding to 2-byte align with start of mailslot.</para></listitem>
2349 <listitem><para>machine name</para></listitem>
2353 <listitem><para>domain name</para></listitem></varlistentry>
2356 <listitem><para>NTversion (same as received in request)</para></listitem></varlistentry>
2359 <listitem><para>LMNTtoken (same as received in request)</para></listitem></varlistentry>
2362 <listitem><para>LM20token (same as received in request)</para></listitem></varlistentry>
2369 <title>SAM Logon</title>
2371 <para><emphasis>Note: machine name in response is preceded by two '\' characters.</emphasis></para>
2373 <para><emphasis>Note: NTversion, LMNTtoken, LM20token in response are the same as those given in the request.</emphasis></para>
2375 <para><emphasis>Note: user name in the response is presumably the same as that in the request.</emphasis></para>
2378 <title>Request</title>
2383 <listitem><para>0x0012 - SAM Logon</para></listitem>
2387 <listitem><para>request count</para></listitem>
2391 <listitem><para>machine name</para></listitem>
2395 <listitem><para>user name</para></listitem>
2399 <listitem><para>response mailslot</para></listitem>
2403 <listitem><para>alloweable account</para></listitem>
2407 <listitem><para>domain SID size</para></listitem>
2410 <term>char[sid_size]</term>
2411 <listitem><para>domain SID, of sid_size bytes.</para></listitem>
2414 <term>UINT8[]</term>
2415 <listitem><para>???? padding to 4? 2? -byte align with start of mailslot.</para></listitem>
2419 <listitem><para>NTversion</para></listitem>
2423 <listitem><para>LMNTtoken</para></listitem>
2427 <listitem><para>LM20token</para></listitem>
2434 <title>Response</title>
2439 <listitem><para>0x0013 - Response to SAM Logon</para></listitem>
2443 <listitem><para>machine name</para></listitem>
2447 <listitem><para>user name - workstation trust account</para></listitem>
2451 <listitem><para>domain name </para></listitem>
2455 <listitem><para>NTversion</para></listitem>
2459 <listitem><para>LMNTtoken</para></listitem>
2463 <listitem><para>LM20token</para></listitem>
2472 <title>SRVSVC Transact Named Pipe</title>
2474 <para>Defines for this pipe, identifying the query are:</para>
2478 <term>Net Share Enum</term>
2479 <listitem><para>0x0f</para></listitem>
2482 <term>Net Server Get Info</term>
2483 <listitem><para>0x15</para></listitem>
2489 <title>Net Share Enum</title>
2491 <para><emphasis>Note: share level and switch value in the response are presumably the same as those in the request.</emphasis></para>
2493 <para><emphasis>Note: cifsrap2.txt (section 5) may be of limited assistance here.</emphasis></para>
2496 <title>Request</title>
2501 <listitem><para>pointer (to server name?)</para></listitem></varlistentry>
2503 <term>UNISTR2</term>
2504 <listitem><para>server name</para></listitem>
2507 <term>UINT8[]</term>
2508 <listitem><para>padding to get unicode string 4-byte aligned with the start of the SMB header.</para></listitem>
2512 <listitem><para>share level</para></listitem>
2516 <listitem><para>switch value</para></listitem>
2520 <listitem><para>pointer to SHARE_INFO_1_CTR</para></listitem>
2523 <term>SHARE_INFO_1_CTR</term>
2524 <listitem><para>share info with 0 entries</para></listitem>
2528 <listitem><para>preferred maximum length (0xffff ffff)</para></listitem></varlistentry>
2533 <title>Response</title>
2538 <listitem><para>share level</para></listitem>
2542 <listitem><para>switch value</para></listitem>
2546 <listitem><para>pointer to SHARE_INFO_1_CTR</para></listitem></varlistentry>
2548 <term>SHARE_INFO_1_CTR</term>
2549 <listitem><para>share info (only added if share info ptr is non-zero)</para></listitem></varlistentry>
2552 <para>return 0 - indicates success</para>
2558 <title>Net Server Get Info</title>
2560 <para><emphasis>Note: level is the same value as in the request.</emphasis></para>
2563 <title>Request</title>
2567 <term>UNISTR2</term>
2568 <listitem><para>server name</para></listitem>
2572 <listitem><para>switch level</para></listitem>
2579 <title>Response</title>
2584 <listitem><para>switch level</para></listitem>
2588 <listitem><para>pointer to SERVER_INFO_101</para></listitem>
2591 <term>SERVER_INFO_101</term>
2592 <listitem><para>server info (only added if server info ptr is non-zero)</para></listitem></varlistentry>
2595 <para>return 0 - indicates success</para>
2602 <title>Cryptographic side of NT Domain Authentication</title>
2605 <title>Definitions</title>
2609 <term>Add(A1,A2)</term>
2610 <listitem><para>Intel byte ordered addition of corresponding 4 byte words in arrays A1 and A2</para></listitem>
2615 <listitem><para>DES ECB encryption of 8 byte data D using 7 byte key K</para></listitem>
2619 <term>lmowf()</term>
2620 <listitem><para>Lan man hash</para></listitem>
2624 <term>ntowf()</term>
2625 <listitem><para>NT hash</para></listitem>
2630 <listitem><para>md4(machine_password) == md4(lsadump $machine.acc) ==
2631 pwdump(machine$) (initially) == md4(lmowf(unicode(machine)))
2636 <term>ARC4(K,Lk,D,Ld)</term>
2637 <listitem><para>ARC4 encryption of data D of length Ld with key K of length Lk</para></listitem>
2641 <term>v[m..n(,l)]</term>
2642 <listitem><para>subset of v from bytes m to n, optionally padded with zeroes to length l</para></listitem>
2646 <term>Cred(K,D)</term>
2647 <listitem><para>E(K[7..7,7],E(K[0..6],D)) computes a credential</para></listitem>
2652 <listitem><para>4 byte current time</para></listitem>
2657 <listitem><para>8 byte client and server challenges Rc,Rs: 8 byte client and server credentials</para></listitem>
2665 <title>Protocol</title>
2673 C & S compute session key Ks = E(PW[9..15],E(PW[0..6],Add(Cc,Cs)))
2678 C->S Authenticate,Rc
2679 S: Rs = Cred(Ks,Cs), assert(Rc == Cred(Ks,Cc))
2681 C: assert(Rs == Cred(Ks,Cs))
2685 On joining the domain the client will optionally attempt to change its
2686 password and the domain controller may refuse to update it depending
2687 on registry settings. This will also occur weekly afterwards.
2691 C: Tc = Time(), Rc' = Cred(Ks,Rc+Tc)
2692 C->S ServerPasswordSet,Rc',Tc,arc4(Ks[0..7,16],lmowf(randompassword())
2693 C: Rc = Cred(Ks,Rc+Tc+1)
2694 S: assert(Rc' == Cred(Ks,Rc+Tc)), Ts = Time()
2695 S: Rs' = Cred(Ks,Rs+Tc+1)
2697 C: assert(Rs' == Cred(Ks,Rs+Tc+1))
2702 User: U with password P wishes to login to the domain (incidental data
2703 such as workstation and domain omitted)
2707 C: Tc = Time(), Rc' = Cred(Ks,Rc+Tc)
2708 C->S NetLogonSamLogon,Rc',Tc,U,arc4(Ks[0..7,16],16,ntowf(P),16), arc4(Ks[0..7,16],16,lmowf(P),16)
2709 S: assert(Rc' == Cred(Ks,Rc+Tc)) assert(passwords match those in SAM)
2714 S->C Cred(Ks,Cred(Ks,Rc+Tc+1)),userinfo(logon script,UID,SIDs,etc)
2715 C: assert(Rs == Cred(Ks,Cred(Rc+Tc+1))
2716 C: Rc = Cred(Ks,Rc+Tc+1)
2722 <title>Comments</title>
2725 On first joining the domain the session key could be computed by
2726 anyone listening in on the network as the machine password has a well
2727 known value. Until the machine is rebooted it will use this session
2728 key to encrypt NT and LM one way functions of passwords which are
2729 password equivalents. Any user who logs in before the machine has been
2730 rebooted a second time will have their password equivalent exposed. Of
2731 course the new machine password is exposed at this time anyway.
2735 None of the returned user info such as logon script, profile path and
2736 SIDs *appear* to be protected by anything other than the TCP checksum.
2740 The server time stamps appear to be ignored.
2744 The client sends a ReturnAuthenticator in the SamLogon request which I
2745 can't find a use for. However its time is used as the timestamp
2746 returned by the server.
2750 The password OWFs should NOT be sent over the network reversibly
2751 encrypted. They should be sent using ARC4(Ks,md4(owf)) with the server
2752 computing the same function using the owf values in the SAM.
2759 <title>SIDs and RIDs</title>
2762 SIDs and RIDs are well documented elsewhere.
2766 A SID is an NT Security ID (see DOM_SID structure). They are of the form:
2770 <member>revision-NN-SubAuth1-SubAuth2-SubAuth3... </member>
2771 <member>revision-0xNNNNNNNNNNNN-SubAuth1-SubAuth2-SubAuth3...</member>
2775 currently, the SID revision is 1.
2776 The Sub-Authorities are known as Relative IDs (RIDs).
2780 <title>Well-known SIDs</title>
2783 <title>Universal well-known SIDs</title>
2787 <term>Null SID</term>
2788 <listitem><para>S-1-0-0</para></listitem>
2792 <listitem><para>S-1-1-0</para></listitem>
2796 <listitem><para>S-1-2-0</para></listitem>
2799 <term>Creator Owner ID</term>
2800 <listitem><para>S-1-3-0</para></listitem>
2803 <term>Creator Group ID</term>
2804 <listitem><para>S-1-3-1</para></listitem>
2807 <term>Creator Owner Server ID</term>
2808 <listitem><para>S-1-3-2</para></listitem>
2811 <term>Creator Group Server ID</term>
2812 <listitem><para>S-1-3-3</para></listitem>
2815 <term>(Non-unique IDs)</term>
2816 <listitem><para>S-1-4</para></listitem>
2823 <title>NT well-known SIDs</title>
2827 <term>NT Authority</term>
2828 <listitem><para>S-1-5</para></listitem>
2832 <listitem><para>S-1-5-1</para></listitem>
2835 <term>Network</term>
2836 <listitem><para>S-1-5-2</para></listitem>
2840 <listitem><para>S-1-5-3</para></listitem>
2843 <term>Interactive</term>
2844 <listitem><para>S-1-5-4</para></listitem>
2847 <term>Service</term>
2848 <listitem><para>S-1-5-6</para></listitem></varlistentry>
2850 <term>AnonymousLogon(aka null logon session)</term>
2851 <listitem><para>S-1-5-7</para></listitem>
2855 <listitem><para>S-1-5-8</para></listitem></varlistentry>
2857 <term>ServerLogon(aka domain controller account)</term>
2858 <listitem><para>S-1-5-8</para></listitem>
2861 <term>(Logon IDs)</term>
2862 <listitem><para>S-1-5-5-X-Y</para></listitem>
2865 <term>(NT non-unique IDs)</term>
2866 <listitem><para>S-1-5-0x15-...</para></listitem>
2869 <term>(Built-in domain)</term>
2870 <listitem><para>s-1-5-0x20</para></listitem>
2878 <title>Well-known RIDS</title>
2881 A RID is a sub-authority value, as part of either a SID, or in the case
2882 of Group RIDs, part of the DOM_GID structure, in the USER_INFO_1
2883 structure, in the LSA SAM Logon response.
2887 <title>Well-known RID users</title>
2890 <segtitle>Groupname</segtitle>
2891 <segtitle>????</segtitle>
2892 <segtitle>RID</segtitle>
2893 <seglistitem><seg>DOMAIN_USER_RID_ADMIN</seg><seg>0x0000</seg><seg>01F4</seg></seglistitem>
2894 <seglistitem><seg>DOMAIN_USER_RID_GUEST</seg><seg>0x0000</seg><seg>01F5</seg></seglistitem>
2900 <title>Well-known RID groups</title>
2903 <segtitle>Groupname</segtitle>
2904 <segtitle>????</segtitle>
2905 <segtitle>RID</segtitle>
2906 <seglistitem><seg> DOMAIN_GROUP_RID_ADMINS</seg><seg>0x0000</seg><seg>0200</seg></seglistitem>
2907 <seglistitem><seg> DOMAIN_GROUP_RID_USERS</seg><seg>0x0000</seg><seg>0201</seg></seglistitem>
2908 <seglistitem><seg> DOMAIN_GROUP_RID_GUESTS</seg><seg>0x0000</seg><seg>0202</seg></seglistitem>
2914 <title>Well-known RID aliases</title>
2917 <segtitle>Groupname</segtitle>
2918 <segtitle>????</segtitle>
2919 <segtitle>RID</segtitle>
2920 <seglistitem><seg> DOMAIN_ALIAS_RID_ADMINS</seg><seg>0x0000</seg><seg>0220</seg></seglistitem>
2921 <seglistitem><seg> DOMAIN_ALIAS_RID_USERS</seg><seg>0x0000</seg><seg>0221</seg></seglistitem>
2922 <seglistitem><seg> DOMAIN_ALIAS_RID_GUESTS</seg><seg>0x0000</seg><seg>0222</seg></seglistitem>
2923 <seglistitem><seg> DOMAIN_ALIAS_RID_POWER_USERS</seg><seg>0x0000</seg><seg>0223</seg></seglistitem>
2924 <seglistitem><seg> DOMAIN_ALIAS_RID_ACCOUNT_OPS</seg><seg>0x0000</seg><seg>0224</seg></seglistitem>
2925 <seglistitem><seg> DOMAIN_ALIAS_RID_SYSTEM_OPS</seg><seg>0x0000</seg><seg>0225</seg></seglistitem>
2926 <seglistitem><seg> DOMAIN_ALIAS_RID_PRINT_OPS</seg><seg>0x0000</seg><seg>0226</seg></seglistitem>
2927 <seglistitem><seg> DOMAIN_ALIAS_RID_BACKUP_OPS</seg><seg>0x0000</seg><seg>0227</seg></seglistitem>
2928 <seglistitem><seg> DOMAIN_ALIAS_RID_REPLICATOR</seg><seg>0x0000</seg><seg>0228</seg></seglistitem>