@@ -2,12 +2,14 @@ package dcerpcauth
2
2
3
3
import (
4
4
"context"
5
+ "encoding/hex"
5
6
"fmt"
6
7
"net"
7
8
"strings"
8
9
9
10
"github.com/RedTeamPentesting/adauth"
10
11
"github.com/RedTeamPentesting/adauth/pkinit"
12
+ "github.com/oiweiwei/gokrb5.fork/v9/iana/etypeID"
11
13
12
14
"github.com/oiweiwei/go-msrpc/dcerpc"
13
15
"github.com/oiweiwei/go-msrpc/smb2"
@@ -131,12 +133,23 @@ func DCERPCCredentials(ctx context.Context, creds *adauth.Credential, options *O
131
133
case creds .AESKey != "" :
132
134
options .debug ("Authenticating with AES key" )
133
135
134
- key , keyType , err := adauth . ParseAESKey (creds .AESKey )
136
+ keyBytes , err := hex . DecodeString (creds .AESKey )
135
137
if err != nil {
136
- return nil , fmt .Errorf ("parse AES key: %w" , err )
138
+ return nil , fmt .Errorf ("decode hex key: %w" , err )
137
139
}
138
140
139
- return credential .NewFromEncryptionKeyBytes (creds .LogonNameWithUpperCaseDomain (), int (keyType ), key ), nil
141
+ var keyType int
142
+
143
+ switch len (keyBytes ) {
144
+ case 32 :
145
+ keyType = int (etypeID .AES256_CTS_HMAC_SHA1_96 )
146
+ case 16 :
147
+ keyType = int (etypeID .AES128_CTS_HMAC_SHA1_96 )
148
+ default :
149
+ return nil , fmt .Errorf ("invalid AES128/AES256 key: key size is %d bytes" , len (keyBytes ))
150
+ }
151
+
152
+ return credential .NewFromEncryptionKeyBytes (creds .LogonNameWithUpperCaseDomain (), keyType , keyBytes ), nil
140
153
case creds .NTHash != "" :
141
154
options .debug ("Authenticating with NT hash" )
142
155
0 commit comments