fp

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2019 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeEmpty uint8 = iota
	TypeAntivirus
	TypeFakeBrowser
	TypeMalware
	TypeParental
	TypeProxy
)

Sources:

Variables

View Source
var GlobalCipherCheck = NewCipherCheck()

GlobalCipherCheck is available to external packages.

Functions

This section is empty.

Types

type CipherCheck

type CipherCheck struct {
	// contains filtered or unexported fields
}

CipherCheck maps ciphers to their assigned security grades

func NewCipherCheck

func NewCipherCheck() CipherCheck

NewCipherCheck returns a new CipherCheck initialized with a list of ciphers

func (CipherCheck) AnyKnownAttack

func (a CipherCheck) AnyKnownAttack(cipherList IntList) bool

AnyKnownAttack returns true if any of the ciphers is vulnerable to a known attack

func (CipherCheck) AnyTriviallyBroken

func (a CipherCheck) AnyTriviallyBroken(cipherList IntList) bool

AnyTriviallyBroken returns true if any of the ciphers is trivially broken

func (CipherCheck) Grade

func (a CipherCheck) Grade(cipherList IntList) Grade

Grade returns the security grade of a list of ciphers

func (CipherCheck) IsFirstPfs

func (a CipherCheck) IsFirstPfs(cipherList IntList) bool

IsFirstPfs checks if the first cipher suite has perfect forward secrecy

type Grade

type Grade uint8

Grade represents a TLS client security grade

const (
	GradeEmpty Grade = iota // no grade assigned
	GradeA                  // optimal
	GradeB                  // suboptimal
	GradeC                  // known attack
	GradeF                  // trivially broken
)

Sources:

func (Grade) Merge

func (a Grade) Merge(b Grade) Grade

Merge returns the weakest of two security grades

func (Grade) String

func (a Grade) String() string

String returns a string representation of the grade

type IntList

type IntList []int

IntList is a list of integers

func NewIntList

func NewIntList(s string) (IntList, error)

NewIntList returns a string list parsed from a string.

func (IntList) Contains

func (a IntList) Contains(b IntList) bool

Contains returns true if b is an ordered subsequence of a

func (IntList) Equals

func (a IntList) Equals(b IntList) bool

Equals returns true if a and b are equal

func (*IntList) Parse

func (a *IntList) Parse(s string) error

Parse an int list from a string and return an error on failure

func (IntList) Set

func (a IntList) Set() *IntSet

Set returns a set representation of a list

func (*IntList) String

func (a *IntList) String() string

String returns a comma-separated string of list elements

type IntSet

type IntSet struct {
	intsets.Sparse
	sync.RWMutex
}

IntSet is a set of integers

func (*IntSet) Clear added in v1.0.2

func (a *IntSet) Clear()

Clear empties an array.

func (*IntSet) Copy added in v1.0.2

func (a *IntSet) Copy(b *IntSet)

Copy sets the value of IntSet a to the value of IntSet b.

func (*IntSet) Diff

func (a *IntSet) Diff(b *IntSet) *IntSet

Diff returns the set difference (a \ b)

func (*IntSet) Equal added in v1.0.2

func (a *IntSet) Equal(b *IntSet) bool

IsEmpty a bool indicating whether two intsets are equal or not

func (*IntSet) Has added in v1.0.2

func (a *IntSet) Has(elem int) bool

Has returns a bool indicating whether an intset actually contains the given elem or not.

func (*IntSet) Insert added in v1.0.2

func (a *IntSet) Insert(elem int)

Inserts the given element into the IntSet.

func (*IntSet) Inter

func (a *IntSet) Inter(b *IntSet) *IntSet

Inter returns the set intersection (a & b)

func (*IntSet) IsEmpty added in v1.0.2

func (a *IntSet) IsEmpty() bool

IsEmpty a bool indicating whether an intset is empty or not.

func (*IntSet) Len added in v1.0.2

func (a *IntSet) Len() int

Len returns the length of an IntSet.

func (*IntSet) List

func (a *IntSet) List() IntList

List returns a list representation of a set in sorted order

func (*IntSet) String added in v1.0.2

func (a *IntSet) String() string

String stringifies an IntSet

func (*IntSet) Union

func (a *IntSet) Union(b *IntSet) *IntSet

Union returns the set union (a | b)

type IntSignature

type IntSignature struct {
	OrderedList IntList
	RequiredSet *IntSet
	OptionalSet *IntSet
	UnlikelySet *IntSet
	ExcludedSet *IntSet
}

An IntSignature is a signature on a list of integers.

func NewIntSignature

func NewIntSignature(s string) (IntSignature, error)

NewIntSignature returns a new int signature parsed from a string.

func (IntSignature) Match

func (a IntSignature) Match(list IntList) (Match, int)

Match an int list against the int signature. Returns MatchImpossible if no match is possible, MatchUnlikely if the match is possible with an unlikely configuration, and MatchPossible otherwise.

func (IntSignature) Merge

func (a IntSignature) Merge(b IntSignature) (merged IntSignature)

Merge int signatures a and b to match fingerprints from both.

func (*IntSignature) Parse

func (a *IntSignature) Parse(s string) error

Parse an int signature from a string and return an error on failure.

func (IntSignature) String

func (a IntSignature) String() string

String returns a string representation of the int signature.

type Match

type Match uint8

Match gives the match result for a comparison of a fingerprint to a signature.

const (
	// MatchEmpty is the uninitialized value for a match
	MatchEmpty Match = iota

	// MatchImpossible means that a match is not possible.
	MatchImpossible

	// MatchUnlikely means that a match is possible but unlikely.
	MatchUnlikely

	// MatchPossible means that a match is possible.
	MatchPossible
)

func (Match) String

func (a Match) String() string

String returns a string represenation of a Match type

type MitmInfo

type MitmInfo struct {
	NameList StringList
	Type     uint8
	Grade    Grade
}

MitmInfo contains information about mitm software.

func NewMitmInfo

func NewMitmInfo(s string) (MitmInfo, error)

NewMitmInfo returns a new MitmInfo struct parsed from a string.

func (MitmInfo) Match

func (a MitmInfo) Match(b MitmInfo) Match

Match returns MatchPossible if the lists of mitm names are exactly the same or share a common mitm name, and returns MatchImpossible otherwise.

func (MitmInfo) Merge

func (a MitmInfo) Merge(b MitmInfo) MitmInfo

Merge mitm info a and b.

func (*MitmInfo) Parse

func (a *MitmInfo) Parse(s string) error

Parse info from a string and return an error on failure.

func (MitmInfo) String

func (a MitmInfo) String() string

String returns a string representation of the mitm info.

type RequestFingerprint

type RequestFingerprint struct {
	Version    Version
	Cipher     IntList
	Extension  IntList
	Curve      IntList
	EcPointFmt IntList
	Header     StringList
	Quirk      StringList
}

A RequestFingerprint represents the features of a client request, including client hello features, http headers, and any additional quirks.

func NewRequestFingerprint

func NewRequestFingerprint(s string) (RequestFingerprint, error)

NewRequestFingerprint is a wrapper around RequestFingerprint.Parse

func (*RequestFingerprint) Parse

func (a *RequestFingerprint) Parse(s string) error

Parse a fingerprint from a string and return an error on failure.

func (RequestFingerprint) String

func (a RequestFingerprint) String() string

String returns a string representation of the fingerprint.

type RequestSignature

type RequestSignature struct {
	Version    VersionSignature
	Cipher     IntSignature
	Extension  IntSignature
	Curve      IntSignature
	EcPointFmt IntSignature
	Header     StringSignature
	Quirk      StringSignature
	// contains filtered or unexported fields
}

A RequestSignature represents a set of client request fingerprints. Many TLS/HTTPS implementations can be uniquely identified by their signatures.

func NewRequestSignature

func NewRequestSignature(s string) (RequestSignature, error)

NewRequestSignature is a wrapper around RequestSignature.Parse

func (*RequestSignature) Grade

func (a *RequestSignature) Grade() Grade

Grade returns the security grade for the request signature.

func (*RequestSignature) IsPfs

func (a *RequestSignature) IsPfs() bool

IsPfs returns true if the request signature has perfect forward secrecy.

func (RequestSignature) Match

func (a RequestSignature) Match(fingerprint RequestFingerprint) (Match, int)

Match a fingerprint against the signature. Returns MatchImpossible if no match is possible, MatchUnlikely if the match is possible with an unlikely configuration, and MatchPossible otherwise.

func (RequestSignature) MatchMap

func (a RequestSignature) MatchMap(fingerprint RequestFingerprint) (map[string]Match, int)

MatchMap returns (1) a map of the match results of the fingerprint against the signature, and (2) the count of overlapping cipher, extension, curve, and ecpointfmt values. The second value helps a caller deduce the closest matching record in the case there is no "MatchPossible" match.

func (RequestSignature) Merge

Merge signatures a and b to match fingerprints from both.

func (*RequestSignature) Parse

func (a *RequestSignature) Parse(s string) error

Parse a signature from a string and return an error on failure.

func (RequestSignature) String

func (a RequestSignature) String() string

Returns a string representation of the signature.

type StringList

type StringList []string

StringList is a list of strings

func NewStringList

func NewStringList(s string) (StringList, error)

NewStringList returns a string list parsed from a string.

func (StringList) Contains

func (a StringList) Contains(b StringList) bool

Contains returns true if b is an ordered subsequence of a

func (StringList) Equals

func (a StringList) Equals(b StringList) bool

Equals returns true if a and b are equal

func (*StringList) Parse

func (a *StringList) Parse(s string) error

Parse a stringlist from a string and return an error on failure

func (StringList) Set

func (a StringList) Set() StringSet

Set returns a set representation of a list

func (StringList) String

func (a StringList) String() string

String returns a comma-separated string of list elements

type StringSet

type StringSet map[string]bool

StringSet is a set of strings

func (StringSet) Diff

func (a StringSet) Diff(b StringSet) StringSet

Diff returns the set difference (a - b)

func (StringSet) Inter

func (a StringSet) Inter(b StringSet) StringSet

Inter returns the set intersection (a & b)

func (StringSet) List

func (a StringSet) List() StringList

List returns a list representation of a set in sorted order

func (StringSet) Union

func (a StringSet) Union(b StringSet) StringSet

Union returns the set union (a | b)

type StringSignature

type StringSignature struct {
	OrderedList StringList
	RequiredSet StringSet
	OptionalSet StringSet
	UnlikelySet StringSet
	ExcludedSet StringSet
}

A StringSignature is a signature on a list of strings.

func NewStringSignature

func NewStringSignature(s string) (StringSignature, error)

NewStringSignature returns a new string signature parsed from a string.

func (StringSignature) Match

func (a StringSignature) Match(list StringList) Match

Match a string list against the string signature. Returns MatchImpossible if no match is possible, MatchUnlikely if the match is possible with an unlikely configuration, and MatchPossible otherwise.

func (StringSignature) Merge

func (a StringSignature) Merge(b StringSignature) (merged StringSignature)

Merge string signatures a and b to match fingerprints from both.

func (*StringSignature) Parse

func (a *StringSignature) Parse(s string) error

Parse a string signature from a string and return an error on failure.

func (StringSignature) String

func (a StringSignature) String() string

String returns a string representation of the string signature.

type UAFingerprint

type UAFingerprint struct {
	BrowserName    int
	BrowserVersion UAVersion
	OSPlatform     int
	OSName         int
	OSVersion      UAVersion
	DeviceType     int
	Quirk          StringList
}

UAFingerprint is a fingerprint for a user agent

func NewUAFingerprint

func NewUAFingerprint(s string) (UAFingerprint, error)

NewUAFingerprint returns a new user agent fingerprint parsed from a string

func (*UAFingerprint) Parse

