ssl

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CipherPreferenceClient = "client"
	CipherPreferenceServer = "server"
)

Cipher preferences

View Source
const Label = "Ssl"

Variables

View Source
var StartTlsPorts = map[int]string{
	433:  "",
	25:   "smtp",
	465:  "",
	587:  "smtp",
	143:  "imap",
	220:  "imap",
	993:  "",
	109:  "pop3",
	110:  "pop3",
	995:  "",
	5222: "xmpp",
	5223: "",
	5280: "xmpp",
	5298: "xmpp",
	5269: "xmpp_server",
	21:   "ftp",
	990:  "",
	989:  "",
	389:  "ldap",
	3268: "ldap",
	7389: "ldap",
	636:  "",
	3269: "",
	7636: "",
	3389: "rdp",
	5432: "postgres",
}

StartTlsPorts maps common port numbers to their respective protocols: smtp, xmpp, xmpp_server, pop3, ftp, imap, ldap, rdp, postgres, auto. More (unofficial) ports from this list: https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers

Functions

func CheckSetup

func CheckSetup() error

CheckSetup checks whether Setup() executed accordingly. Scan arguments should be checked by the scanner.

func IsValidAuthentication

func IsValidAuthentication(auth Authentication) bool

func IsValidEncryption

func IsValidEncryption(enc Encryption) bool

func IsValidEncryptionMode

func IsValidEncryptionMode(encMode EncryptionMode) bool

func IsValidKeyExchange

func IsValidKeyExchange(k KeyExchange) bool

func IsValidMac

func IsValidMac(m Mac) bool

func IsValidPrf

func IsValidPrf(p Prf) bool

func IsValidProtocol

func IsValidProtocol(p Protocol) bool

func LoadCiphers

func LoadCiphers(logger utils.Logger)

func Setup

func Setup(logger utils.Logger) error

Setup configures the environment accordingly, if the scan module has some special requirements. A successful setup is required before a scan can be started.

Types

type Authentication

type Authentication uint8

Algorithms used to authenticate the server and (optionally) client.

const (
	AUTH_NONE         Authentication = iota + 1 // No authentication
	AUTH_TLSv1_3                                // RSA / ECDSA / RSA-PSS / EdDSA / PSK
	AUTH_DSS                                    // DSS
	AUTH_ECDSA                                  // ECDSA
	AUTH_ECNRA                                  // ECNRA
	AUTH_FORTEZZA_KEA                           // FORTEZZA_KEA
	AUTH_GOSTR341001                            // GOST R 34.10.2001
	AUTH_GOSTR341094                            // GOST R 34.10.1994
	AUTH_KRB5                                   // KRB5
	AUTH_PSK                                    // PSK
	AUTH_RSA                                    // RSA
	AUTH_SRP_SHA                                // SRP_SHA
)

AUTH_GOSTR341001: elliptic curve version

func (Authentication) String

func (i Authentication) String() string

type CertDeployment

type CertDeployment struct {
	Certificates  []*Certificate // Certificates of this specific deployment
	ValidatedBy   []string       // Name(s) of the trust store(s) that successfully validated this deployment
	HasValidOrder bool           // Indicates whether the certificate chain was sent in valid order
}

type Certificate

type Certificate struct {
	Type                   string             // 'leaf' / 'intermediate' / 'root'
	Version                int                // Version of the X.509 standard.
	Serial                 big.Int            // Serial number chosen by the CA (not necessarily globally unique / random).
	Subject                []string           // Object Identifiers (OIDs) of the subject.
	SubjectCN              string             // Subject's common name.
	Issuer                 []string           // Object Identifiers (OIDs) of the issuer.
	IssuerCN               string             // Issuer's common name.
	AlternativeNames       []string           // Subject's alternative names.
	ValidFrom              time.Time          // The initial date at which the certificate is valid.
	ValidTo                time.Time          // The expiration date of the certificate.
	PublicKeyAlgorithm     PublicKey          // The algorithm corresponding to the public key.
	PublicKeyInfo          string             // Some additional info on the public key, depending on the public key's type.
	PublicKeyBits          uint64             // The public key's bit-size.
	PublicKeyStrength      int                // The public key's strength corresponding to the key size.
	SignatureAlgorithm     SignatureAlgorithm // The signature algorithm.
	SignatureHashAlgorithm SignatureHash      // The signature hash algorithm.
	CrlUrls                []string           // URL(s) for the certificate revocation list.
	OcspUrls               []string           // URL(s) for the  online certificate status protocol
	KeyUsage               []string           // Key usage flags set in the certificate.
	ExtendedKeyUsage       []string           // Extended key usage flags set in the certificate.
	BasicConstraintsValid  bool               // Indicates whether Ca and MaxPathLen is valid. All three fields belong to the "basic constraint extension"
	Ca                     bool               // Indicates whether the certificate is of a CA.
	MaxPathLength          int                // Maximum number of non-self-issued intermediate certificates that follow this certificate (leaf certificate not counting). See also: http://www.pkiglobe.org/
	Sha1Fingerprint        string             // SHA1 fingerprint of the certificate.
}

type Cipher

type Cipher struct {
	Id                  string
	IanaName            string
	OpensslName         string
	Protocol            Protocol       // SSL/TLS version used.
	KeyExchange         KeyExchange    // The key exchange algorithm.
	KeyExchangeBits     int            // The encryption's key bit-size - only set if ephemeral key exchange or export cipher.
	KeyExchangeStrength int            // The encryption's strength corresponding to the key size - only set if ephemeral key exchange or export cipher.
	KeyExchangeInfo     []string       // Additional info on the key exchange - only set if ephemeral key exchange
	ForwardSecrecy      bool           // Set if the key exchange algorithm supports forward secrecy.
	Authentication      Authentication // The authentication algorithm.
	Encryption          Encryption     // The encryption algorithm.
	EncryptionMode      EncryptionMode // The encryption's mode.
	EncryptionBits      int            // The encryption's key bit-size.
	EncryptionStrength  int            // The encryption's strength corresponding to the key size.
	BlockCipher         bool           // Indicates whether the encryption method is a block cipher.
	BlockSize           int            // The encryption's block size if it is a block cipher.
	StreamCipher        bool           // Indicates whether the encryption method is a stream cipher.
	Mac                 Mac            // The message authentication code algorithm.
	MacBits             int            // The mac's digest size in bits.
	MacStrength         int            // The mac's strength corresponding to the digest size.
	Prf                 Prf            // The pseudo-random function family algorithm (if any).
	PrfBits             int            // The prf's digest size in bits.
	PrfStrength         int            // The prf's strength corresponding to the digest size.
	Export              bool           // Indicates whether the cipher suite is an old export cipher suite.
	Draft               bool           // Indicates whether the cipher suite is a draft.
}

type CipherInfo

type CipherInfo struct {
	Id          string         `json:"cipher_suite"` // Cipher suite id
	OpensslName string         `json:"openssl_name"` // OpenSSL name of the cipher (SSLyze uses it)
	IanaName    string         `json:"iana_name"`    // IANA name
	Kx          KeyExchange    `json:"kx"`           // Key exchange protocol
	Au          Authentication `json:"au"`           // Key exchange authentication
	Enc         Encryption     `json:"enc"`          // (Bulk) encryption algorithm
	EncBits     int            `json:"enc_bits"`     //
	EncMode     EncryptionMode `json:"enc_mode"`     //
	Mac         Mac            `json:"mac"`          // Message authentication code algorithm
	Prf         Prf            `json:"prf"`          // Pseudorandom function family if existing
	Export      bool           `json:"export"`       // export indicator, if the string is not empty it's an exportable cipher
}

Struct used for our cipher suite mapping.

type Curve

type Curve string

Curves used for elliptic curve cryptography (ECDHE, ECDSA). see http://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-8 This custom type is not transformed to an integer type as we only have one significant method declared for it and we only get a string from SSLyze. Therefore we'd have to create a mapping to our type in order to use a integer representation.

