sensor-d4-tls-fingerprinting/etls/etls_test.go

302 lines
17 KiB
Go

package etls
import (
"bytes"
"encoding/hex"
"testing"
"github.com/google/gopacket"
)
var etls = &ETLS{}
var d4ClientHelloPacket = []byte{
0x16, 0x03, 0x01, 0x00, 0x89, 0x01, 0x00, 0x00, 0x85, 0x03, 0x03, 0x49, 0xdd,
0x95, 0x76, 0x1f, 0xd8, 0x43, 0x9c, 0xf4, 0x66, 0xd5, 0xf0, 0x8c, 0xcb, 0x37,
0xd1, 0x55, 0xe6, 0x99, 0x1d, 0x29, 0x07, 0xe5, 0xcf, 0xdb, 0x55, 0x53, 0xc8,
0xc3, 0xbc, 0x73, 0x27, 0x00, 0x00, 0x20, 0xc0, 0x2f, 0xc0, 0x30, 0xc0, 0x2b,
0xc0, 0x2c, 0xcc, 0xa8, 0xcc, 0xa9, 0xc0, 0x13, 0xc0, 0x09, 0xc0, 0x14, 0xc0,
0x0a, 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x2f, 0x00, 0x35, 0xc0, 0x12, 0x00, 0x0a,
0x01, 0x00, 0x00, 0x3c, 0x00, 0x05, 0x00, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0a, 0x00, 0x0a, 0x00, 0x08, 0x00, 0x1d, 0x00, 0x17, 0x00, 0x18, 0x00,
0x19, 0x00, 0x0b, 0x00, 0x02, 0x01, 0x00, 0x00, 0x0d, 0x00, 0x12, 0x00, 0x10,
0x04, 0x01, 0x04, 0x03, 0x05, 0x01, 0x05, 0x03, 0x06, 0x01, 0x06, 0x03, 0x02,
0x01, 0x02, 0x03, 0xff, 0x01, 0x00, 0x01, 0x00, 0x00, 0x12, 0x00, 0x00,
}
var d4ServerHelloPacket = []byte{
0x16, 0x03, 0x03, 0x00, 0x59, 0x02, 0x00, 0x00, 0x55, 0x03, 0x03, 0x6a, 0xf0,
0x87, 0x47, 0xfb, 0xce, 0xc4, 0xde, 0x24, 0xcb, 0x49, 0x48, 0xdf, 0x1d, 0x71,
0x8e, 0xb5, 0xae, 0xf1, 0x9c, 0x7f, 0x0f, 0xcb, 0x39, 0xfd, 0x51, 0xcc, 0x9b,
0x06, 0x1f, 0x79, 0xac, 0x20, 0x79, 0x0d, 0x72, 0xf7, 0xc9, 0x40, 0x83, 0xf2,
0x95, 0xdf, 0xcc, 0xec, 0xc5, 0xd2, 0x08, 0xbf, 0x71, 0x84, 0xfd, 0xcf, 0x79,
0xe0, 0x5f, 0x63, 0x06, 0x15, 0x49, 0x01, 0x2b, 0x6b, 0x7e, 0xba, 0xc0, 0x30,
0x00, 0x00, 0x0d, 0xff, 0x01, 0x00, 0x01, 0x00, 0x00, 0x0b, 0x00, 0x04, 0x03,
0x00, 0x01, 0x02, 0x16, 0x03, 0x03, 0x05, 0x4d, 0x0b, 0x00, 0x05, 0x49, 0x00,
0x05, 0x46, 0x00, 0x05, 0x43, 0x30, 0x82, 0x05, 0x3f, 0x30, 0x82, 0x03, 0x27,
0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, 0xe9, 0xd2, 0x5f, 0x88, 0x34,
0xb2, 0x95, 0xce, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x4f, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03,
0x55, 0x04, 0x06, 0x13, 0x02, 0x4c, 0x55, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03,
0x55, 0x04, 0x08, 0x0c, 0x02, 0x4c, 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03,
0x55, 0x04, 0x07, 0x0c, 0x0a, 0x4c, 0x75, 0x78, 0x65, 0x6d, 0x62, 0x6f, 0x75,
0x72, 0x67, 0x31, 0x0e, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x05,
0x53, 0x4d, 0x49, 0x4c, 0x45, 0x31, 0x0e, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x04,
0x0b, 0x0c, 0x05, 0x43, 0x49, 0x52, 0x43, 0x4c, 0x30, 0x1e, 0x17, 0x0d, 0x31,
0x39, 0x30, 0x31, 0x31, 0x38, 0x30, 0x38, 0x33, 0x37, 0x32, 0x36, 0x5a, 0x17,
0x0d, 0x32, 0x30, 0x30, 0x36, 0x30, 0x31, 0x30, 0x38, 0x33, 0x37, 0x32, 0x36,
0x5a, 0x30, 0x4d, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13,
0x02, 0x4c, 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c,
0x0a, 0x4c, 0x75, 0x78, 0x65, 0x6d, 0x62, 0x6f, 0x75, 0x72, 0x67, 0x31, 0x15,
0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0c, 0x53, 0x4d, 0x49, 0x4c,
0x45, 0x2c, 0x20, 0x43, 0x49, 0x52, 0x43, 0x4c, 0x31, 0x12, 0x30, 0x10, 0x06,
0x03, 0x55, 0x04, 0x03, 0x0c, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f,
0x73, 0x74, 0x30, 0x82, 0x02, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48,
0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x02, 0x0f, 0x00,
0x30, 0x82, 0x02, 0x0a, 0x02, 0x82, 0x02, 0x01, 0x00, 0xbe, 0xbc, 0x26, 0x91,
0x5e, 0xc9, 0xa0, 0x4b, 0x62, 0x9a, 0xf4, 0x78, 0x02, 0x14, 0x45, 0xc5, 0x9a,
0x3f, 0x87, 0x9d, 0xc6, 0x4c, 0x37, 0x5a, 0xb2, 0xcc, 0x9f, 0x95, 0x16, 0xa5,
0xf5, 0x50, 0x68, 0xda, 0x09, 0xd3, 0x9b, 0xf0, 0xc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 0xa6, 0x3c, 0x13, 0xd7, 0x6b, 0x4e, 0xce, 0xfb, 0x7d, 0x1c, 0x3a,
0xa5, 0xc8, 0xc3, 0x70, 0x03, 0x88, 0x68, 0x75, 0xd9, 0xec, 0x3b, 0x67, 0x55,
0x56, 0xa4, 0x06, 0x6d, 0x4c, 0x83, 0xbd, 0x39, 0x4e, 0x4f, 0x8d, 0x19, 0xb3,
0x3f, 0x22, 0x0e, 0xfb, 0x58, 0xb5, 0xc0, 0x67, 0xdc, 0xac, 0xaa, 0x02, 0x7d,
0x56, 0x9b, 0xb6, 0xac, 0x7f, 0x31, 0xe0, 0x18, 0x49, 0x83, 0x8f, 0x57, 0x22,
0x27, 0x0b, 0xfc, 0x6f, 0x4f, 0xf3, 0x14, 0x08, 0xe5, 0xb5, 0x5c, 0xa7, 0x11,
0x44, 0x82, 0x8e, 0xe8, 0xf2, 0x98, 0xcb, 0x2b, 0xe5, 0xbf, 0x44, 0x97, 0xee,
0xf5, 0x87, 0x16, 0xd1, 0x48, 0x77, 0x78, 0x49, 0x44, 0x66, 0xa4, 0x1d, 0x87,
0xe5, 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x20, 0x30, 0x1e, 0x30, 0x0b, 0x06,
0x03, 0x55, 0x1d, 0x0f, 0x04, 0x04, 0x03, 0x02, 0x04, 0xf0, 0x30, 0x0f, 0x06,
0x03, 0x55, 0x1d, 0x11, 0x04, 0x08, 0x30, 0x06, 0x87, 0x04, 0x7f, 0x00, 0x00,
0x01, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01,
0x0b, 0x05, 0x00, 0x03, 0x82, 0x02, 0x01, 0x00, 0x23, 0x10, 0x2b, 0xfe, 0xda,
0x64, 0x5c, 0x81, 0xbb, 0xb7, 0x42, 0xb4, 0x88, 0xb4, 0xae, 0x20, 0x52, 0x3d,
0x0d, 0xe8, 0x13, 0xab, 0xb0, 0xb1, 0x4c, 0xb8,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, 0x0b, 0xea, 0xf0, 0xa0, 0x2a, 0x5f, 0x37,
0x54, 0xbb, 0x65, 0xf7, 0x3a, 0xd5, 0xe8, 0x58, 0x1c, 0xb9, 0x00, 0x05, 0x02,
0xee, 0x17, 0x11, 0x52, 0x62, 0xc6, 0xd2, 0x30, 0xbd, 0x32, 0x51, 0xd1, 0xf7,
0xf2, 0x81, 0x86, 0x71, 0xd7, 0x16, 0x4e, 0xf4, 0x8a, 0xc7, 0x0b, 0x3a, 0xd9,
0x55, 0x0d, 0x80, 0x1f, 0x64, 0x3e, 0x9d, 0xa3, 0x8c, 0x2a, 0x5c, 0xe0, 0x53,
0x97, 0xef, 0x55, 0xb8, 0x78, 0x1f, 0xf8, 0x77, 0xc1, 0x34, 0xc1, 0x59, 0x2a,
0xd3, 0xa6, 0xb7, 0x28, 0x31, 0xbe, 0x78, 0xef, 0xd5, 0x3f, 0x83, 0xbc, 0xfc,
0xea, 0x3f, 0x72, 0xdf, 0xa6, 0x91, 0x1a, 0x05, 0x39, 0x86, 0x9d, 0x09, 0x8a,
0x5c, 0x3d, 0x89, 0x17, 0x80, 0xb3, 0xba, 0xf5, 0x9c, 0x5f, 0x7d, 0xaf, 0x53,
0x23, 0xe3, 0x79, 0x08, 0x24, 0x7c, 0x07, 0xaf, 0x4b, 0xd2, 0x2c, 0x19, 0xdd,
0xc5, 0x66, 0x16, 0x03, 0x03, 0x00, 0x04, 0x0e, 0x00, 0x00, 0x00,
}
var serverHello = d4ServerHelloPacket[:94]
var certificateRecord = d4ServerHelloPacket[94:1456]
// Rest of the packet is:
// Server Key Exchange[1456:2017]
// Server Hello Done[2017:]
func TestDecodeClientHello(t *testing.T) {
var decoded []gopacket.LayerType
p := gopacket.NewDecodingLayerParser(LayerTypeETLS, etls)
err := p.DecodeLayers(d4ClientHelloPacket, &decoded)
if err != nil {
t.Logf("Failed to decode client hello record %e", err)
t.Fail()
} else if decoded[0] == LayerTypeETLS {
t.Logf("Successfully decoded layer type %v\n", decoded[0])
if etls.Handshake != nil {
for _, etlsrecord := range etls.Handshake {
if etlsrecord.ETLSHandshakeMsgType == 1 {
// Client Hello
if !bytes.Equal(etlsrecord.ETLSHandshakeClientHello.raw, d4ClientHelloPacket[5:]) {
t.Logf("%v", hex.Dump(etlsrecord.ETLSHandshakeClientHello.raw))
t.Logf("%v", hex.Dump(d4ClientHelloPacket))
t.Fail()
}
if etlsrecord.ETLSRecordHeader.ContentType != 0x16 {
t.Logf("%v", etlsrecord.ETLSRecordHeader.ContentType)
t.Fail()
}
if etlsrecord.ETLSRecordHeader.Version != 0x0301 {
t.Logf("%v", etlsrecord.ETLSRecordHeader.Version)
t.Fail()
}
if etlsrecord.ETLSRecordHeader.Length != 0x89 {
t.Logf("%v", etlsrecord.ETLSRecordHeader.Length)
t.Fail()
}
}
}
}
}
}
func TestDecodeServerHello(t *testing.T) {
var decoded []gopacket.LayerType
p := gopacket.NewDecodingLayerParser(LayerTypeETLS, etls)
err := p.DecodeLayers(serverHello, &decoded)
if err != nil {
t.Logf("Failed to decode server hello record %e", err)
t.Fail()
} else if decoded[0] == LayerTypeETLS {
t.Logf("Successfully decoded layer type %v\n", decoded[0])
if etls.Handshake != nil {
for _, etlsrecord := range etls.Handshake {
if etlsrecord.ETLSHandshakeMsgType == 11 {
// Server Hello
if !bytes.Equal(etlsrecord.ETLSHandshakeServerHello.raw, serverHello[5:]) {
t.Logf("%v", hex.Dump(etlsrecord.ETLSHandshakeServerHello.raw))
t.Logf("%v", hex.Dump(serverHello))
t.Fail()
}
if etlsrecord.ETLSRecordHeader.ContentType != 0x16 {
t.Logf("%v", etlsrecord.ETLSRecordHeader.ContentType)
t.Fail()
}
if etlsrecord.ETLSRecordHeader.Version != 0x0303 {
t.Logf("%v", etlsrecord.ETLSRecordHeader.Version)
t.Fail()
}
if etlsrecord.ETLSRecordHeader.Length != 89 {
t.Logf("%v", etlsrecord.ETLSRecordHeader.Length)
t.Fail()
}
}
}
}
}
}
func TestDecodeCertificate(t *testing.T) {
var decoded []gopacket.LayerType
p := gopacket.NewDecodingLayerParser(LayerTypeETLS, etls)
err := p.DecodeLayers(certificateRecord, &decoded)
if err != nil {
t.Logf("Failed to decode certificate record packet %e", err)
t.Fail()
} else if decoded[0] == LayerTypeETLS {
t.Logf("Successfully decoded layer type %v\n", decoded[0])
if etls.Handshake != nil {
for _, etlsrecord := range etls.Handshake {
if etlsrecord.ETLSHandshakeMsgType == 2 {
// Server Certificate
t.Logf("%v", hex.Dump(etlsrecord.ETLSHandshakeCertificate.raw))
if !bytes.Equal(etlsrecord.ETLSHandshakeCertificate.raw, certificateRecord[5:]) {
t.Logf("%v", hex.Dump(etlsrecord.ETLSHandshakeCertificate.raw))
t.Logf("%v", hex.Dump(certificateRecord))
t.Fail()
}
if etlsrecord.ETLSRecordHeader.ContentType != 0x16 {
t.Logf("%v", etlsrecord.ETLSRecordHeader.ContentType)
t.Fail()
}
if etlsrecord.ETLSRecordHeader.Version != 0x0303 {
t.Logf("%v", etlsrecord.ETLSRecordHeader.Version)
t.Fail()
}
if etlsrecord.ETLSRecordHeader.Length != 1357 {
t.Logf("%v", etlsrecord.ETLSRecordHeader.Length)
t.Fail()
}
}
}
}
}
}