代码拉取完成,页面将自动刷新
package tls
import (
"crypto/md5"
"encoding/hex"
"strconv"
"strings"
)
func getJa3Fingerprint(hello *helloMessage) (hash string, ja3str string) {
// build the array of arrays of numbers
data := make([][]uint16, 5)
// Version as integer
data[0] = []uint16{uint16(hello.version.major)*256 + uint16(hello.version.minor)}
// ciphersuites, in client-supplied priority
data[1] = make([]uint16, 0)
for _, suite := range hello.supported.cipherSuites {
if !isGreaseValue(uint16(suite)) {
data[1] = append(data[1], uint16(suite))
}
}
// extensions
data[2] = make([]uint16, len(hello.extensions.InOrder))
for idx, extid := range hello.extensions.InOrder {
data[2][idx] = uint16(extid)
}
data[3] = extractJa3Array(hello.extensions.Raw[ExtensionSupportedGroups], 2)
data[4] = extractJa3Array(hello.extensions.Raw[ExtensionEllipticCurvePointsFormats], 1)
// build the string
parts := make([]string, len(data))
for i, arr := range data {
strNum := make([]string, len(arr))
for j, num := range arr {
strNum[j] = strconv.Itoa(int(num))
}
parts[i] = strings.Join(strNum, "-")
}
ja3str = strings.Join(parts, ",")
sum := md5.Sum([]byte(ja3str))
return hex.EncodeToString(sum[:]), ja3str
}
func extractJa3Array(raw []byte, size int) []uint16 {
if size < 1 || size > 2 {
return nil
}
actual := len(raw)
if actual < size {
return nil
}
limit := int(raw[0])
if size == 2 {
limit = limit*256 + int(raw[1])
}
if actual < limit {
limit = actual
}
var array []uint16
for pos := size; pos <= limit; pos += size {
value := uint16(raw[pos])
if size == 2 {
value = value*256 + uint16(raw[pos+1])
}
if !isGreaseValue(value) {
array = append(array, value)
}
}
return array
}
func isGreaseValue(num uint16) bool {
hi, lo := byte(num>>8), byte(num)
return hi == lo && lo&0xf == 0xa
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。