Home > Articles > Networking > Network Design & Architecture

This chapter is from the book

13.3 Gesundheit: The NEGOTIATE PROTOCOL RESPONSE

The NEGOTIATE PROTOCOL RESPONSE SMB is more complex than the request. In addition to the dialect selection, it also contains a variety of other parameters that let the client know the capabilities, limitations, and expectations of the server. Most of these values are stuffed into the SMB_PARAMETERS block, but there are a few fields defined in the SMB_DATA block as well.

13.3.1 NegProt Response Parameters

The NEGOTIATE_PROTOCOL_RESPONSE.SMB_PARAMETERS.Words block for the NT LM 0.12 dialect is 17 words (34 bytes) in size, and is structured as shown below. Earlier dialects use a different structure and, of course, the server should always match the reply to the dialect it selects.

typedef struct
  {
  uchar WordCount;              /* Always 17 for this struct */
  struct
    {
    ushort DialectIndex;        /* Selected dialect index    */
    uchar  SecurityMode;        /* Server security flags     */
    ushort MaxMpxCount;         /* Maximum Multiplex Count   */
    ushort MaxNumberVCs;        /* Maximum Virtual Circuits  */
    ulong  MaxBufferSize;       /* Maximum SMB message size  */
    ulong  MaxRawSize;          /* Obsolete                  */
    ulong  SessionKey;          /* Unique session ID         */
    ulong  Capabilities;        /* Server capabilities flags */
    ulong  SystemTimeLow;       /* Server time; low bytes    */
    ulong  SystemTimeHigh;      /* Server time; high bytes   */
    short  ServerTimeZone;      /* Minutes from UTC; signed  */
    uchar  EncryptionKeyLength; /* 0 or 8                    */
    } Words;
  } smb_NegProt_Rsp_Params;

That requires a lot of discussion. Let’s tear it up and take a close look at the tiny pieces.

DialectIndex

  • Things start off fairly simply. The DialectIndex field contains the index of the dialect string that the server has selected, which will be the highest-level dialect that the server understands. The dialect strings are numbered starting with zero, so to choose “NT LM 0.12” from the list in the example request the server would return 7 in the DialectIndex field.

SecurityMode

  • SecurityMode is a bitfield that provides some information about the authentication sub-protocol that the server is expecting. Four flag bits are defined; they are described below. Challenge/Response and Message Authentication Code (MAC) message signing will be explained later (this is becoming our mantra), when we cover authentication. It will take a little while to get there, but keep your eyes open for additional clues along the way.

Bit

Name / Bitmask / Values

Description

7–4

0xF0

<Reserved> (must be zero)

3

NEGOTIATE_SECURITY_SIGNATURES_REQUIRED

0x08

0: Message signing is optional

1: Message signing is required

If set, this bit indicates that the server is requiring the use of a Message Authentication Code (MAC) in each packet. If the bit is clear then message signing is optional.

This bit should be zero if the next bit (mask 0x04) is zero.

2

NEGOTIATE_SECURITY_SIGNATURES_ENABLED

0x04

0: Message signing not supported

1: Server can perform message signing

If set, the server is indicating that it is capable of performing Message Authentication Code (MAC) message signing.

This bit should be zero if the next bit (mask 0x02) is zero.

1

NEGOTIATE_SECURITY_CHALLENGE_RESPONSE

0x02

0: Plaintext Passwords

1: Challenge/Response

This bit indicates whether or not the server supports Challenge/Response authentication (which will be covered further on). If the bit is clear, then plaintext passwords must be used. If set, the server may (optionally) reject plaintext authentication.

If this bit is clear and the client rejects the use of plaintext, then there is no way to perform the logon and the client will be unable to connect to the server.

0

NEGOTIATE_SECURITY_USER_LEVEL

0x01

0: Share Level

1: User Level

Ah! Finally something we’ve already covered!

This bit indicates whether the server, as a whole, is operating under Share Level or User Level security. Share and User Level security were explained along with the TID and UID header fields, back in Section 12.4 on page 209.

MaxMpxCount

  • Remember the PID and MID fields in the header? They could be used to multiplex several sessions over a single TCP/IP connection. The thing is, the server might not be able to handle more than a fixed number of total outstanding requests.

  • The MaxMpxCount field lets the server tell the client how many requests, in total, it can handle concurrently. It is the client’s responsibility to ensure that there are no more than MaxMpxCount outstanding requests in the pipe at any time. That may mean that client processes will block, waiting for their turn to send an SMB.

MaxNumberVCs

  • The MaxNumberVCs field specifies the maximum number of Virtual Circuits (VCs) that the server is able to accommodate. VCs are yet another mechanism by which multiple SMB sessions could, in theory, be multiplexed over a single transport-layer session. Note the use of the phrase “in theory.” The dichotomy between theory and practice is a recurring theme in the study of CIFS.

MaxBufferSize

  • MaxBufferSize is the size (in bytes) of the largest message that the server can receive.

  • Keep in mind that the transport layer will fragment and defragment packets as necessary. It is, therefore, possible to send very large SMBs and let the lower layers worry about ensuring safe, fast, reliable delivery.

  • How big can an SMB message be?

  • In the NT LM 0.12 dialect, the MaxBufferSize field is an unsigned longword. As described much earlier on, however, the Length field in the NBT SESSION MESSAGE is 17 bits wide and the naked transport header has a 24-bit Length field. So the session headers place slightly more reasonable limits on the maximum size of a single SMB message.

MaxRawSize

  • This is the maximum size of a raw data buffer.

  • The X/Open doc describes the READ RAW and WRITE RAW SMBs, which were introduced with the Extended 1.0 version of SMB (the MICROSOFT NETWORKS 3.0 and LANMAN1.0 dialects). These were a speed hack. For a large read or write operation, the first message would be a proper SMB, but subsequent messages would be sent in “raw” mode, with no SMB or session header. The raw blocks could be as large as MaxRawSize bytes in length. Once again, the transport layer was expected to take care of fragmentation/defragmentation as well as resending of any lost packets.

  • Raw mode is not used much any more. Among other things, it conflicts with message signing because the raw messages have no header in which to put the MAC Signature. Thus, the MaxRawSize field is considered obsolete.2

SessionKey

  • The SessionKey is supposed to be used to identify the session in which a VC has been opened. Documentation on the use of this field is very poor, however, and the commentary in various mailing list archives shows that there is not much agreement about what to do with it.

  • In theory, the SessionKey value should be echoed back to the server whenever the client sends a SESSION SETUP request. Samba’s smbclient does this, but some versions of jCIFS always reply with zero, and they don’t seem to have any trouble with it. In testing, it also appears that Windows 2000 servers do not generate a session key. They send zero in NEGOTIATE PROTOCOL RESPONSE messages. Hmmm...

  • It would seem that the use of this field was never clearly defined — anywhere by anyone — and that most servers really don’t care what goes there. It is probably safest if the client echoes back the value sent by the server.

Capabilities

  • This is a grab-bag bitfield, similar in style to the FLAGS and FLAGS2 fields in the header except, of course, that it is not included in every message. The bits of the Capabilities field indicate specific server features of which the client may choose to take advantage.

  • We are already building up a backlog of unexplained features. We will also postpone the discussion of the Capabilities field until we get some of the other stuff out of the way.

SystemTimeLow and SystemTimeHigh

  • The SystemTime fields are shown as two unsigned longs in the SNIA doc. We might write it as:

    typedef struct
      {
      ulong timeLow;
      ulong timeHigh;
      } smb_Time;
    

    Keeping byte order in mind, the completed time value should be read as two little-endian 32-bit integers. The result, however, should be handled as a 64-bit signed value representing the number of tenths of a microsecond since January 1, 1601, 00:00:00.0 UTC.

    WHAT?!?!

    Yes, you read that right folks. The time value is based on that unwieldy little formula. Read it again five times and see if you don’t get a headache. Looks as though we need to get out the protractor, the astrolabe, and the didgeridoo and try a little calculating. Let’s start with some complex scientific equations:

    • 1 microsecond = 10–6 seconds,

    • 1/10 microsecond = 10–7 seconds.

    In other words, the server time is given in units of 10–7 seconds.3 Many CIFS implementations handle these units by converting them into Unix-style measurements. Unix, of course, bases its time measurements on an equally obscure date: January 1, 1970, 00:00:00.0 UTC.4 Converting between the two schemes requires knowing the difference (in seconds) between the two base times.

    Email

    email.gif

           From: Andrew Narver
    
    In-Reply-To: A message from Mike Allen sent to Microsoft's CIFS
                 mailing list and the Samba-Technical mailing list.
    
    > (what's the number of seconds between 1601 and 1970 again?)
    
    Between Jan 1, 1601 and Jan 1, 1970, you have 369 complete
    years, of which 89 are leap years (1700, 1800, and 1900 were
    not leap years). That gives you a total of 134774 days or
    11644473600 seconds.

    So, if you want to convert the SystemTime to a Unix time_t value, you need to do something like this:

    unix_time = (time_t)(((smb_time)/10000000) - 11644473600);
    

    which gives you the server’s system time in seconds since January 1, 1970, 00:00:00.0 UTC.

ServerTimeZone

  • ServerTimeZone, of course, is the timezone in which the server believes it resides. It is represented as an offset relative to UTC, in minutes. Minutes, that is. Multiply by 60 in order to get seconds, or 600,000,000 to get tenths of a microsecond.

  • The available documentation (the SNIA doc and the Leach/Naik IETF draft) states that this field is an unsigned short integer. They’re wrong. The field is a signed value which is subtracted from the SystemTime to give local time.

  • If, for example, your server is located in the beautiful city of Saint Paul, Minnesota, it would be in the US Central timezone5 which is six hours west of UTC. The value in the ServerTimeZone field would, therefore be 360 minutes. (Except, of course, during the summer when Daylight Savings Time is in effect, in which case it would be 300 minutes.) On the other hand, if your server is in Moscow in the winter, the ServerTimeZone value would be –180.

  • The basic rule of thumb:

  • LocalTime = SystemTime - ( ServerTimeZone × 600000000 )
    

  • ...which returns local time in units of 10–7 seconds, based on January 1601 as described above.

  • If you found all of that to be complicated, you will be relieved to know that this is only one of many different time formats used in SMB. Time And Date Encoding is covered in Section 3.7 of the SNIA doc.

EncryptionKeyLength

  • This is the last field in the NEGOTIATE_PROTOCOL_RESPONSE.SMB_PARAMETERS block. It provides the length, in bytes, of the Challenge used in Challenge/Response authentication. SMB Challenges, if present, are always 8 bytes long, so the EncryptionKeyLength will have a value of either 8 or 0 — the latter if Challenge/Response authentication is not in use.

  • The name of this field is probably a hold-over from some previous enhancement to the protocol — still in use for “historical reasons.”

Wow... a lot of stuff there. No time to sit and chat about it right now, though. We still need to finish out the examination of the NEGOTIATE_PROTOCOL_RESPONSE.SMB_DATA block.

13.3.2 NegProt Response Data

SMB_DATA, of course, is handed to us as an array of bytes with the length provided in the ByteCount field. The parsing of those bytes depends upon the values in the SMB_PARAMETER block that we just examined. The structure is completely different depending upon whether Extended Security has been negotiated.

Here is what it looks like, more or less, in the NT LM 0.12 dialect:

typedef struct
  {
  ushort ByteCount;          /* Number of bytes to follow  */
  union
    {
    struct
      {
      uchar GUID[16];        /* 16-byte Globally Unique ID */
      uchar SecurityBlob[];  /* Auth-system dependent      */
      } ext_sec;             /* Extended Security          */
    struct
      {
      uchar EncryptionKey[]; /* 0 or 8 bytes long          */
      uchar DomainName[];    /* nul-terminated string      */
      } non_ext_sec;         /* Non-Extended Security      */
    } Bytes;
  } smb_NegProt_Rsp_Data;

The first thing to note is that this SMB_DATA.Bytes block structure is the union of two smaller structures:

  • ext_sec is used if Extended Security has been negotiated,

  • non_ext_sec is used otherwise.

The second thing to note is that this is pseudo-code, not valid C code. Some of the array lengths are unspecified because we don’t know the byte-length of the fields ahead of time. In real code, you will probably need to use pointers or some other mechanism to extract the variable-length data from the buffer.

Okay, let’s chop that structure into little bits...

GUID

  • GUID stands for Globally Unique IDentifier. The GUID field is always 16 bytes long.

  • As of this writing, research by Samba Team members shows that this value is probably the same as the GUID identifier used by Active Directory to keep track of servers in the database. Standalone servers (which are not listed in any Active Directory) also generate and use a GUID. Go figure.

  • Though this field is only present when Extended Security is enabled, it is not, strictly speaking, a security field. The value is well known and easily forged. It is not clear (yet) why this field is even sent to the client. In testing, a Samba server was configured to fill the GUID field with its own 16-byte Server Service NetBIOS name... and that worked just fine.

SecurityBlob

  • The SecurityBlob is — as the name says — a blob of security information. In other words, it is a block of data that contains authentication information particular to the Extended Security mechanism being used. Obviously, this field will need to be covered in the Authentication section.

  • The SecurityBlob is variable in length. Fortunately, the GUID field is always 16 bytes, so the length of the SecurityBlob is (ByteCount - 16) bytes.

EncryptionKey

  • This field should be called Challenge because that’s what it actually contains — the Challenge used in Challenge/Response authentication. The SMB Challenge, if present, is always eight bytes long. If plaintext passwords are in use then there is no Challenge, the EncryptionKey will be empty, and the SMB_PARAMETERS.EncryptionKeyLength field will contain 0.

DomainName

  • This field sometimes contains the NetBIOS name of the Workgroup or NT Domain to which the server belongs. (We have talked a bit, in previous sections, about Workgroups and NT Domains so the terms should be somewhat familiar.) In testing, Samba servers always provided a name in the DomainName field; Windows systems less reliably so. Windows 98, for example, would sometimes provide a value and sometimes not.6

    The SNIA doc calls this field the OEMDomainName and claims that the characters will be eight-bit values using the OEM character set of the server (that’s the 7-bit ASCII character set augmented by an extended DOS code page which defines characters for the upper 128 octet values). In fact, this field may contain either a string of 8-bit OEM characters or a Unicode string with 16-bit characters. The value of SMB_HEADER.FLAGS2.SMB_FLAGS2_UNICODE_STRINGS will let you know how to read the DomainName field.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020