const (
	SECT163K1       Curve = "sect163k1"
	SECT163R1       Curve = "sect163r1"
	SECT163R2       Curve = "sect163r2"
	SECT193R1       Curve = "sect193r1"
	SECT193R2       Curve = "sect193r2"
	SECT233K1       Curve = "sect233k1"
	SECT233R1       Curve = "sect233r1"
	SECT239K1       Curve = "sect239k1"
	SECT283K1       Curve = "sect283k1"
	SECT283R1       Curve = "sect283r1"
	SECT409K1       Curve = "sect409k1"
	SECT409R1       Curve = "sect409r1"
	SECT571K1       Curve = "sect571k1"
	SECT571R1       Curve = "sect571r1"
	SECP160K1       Curve = "secp160k1"
	SECP160R1       Curve = "secp160r1"
	SECP160R2       Curve = "secp160r2"
	SECP192K1       Curve = "secp192k1"
	SECP192R1       Curve = "secp192r1"
	SECP224K1       Curve = "secp224k1"
	SECP224R1       Curve = "secp224r1"
	SECP256K1       Curve = "secp256k1"
	SECP256R1       Curve = "secp256r1"
	SECP384R1       Curve = "secp384r1"
	SECP521R1       Curve = "secp521r1"
	BRAINPOOLP256R1 Curve = "brainpoolP256r1"
	BRAINPOOLP384R1 Curve = "brainpoolP384r1"
	BRAINPOOLP512R1 Curve = "brainpoolP512r1"
	ECDH_X25519     Curve = "ecdh_x25519"
)

func (Curve) IsValidCurve

func (c Curve) IsValidCurve() bool

func (Curve) String

func (c Curve) String() string

We have to create our own String() function, as the Curve is a string alias and stringer can't process those.

type Data

type Data struct {
	Vhost                 string             // The target's hostname
	Issues                *Issues            // Cipher basic info
	Ciphers               map[string]*Cipher // Map of [protocol + "|" + cipher id] = cipher
	CertDeployments       []*CertDeployment  // A server can have multiple certificate chains, e.g. in order to support older clients. Unfortunately SSLyze does not return any information on which chain is linked to which client (/Cipher/Server name used for SNI...)
	EllipticCurves        *EllipticCurves    // Information about the elliptic curves that the target supports or rejects
	ComplianceTestDetails string             // Details to the check against Mozilla's SSL config. Each target will have its own IsCompliant flag, but this variable contains further details of the check.
}

type EllipticCurve

type EllipticCurve struct {
	Name       string
	OpenSSLnid int
}

type EllipticCurves

type EllipticCurves struct {
	RejectedCurves         []EllipticCurve // The curves that the target rejects
	SupportedCurves        []EllipticCurve // The curves that the target accepts
	SupportECDHKeyExchange bool            // Indicates whether the target supports ECDH Key Exchange
}

type Encryption

type Encryption uint8

Encryption algorithms

const (
	ENC_NONE       Encryption = iota + 1 // No encryption
	ENC_DES                              // DES
	ENC_RC2                              // RC2
	ENC_TRIPLE_DES                       // 3DES
	ENC_SKIPJACK                         // FORTEZZA
	ENC_SEED                             // SEED
	ENC_IDEA                             // IDEA
	ENC_CAMELLIA                         // Camellia
	ENC_ARIA                             // ARIA
	ENC_GOST28147                        // GOST 28147
	ENC_AES                              // AES

	// Stream ciphers
	ENC_RC4      // RC4
	ENC_CHACHA20 // ChaCha20
)

func (Encryption) String

func (i Encryption) String() string

type EncryptionMode

type EncryptionMode uint8

Modes of operation for block ciphers.

const (
	ENC_M_NONE     EncryptionMode = iota + 1 // No encryption mode
	ENC_M_CBC                                // CBC
	ENC_M_CCM                                // CCM
	ENC_M_CCM_8                              // CCM8
	ENC_M_GCM                                // GCM
	ENC_M_POLY1305                           // Poly1305
	ENC_M_CNT                                // CNT
)

CNT mode for GOST ciphers, see https://tools.ietf.org/html/rfc5830#page-6

func (EncryptionMode) String

func (i EncryptionMode) String() string

type Issues

