mirror of https://github.com/cbeuw/Cloak
Refactor Browser fingerprint modules
This commit is contained in:
parent
4fbf387bbf
commit
896fd16938
|
|
@ -0,0 +1,41 @@
|
||||||
|
package browsers
|
||||||
|
|
||||||
|
import "encoding/binary"
|
||||||
|
|
||||||
|
type ClientHelloFields struct {
|
||||||
|
Random []byte
|
||||||
|
SessionId []byte
|
||||||
|
X25519KeyShare []byte
|
||||||
|
ServerName string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Browser represents the signature of a browser at a particular version
|
||||||
|
type Browser interface {
|
||||||
|
// ComposeClientHello produces the ClientHello message (without TLS record layer) as the mimicking browser would
|
||||||
|
ComposeClientHello(ClientHelloFields) []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
// addExtensionRecord, add type, length to extension data
|
||||||
|
func addExtRec(typ []byte, data []byte) []byte {
|
||||||
|
length := make([]byte, 2)
|
||||||
|
binary.BigEndian.PutUint16(length, uint16(len(data)))
|
||||||
|
ret := make([]byte, 2+2+len(data))
|
||||||
|
copy(ret[0:2], typ)
|
||||||
|
copy(ret[2:4], length)
|
||||||
|
copy(ret[4:], data)
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func generateSNI(serverName string) []byte {
|
||||||
|
serverNameListLength := make([]byte, 2)
|
||||||
|
binary.BigEndian.PutUint16(serverNameListLength, uint16(len(serverName)+3))
|
||||||
|
serverNameType := []byte{0x00} // host_name
|
||||||
|
serverNameLength := make([]byte, 2)
|
||||||
|
binary.BigEndian.PutUint16(serverNameLength, uint16(len(serverName)))
|
||||||
|
ret := make([]byte, 2+1+2+len(serverName))
|
||||||
|
copy(ret[0:2], serverNameListLength)
|
||||||
|
copy(ret[2:3], serverNameType)
|
||||||
|
copy(ret[3:5], serverNameLength)
|
||||||
|
copy(ret[5:], serverName)
|
||||||
|
return ret
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue