-
Notifications
You must be signed in to change notification settings - Fork 29
/
fingerprints.go
50 lines (40 loc) · 951 Bytes
/
fingerprints.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package tcpraw
import (
"encoding/binary"
"time"
"github.com/google/gopacket/layers"
)
type FingerPrintType int
const (
TypeLinux FingerPrintType = iota
)
type fingerPrint struct {
Type FingerPrintType
Window uint16
Options []layers.TCPOption
TTL uint16
}
// options [nop,nop,TS val 1940162183 ecr 1366690553]
var fingerPrintLinux = fingerPrint{
Type: TypeLinux,
Window: 65535,
Options: []layers.TCPOption{
{1, 0, nil},
{1, 0, nil},
{8, 10, make([]byte, 10)}, // len = 10
},
TTL: 64,
}
var defaultFingerPrint = fingerPrintLinux
var seed uint32
func init() {
seed = uint32(time.Now().UnixNano())
}
func makeOption(optType FingerPrintType, options []layers.TCPOption) {
switch optType {
case TypeLinux:
nowMilli := time.Now().UnixNano() / 1e9
binary.BigEndian.PutUint32(options[2].OptionData[:4], uint32(nowMilli))
binary.BigEndian.PutUint32(options[2].OptionData[4:], uint32(seed+uint32(nowMilli)))
}
}