|
| 1 | +<p align="center"> |
| 2 | + <h1 align="center"><b>adauth</b></h1> |
| 3 | + <p align="center"><i>Active Directory Authentication Library</i></p> |
| 4 | + <p align="center"> |
| 5 | + <a href="https://github.com/RedTeamPentesting/adauth/releases/latest"><img alt="Release" src="https://img.shields.io/github/release/RedTeamPentesting/adauth.svg?style=for-the-badge"></a> |
| 6 | + <a href="https://pkg.go.dev/github.com/RedTeamPentesting/adauth"><img alt="Go Doc" src="https://img.shields.io/badge/godoc-reference-blue.svg?style=for-the-badge"></a> |
| 7 | + <a href="https://github.com/RedTeamPentesting/adauth/actions?workflow=Check"><img alt="GitHub Action: Check" src="https://img.shields.io/github/actions/workflow/status/RedTeamPentesting/adauth/check.yml?branch=main&style=for-the-badge"></a> |
| 8 | + <a href="/LICENSE"><img alt="Software License" src="https://img.shields.io/badge/license-MIT-brightgreen.svg?style=for-the-badge"></a> |
| 9 | + <a href="https://goreportcard.com/report/github.com/RedTeamPentesting/adauth"><img alt="Go Report Card" src="https://goreportcard.com/badge/github.com/RedTeamPentesting/adauth?style=for-the-badge"></a> |
| 10 | + </p> |
| 11 | +</p> |
| 12 | + |
| 13 | + |
| 14 | +**Warning: The API of this library is not yet stable. Expect breaking changes.** |
| 15 | + |
| 16 | +`adauth` is a Go library for active directory authentication. It can be used to |
| 17 | +quickly set up authentication options: |
| 18 | + |
| 19 | +```go |
| 20 | +var ( |
| 21 | + ctx = context.Background() |
| 22 | + authOpts = &adauth.Options{} |
| 23 | +) |
| 24 | + |
| 25 | +authOpts.RegisterFlags(pflag.CommandLine) |
| 26 | +pflag.Parse() |
| 27 | +// --aes-key string Kerberos AES key |
| 28 | +// --ccache string Kerberos CCache file name (defaults to $KRB5CCNAME, currently unset) |
| 29 | +// --dc string Domain controller |
| 30 | +// --debug Enable debug output |
| 31 | +// -k, --kerberos Use Kerberos authentication |
| 32 | +// -H, --nt-hash string NT hash |
| 33 | +// -p, --password string Password |
| 34 | +// --pfx string Client certificate and private key in PFX format |
| 35 | +// --pfx-password string Password for PFX file |
| 36 | +// -u, --user string Username ('user@domain', 'domain\user', 'domain/user' or 'user') |
| 37 | + |
| 38 | +// Credentials for an arbitrary target: |
| 39 | +creds, target, err := authOpts.WithTarget(ctx, "smb", pflag.Arg(0)) |
| 40 | +if err != nil { /* error handling */ } |
| 41 | + |
| 42 | + |
| 43 | +// Only credentials are need, no specific target: |
| 44 | +creds, err := authOpts.NoTarget() |
| 45 | +if err != nil { /* error handling */ } |
| 46 | + |
| 47 | +// Credentials to authenticate to the corresponding DC: |
| 48 | +creds, dc, err := authOpts.WithDCTarget(ctx, "ldap") |
| 49 | +if err != nil { /* error handling */ } |
| 50 | +``` |
| 51 | + |
| 52 | +It deduces as much information from the parameters as possible. For example, |
| 53 | +Kerberos authentication is possible even when specifying the target via IP |
| 54 | +address if reverse lookups are possible. Similarly, the domain can be omitted |
| 55 | +when the target hostname contains the domain. |
| 56 | + |
| 57 | +The library also contains helper packages for LDAP and DCERPC, a Kerebros PKINIT |
| 58 | +implementation as well as helpers for creating and writing CCache files (see |
| 59 | +examples). |
| 60 | + |
| 61 | +## Features |
| 62 | + |
| 63 | +* Kerberos |
| 64 | + * PKINIT |
| 65 | + * UnPAC-the-Hash |
| 66 | + * Pass-the-Hash (RC4/NT or AES key) |
| 67 | + * CCache (containing TGT or ST) |
| 68 | +* NTLM |
| 69 | + * Pass-the-Hash |
| 70 | +* LDAP |
| 71 | + * Kerberos, NTLM, Simple Bind |
| 72 | + * mTLS Authentication / Pass-the-Certificate (LDAPS or LDAP+StartTLS) |
| 73 | + * Channel Binding (Kerberos and NTLM) |
| 74 | +* DCERPC: |
| 75 | + * Kerberos, NTLM |
| 76 | + * Raw endpoits (with port mapping) |
| 77 | + * Named pipes (SMB) |
| 78 | + * Signing |
| 79 | + * Sealing |
| 80 | + |
| 81 | +## Caveats |
| 82 | + |
| 83 | +**LDAP:** |
| 84 | + |
| 85 | +The LDAP helper package does not support authentication using RC4 service |
| 86 | +tickets from `ccache`, since Windows returns unsupported GSSAPI wrap tokens |
| 87 | +during the SASL handshake when presented with an RC4 service ticket (see |
| 88 | +[github.com/jcmturner/gokrb5/pull/498](https://github.com/jcmturner/gokrb5/pull/498)). |
| 89 | + |
| 90 | +However, it should still be possible to request an AES256 service ticket |
| 91 | +instead, even when an NT hash was used for pre-authentication . Unfortunately, |
| 92 | +[impacket](https://github.com/fortra/impacket) always requests RC4 tickets. This |
| 93 | +behavior can be changed by adding |
| 94 | +`int(constants.EncryptionTypes.aes256_cts_hmac_sha1_96.value),` as the first |
| 95 | +element of [this |
| 96 | +list](https://github.com/fortra/impacket/blob/af91d617c382e1eb132506159debcbc10da7a567/impacket/krb5/kerberosv5.py#L447-L450). |
| 97 | + |
| 98 | +The LDAP library does not (yet) support LDAP signing, but it supports channel |
| 99 | +binding for LDAPS and LDAP+StartTLS which is typically sufficient as a |
| 100 | +workaround unless the server lacks a TLS certificate. |
| 101 | + |
0 commit comments