Compare commits

...

2 Commits

Author SHA1 Message Date
nervuri 539f7ff19d go fmt 2022-05-26 00:00:00 +00:00
nervuri b64902909e fix small error in systemd unit file 2022-05-26 00:00:00 +00:00
3 changed files with 32 additions and 32 deletions

View File

@ -51,7 +51,7 @@ After=network.target
[Service]
Type=simple
Restart=always
ExecStart=client-hello-mirror -u www-data -c /etc/letsencrypt/live/example.org/cert.pem -k /etc/letsencrypt/live/example.org/privkey.pem :443 2\>/var/log/client-hello-mirror-error.log
ExecStart=client-hello-mirror -u www-data -c /etc/letsencrypt/live/example.org/cert.pem -k /etc/letsencrypt/live/example.org/privkey.pem :443 2>/var/log/client-hello-mirror-error.log
[Install]
WantedBy=multi-user.target

View File

@ -172,21 +172,21 @@ func (numbers uint8Slice) MarshalJSON() ([]byte, error) {
}
type extensionData struct {
Raw byteSlice `json:"raw"`
ServerName string `json:"server_name,omitempty"`
StatusType uint8 `json:"status_type,omitempty"`
SupportedGroups []curveID `json:"supported_groups,omitempty"`
SupportedPointFormats uint8Slice `json:"supported_point_formats,omitempty"`
SupportedSignatureAlgorithms []signatureScheme `json:"supported_signature_algorithms,omitempty"`
RenegotiationInfo []byte `json:"renegotiation_info,omitempty"`
AlpnProtocols []string `json:"alpn_protocols,omitempty"`
SupportedVersions []uint16 `json:"supported_tls_versions,omitempty"`
Cookie byteSlice `json:"cookie,omitempty"`
KeyShares []keyShare `json:"key_shares,omitempty"`
PskModes uint8Slice `json:"psk_modes,omitempty"`
PskIdentities []pskIdentity `json:"psk_identities,omitempty"`
PskBinders []byteSlice `json:"psk_binders,omitempty"`
Length uint16 `json:"length,omitempty"` // padding
Raw byteSlice `json:"raw"`
ServerName string `json:"server_name,omitempty"`
StatusType uint8 `json:"status_type,omitempty"`
SupportedGroups []curveID `json:"supported_groups,omitempty"`
SupportedPointFormats uint8Slice `json:"supported_point_formats,omitempty"`
SupportedSignatureAlgorithms []signatureScheme `json:"supported_signature_algorithms,omitempty"`
RenegotiationInfo []byte `json:"renegotiation_info,omitempty"`
AlpnProtocols []string `json:"alpn_protocols,omitempty"`
SupportedVersions []uint16 `json:"supported_tls_versions,omitempty"`
Cookie byteSlice `json:"cookie,omitempty"`
KeyShares []keyShare `json:"key_shares,omitempty"`
PskModes uint8Slice `json:"psk_modes,omitempty"`
PskIdentities []pskIdentity `json:"psk_identities,omitempty"`
PskBinders []byteSlice `json:"psk_binders,omitempty"`
Length uint16 `json:"length,omitempty"` // padding
}
type extension struct {
@ -197,13 +197,13 @@ type extension struct {
type highlights struct {
//SupportedTLSVersions []uint16
SecureRenegotiationSupport bool `json:"secure_renegotiation_support"`
OcspStaplingSupport bool `json:"ocsp_stapling_support"`
SctSupport bool `json:"sct_support"`
SecureRenegotiationSupport bool `json:"secure_renegotiation_support"`
OcspStaplingSupport bool `json:"ocsp_stapling_support"`
SctSupport bool `json:"sct_support"`
// Go's crypto/tls server does not support early data.
EarlyData bool `json:"-"` // don't include in JSON
JA3 string `json:"ja3"`
JA3MD5 byteSlice `json:"ja3_md5"`
EarlyData bool `json:"-"` // don't include in JSON
JA3 string `json:"ja3"`
JA3MD5 byteSlice `json:"ja3_md5"`
}
type clientHelloMsg struct {
@ -518,7 +518,7 @@ func (m *clientHelloMsg) unmarshal(data []byte) bool {
default:
// Check if this is a GREASE extension (RFC 8701)
if isGREASE(extension.Code) {
extension.Name = "GREASE"
extension.Name = "GREASE"
} else {
log.Println("Unknown extension:", extension.Code)
}
@ -541,7 +541,7 @@ func (m *clientHelloMsg) unmarshal(data []byte) bool {
for i, cs := range m.CipherSuites {
if !isGREASE(cs) { // ignore GREASE values
ja3.WriteString(strconv.FormatUint(uint64(cs), 10))
if i + 1 != len(m.CipherSuites) {
if i+1 != len(m.CipherSuites) {
ja3.WriteString("-")
}
}
@ -550,7 +550,7 @@ func (m *clientHelloMsg) unmarshal(data []byte) bool {
for i, e := range m.Extensions {
if !isGREASE(e.Code) { // ignore GREASE values
ja3.WriteString(strconv.FormatUint(uint64(e.Code), 10))
if i + 1 != len(m.Extensions) {
if i+1 != len(m.Extensions) {
ja3.WriteString("-")
}
if e.Code == extensionSupportedGroups {
@ -564,7 +564,7 @@ func (m *clientHelloMsg) unmarshal(data []byte) bool {
for i, g := range supportedGroups {
if !isGREASE(uint16(g)) { // ignore GREASE values
ja3.WriteString(strconv.FormatUint(uint64(g), 10))
if i + 1 != len(supportedGroups) {
if i+1 != len(supportedGroups) {
ja3.WriteString("-")
}
}
@ -573,7 +573,7 @@ func (m *clientHelloMsg) unmarshal(data []byte) bool {
for i, pf := range supportedPointFormats {
if !isGREASE(uint16(pf)) { // ignore GREASE values
ja3.WriteString(strconv.FormatUint(uint64(pf), 10))
if i + 1 != len(supportedPointFormats) {
if i+1 != len(supportedPointFormats) {
ja3.WriteString("-")
}
}

View File

@ -11,9 +11,9 @@ import (
"flag"
"fmt"
"io"
"log"
"net"
"net/url"
"log"
"os/user"
"strconv"
"strings"
@ -21,7 +21,7 @@ import (
"time"
)
import(
import (
//#include <unistd.h>
//#include <errno.h>
"C"
@ -192,8 +192,8 @@ func tlsHandler(conn *tls.Conn, rawClientHello []byte) {
_, err = conn.Write([]byte("20 application/json\r\n"))
}
} else if strings.HasPrefix(line, "GET ") ||
strings.HasPrefix(line, "POST ") ||
strings.HasPrefix(line, "HEAD ") {
strings.HasPrefix(line, "POST ") ||
strings.HasPrefix(line, "HEAD ") {
protocol = "HTTP"
path = strings.Split(line, " ")[1]
if path == "/" {
@ -243,7 +243,7 @@ func tlsHandler(conn *tls.Conn, rawClientHello []byte) {
}
} else if path == "/json/v1" {
output := struct {
ClientHello clientHelloMsg `json:"client_hello"`
ClientHello clientHelloMsg `json:"client_hello"`
TlsConnectionInfo tlsConnectionInfo `json:"connection_info"`
}{
clientHello,