func (a *UAFingerprint) Parse(s string) error

Parse a user agent fingerprint from a string and return an error on failure

func (UAFingerprint) String

func (a UAFingerprint) String() string

String returns a string representation of a fingerprint

type UASignature

type UASignature struct {
	BrowserName    int
	BrowserVersion UAVersionSignature
	OSPlatform     int
	OSName         int
	OSVersion      UAVersionSignature
	DeviceType     int
	Quirk          StringSignature
}

A UASignature represents a set of user agents

func NewUASignature

func NewUASignature(s string) (UASignature, error)

NewUASignature returns a new user agent signature parsed from a string

func (UASignature) Match

func (a UASignature) Match(fingerprint UAFingerprint) Match

Match a user agent against the user agent signature. Returns MatchImpossible if no match is possible, MatchUnlikely if the match is possible with an unlikely configuration, and MatchPossible otherwise.

func (UASignature) Merge

func (a UASignature) Merge(b UASignature) UASignature

Merge user agent signatures a and b to match fingerprints from both.

func (*UASignature) Parse

func (a *UASignature) Parse(s string) error

Parse a user agent signature from a string and return an error on failure

func (UASignature) String

func (a UASignature) String() string

String returns a string representation of a signature

type UAVersion

type UAVersion ua.Version

UAVersion represents a user agent browser or OS version.

func (*UAVersion) Parse

func (a *UAVersion) Parse(s string) error

Parse a user agent version from a string and return an error on failure.

func (UAVersion) String

func (a UAVersion) String() string

type UAVersionSignature

type UAVersionSignature struct {
	Min UAVersion
	Max UAVersion
}

A UAVersionSignature matches a range of possible user agent versions

func (UAVersionSignature) Match

func (a UAVersionSignature) Match(fingerprint UAVersion) Match

Match a user agent fingerprint against the signature. Returns MatchImpossible if no match is possible, MatchUnlikely if the match is possible with an unlikely configuration, and MatchPossible otherwise.

func (UAVersionSignature) Merge

Merge signatures a and b to match fingerprints from both.

func (*UAVersionSignature) Parse

func (a *UAVersionSignature) Parse(s string) error

Parse a user agent version signature from a string and return an error on failure.

func (UAVersionSignature) String

func (a UAVersionSignature) String() string

type Version

type Version uint16

Version represents a TLS Version

const (
	VersionEmpty Version = 0
	VersionSSL2  Version = 0x0200 // 0x0002 on the wire, so let's swap here
	VersionSSL3  Version = 0x0300
	VersionTLS10 Version = 0x0301
	VersionTLS11 Version = 0x0302
	VersionTLS12 Version = 0x0303
	VersionTLS13 Version = 0x0304
)

Source:

func NewVersion

func NewVersion(s string) (Version, error)

NewVersion parses a version from a string, returning VersionEmpty if not recognized

func (Version) Grade

func (a Version) Grade() Grade

Grade returns a security grade for the version

func (*Version) Parse

func (a *Version) Parse(s string) error

Parse initializes a version from a string

func (Version) String

func (a Version) String() string

String returns a string representation of the version

type VersionSignature

type VersionSignature struct {
	Min Version
	Exp Version
	Max Version
}

A VersionSignature is a signature for a TLS version.

func NewVersionSignature added in v1.0.1

func NewVersionSignature(s string) (VersionSignature, error)

NewVersionSignature returns a new int signature parsed from a string.

func (VersionSignature) Match

func (a VersionSignature) Match(version Version) Match

Match a version against the version signature. Returns MatchImpossible if no match is possible, MatchUnlikely if the match is possible with an unlikely configuration, and MatchPossible otherwise.

func (VersionSignature) Merge

Merge version signatures a and b to match fingerprints from both.

func (*VersionSignature) Parse

func (a *VersionSignature) Parse(s string) error

Parse a version signature from a string and return an error on failure.

func (VersionSignature) String

func (a VersionSignature) String() string

Return a string representation of the version signature.

Jump to

Keyboard shortcuts

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