type Issues struct {
	// ATTENTION: When changing any of the following structs, change the compareResultData function accordingly!
	AnyChainInvalid              bool     // Indicates whether any certificate chain is invalid.
	AnyChainInvalidOrder         bool     // Indicates whether any certificate chain has an invalid order.
	LowestProtocol               Protocol // The lowest SSL / TLS version that is supported by the server.
	MinStrength                  int      // The minimum of EncryptionStrength, MacStrength(/PrfStrength) and PublicKeyStrength across all ciphers and certificates.
	InsecureRenegotiation        bool     // Indicates whether the server supports secure renegotiation.
	AcceptsClientRenegotiation   bool     // If set renegotiation can be initialized by the client.
	InsecureClientRenegotiation  bool     // Combination of InsecureRenegotiation and AcceptsClientRenegotiation.
	SessionResumptionWithId      bool     // If set a session resumption using IDs is possible.
	SessionResumptionWithTickets bool     // If set a session resumption using session tickets is possible.
	NoPerfectForwardSecrecy      bool     // If this is set, the server supports at least one cipher suite that does not provide prefect forward secrecy.
	Compression                  bool     // If set compression for the payload is available (leading to CRIME vulnerability).
	ExportSuite                  bool     // Indicates whether the server supports an export cipher suite.
	DraftSuite                   bool     // Indicates whether the server supports a draft cipher suite.
	Sslv2Enabled                 bool     // Indicates the presence of at least one SSLv2 cipher suite.
	Sslv3Enabled                 bool     // Indicates the presence of at least one SSLv3 cipher suite.
	Rc4Enabled                   bool     // Indicates the presence of at least one cipher suite with RC4 encryption.
	Md2Enabled                   bool     // Indicates the presence of at least one cipher suite with MD2 mac (/prf).
	Md5Enabled                   bool     // Indicates the presence of at least one cipher suite with MD5 mac (/prf).
	Sha1Enabled                  bool     // Indicates the presence of at least one cipher suite with SHA1 mac (/prf).
	EarlyDataSupported           bool     // Early data can have a negative impact if session management is not implemented carefully.
	CcsInjection                 bool     // 									(https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-0224)
	Beast                        bool     // 									(https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-3389)
	Heartbleed                   bool     // http://heartbleed.com/				(https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-0160)
	Lucky13                      bool     // 									(https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2013-0169)
	Poodle                       bool     // 									(https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-3566) (https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-8730)
	Freak                        bool     // https://freakattack.com			(https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-0204)
	Logjam                       bool     // https://weakdh.org/logjam.html		(https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-4000) (Currently only export ciphers are tested)
	Sweet32                      bool     // https://sweet32.info/ 				(https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-2183)
	Drown                        bool     // https://drownattack.com/ 			(https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-0800)
	IsCompliantToMozillaConfig   bool     // https://ssl-config.mozilla.org/    Check if the server's SSL config complies with the recommended one from Mozilla
}

type KeyExchange

type KeyExchange uint8

Algorithms used for the key exchange.

const (
	KEX_DH           KeyExchange = iota + 1 // DH
	KEX_DHE                                 // DHE
	KEX_ECDH                                // ECDH
	KEX_ECDHE                               // ECDHE
	KEX_ECMQV                               // ECMQV
	KEX_ECCPWD                              // ECCPWD
	KEX_FORTEZZA_KEA                        // FORTEZZA_KEA
	KEX_GOSTR341001                         // GOST R 34.10-2001
	KEX_GOSTR341094                         // GOST R 34.10.1994
	KEX_KRB5                                // KRB5
	KEX_PSK                                 // PSK
	KEX_RSA                                 // RSA
	KEX_SRP_SHA                             // SRP_SHA
	KEX_TLSv1_3                             // (EC)DHE / PSK / PSK + (EC)DHE
)

KEX_ECMQV: https://tools.ietf.org/html/draft-campagna-tls-ecmqv-ecqv-01 KEX_GOSTR341001: elliptic curve version

func (KeyExchange) String

func (i KeyExchange) String() string

type Mac

type Mac uint8

Hash algorithms

const (
	MAC_AEAD        Mac = iota + 1 // AEAD
	MAC_MD2                        // MD2
	MAC_MD5                        // MD5
	MAC_SHA1                       // SHA1
	MAC_SHA224                     // SHA224
	MAC_SHA256                     // SHA256
	MAC_SHA384                     // SHA384
	MAC_SHA512                     // SHA512
	MAC_RIPEMD160                  // RMD
	MAC_GOSTR341194                // GOSTR341194
	MAC_GOST28147                  // GOST28147
	MAC_STREEBOG256                // Streeborg256
	MAC_BLAKE2B                    // BLAKE2b
	MAC_BLAKE2S                    // BLAKE2s
)

