mirror of
https://github.com/mandiant/gopacket
synced 2026-06-21 13:57:02 +00:00
8eea029431
The embedded gokrb5/v8 library hard-coded net.DialTimeout for AS/TGS
exchanges, bypassing -proxy and leaking the operator's source IP to the
KDC (UDP/88 first, TCP/88 fallback). The DCERPC Kerberos auth path used
a separate library (oiweiwei/gokrb5.fork/v9 via go-msrpc) that leaked the
same way.
Vendor jcmturner/gokrb5/v8 in-tree at pkg/third_party/gokrb5 with a
required KDCDialer first argument on every client constructor, so
proxy-bypass becomes a compile error. Wire kerberos.TransportKDCDialer
everywhere a gokrb5 client is built. Stamp udp_preference_limit=1 and
dns_lookup_kdc/realm=false unconditionally so KRB5 is TCP-only and the
OS resolver is never consulted; /etc/krb5.conf and $KRB5_CONFIG are
deliberately not read.
For DCERPC: set krbConfig.KDCDialer on every krb5.Config, pass
dcerpc.WithDialer(transport.ContextDialer{}) on every dcerpc.Dial, and
use the "ncacn_ip_tcp:" StringBinding prefix on the OXID-pivot dial so
go-msrpc's hard-coded pre-dial net.LookupIP is skipped (defers FQDN
resolution to the SOCKS5 proxy).
Verified against a live GOAD lab: 8 Kerberos-touching tools plus 5
NTLM/password/PtH regressions all operate through SOCKS5 with zero
direct packets to the AD subnet. Negative control (no -proxy)
immediately emits direct SYNs to the KDC, confirming both the leak
class and the fix.
41 lines
844 B
Go
41 lines
844 B
Go
package rfc4757
|
|
|
|
import (
|
|
"bytes"
|
|
"crypto/hmac"
|
|
"crypto/md5"
|
|
"io"
|
|
)
|
|
|
|
// Checksum returns a hash of the data in accordance with RFC 4757
|
|
func Checksum(key []byte, usage uint32, data []byte) ([]byte, error) {
|
|
// Create hashing key
|
|
s := append([]byte(`signaturekey`), byte(0x00)) //includes zero octet at end
|
|
mac := hmac.New(md5.New, key)
|
|
mac.Write(s)
|
|
Ksign := mac.Sum(nil)
|
|
|
|
// Format data
|
|
tb := UsageToMSMsgType(usage)
|
|
p := append(tb, data...)
|
|
h := md5.New()
|
|
rb := bytes.NewReader(p)
|
|
_, err := io.Copy(h, rb)
|
|
if err != nil {
|
|
return []byte{}, err
|
|
}
|
|
tmp := h.Sum(nil)
|
|
|
|
// Generate HMAC
|
|
mac = hmac.New(md5.New, Ksign)
|
|
mac.Write(tmp)
|
|
return mac.Sum(nil), nil
|
|
}
|
|
|
|
// HMAC returns a keyed MD5 checksum of the data
|
|
func HMAC(key []byte, data []byte) []byte {
|
|
mac := hmac.New(md5.New, key)
|
|
mac.Write(data)
|
|
return mac.Sum(nil)
|
|
}
|