func (Mac) String

func (i Mac) String() string

type Prf

type Prf uint8

Hash algorithms

const (
	PRF_NONE      Prf = iota + 1 //
	PRF_MD2                      // MD2
	PRF_MD5                      // MD5
	PRF_SHA1                     // SHA1
	PRF_SHA224                   // SHA224
	PRF_SHA256                   // SHA256
	PRF_SHA384                   // SHA384
	PRF_SHA512                   // SHA512
	PRF_RIPEMD160                // RMD
	PRF_GOST28147                // IMIT GOST28147
	PRF_BLAKE2B                  // BLAKE2b
	PRF_BLAKE2S                  // BLAKE2s
)

func (Prf) String

func (i Prf) String() string

type Protocol

type Protocol uint8
const (
	PROTO_Unknown Protocol = iota //
	Sslv2                         // SSLv2
	Sslv3                         // SSLv3
	Tlsv1_0                       // TLSv1.0
	Tlsv1_1                       // TLSv1.1
	Tlsv1_2                       // TLSv1.2
	Tlsv1_3                       // TLSv1.3
)

func (Protocol) String

func (i Protocol) String() string

type PublicKey

type PublicKey uint8
const (
	PUB_K_Unknown     PublicKey = iota //
	PUB_K_RSA                          // RSA
	PUB_K_DSA                          // DSA
	PUB_K_ECDSA                        // ECDSA
	PUB_K_ED25519                      // Ed25519
	PUB_K_ED448                        // Ed448
	PUB_K_GOSTR341001                  // GOSTR341001
	PUB_K_GOSTR341094                  // GOSTR341094
)

func (PublicKey) String

func (i PublicKey) String() string

type Result

type Result struct {
	Data      []*Data
	Status    string // Final scan status (success or graceful error). Should be stored along with the scan results.
	Exception bool   // Indicates if something went wrong badly and results shall be discarded. This should never be

}

type Scanner

type Scanner struct {
	Label    string
	Started  time.Time
	Finished time.Time
	// contains filtered or unexported fields
}

func NewScanner

func NewScanner(
	logger utils.Logger,
	pythonPath string,
	sslyzeAdditionalTruststore string,
	target string,
	port int,
	vhosts []string,
) (*Scanner, error)

NewScanner initializes a new SSLyze scan. Linux specific implementation, Python and SSLyze package required

func (*Scanner) Run

func (s *Scanner) Run(timeout time.Duration) (res *Result)

Run starts scan execution. This must either be executed as a goroutine, or another thread must be active listening on the scan's result channel, in order to avoid a deadlock situation.

type SignatureAlgorithm

type SignatureAlgorithm uint8
const (
	SIG_A_Unknown SignatureAlgorithm = iota //
	SIG_A_RSA                               // RSA
	SIG_A_DSA                               // DSA
	SIG_A_ECDSA                             // ECDSA
	SIG_A_RSAPSS                            // RSAPSS
)

func (SignatureAlgorithm) IsValidSignatureAlgo

func (a SignatureAlgorithm) IsValidSignatureAlgo() bool

func (SignatureAlgorithm) String

func (i SignatureAlgorithm) String() string

type SignatureHash

type SignatureHash uint8

Signature hash algorithms

const (
	SIG_H_Unknown   SignatureHash = iota //
	SIG_H_None                           // None
	SIG_H_MD2                            // MD2
	SIG_H_MD5                            // MD5
	SIG_H_SHA1                           // SHA1
	SIG_H_SHA224                         // SHA224
	SIG_H_SHA256                         // SHA256
	SIG_H_SHA384                         // SHA384
	SIG_H_SHA512                         // SHA512
	SIG_H_RIPEMD160                      // RMD
	SIG_H_GOSTR3411                      // GOSTR3411
	SIG_H_BLAKE2B                        // BLAKE2b
	SIG_H_BLAKE2S                        // BLAKE2s
)

BLAKE2*: has a variable digest size, 512 is the maximum. SIG_H_None happen if the signature does not use a separate hash (ED25519, ED448).

func (SignatureHash) IsValidSignatureHash

func (h SignatureHash) IsValidSignatureHash() bool

func (SignatureHash) String

func (i SignatureHash) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL