netkitty 0.0.20 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +2 -2
- package/.idea/inspectionProfiles/Project_Default.xml +2 -1
- package/.idea/netkitty.iml +0 -1
- package/cpp/nodepcap/deps/include/Packet32.h +429 -429
- package/cpp/nodepcap/deps/include/pcap/bluetooth.h +56 -56
- package/cpp/nodepcap/deps/include/pcap/bpf.h +292 -292
- package/cpp/nodepcap/deps/include/pcap/can_socketcan.h +56 -56
- package/cpp/nodepcap/deps/include/pcap/compiler-tests.h +163 -163
- package/cpp/nodepcap/deps/include/pcap/dlt.h +1514 -1514
- package/cpp/nodepcap/deps/include/pcap/funcattrs.h +325 -325
- package/cpp/nodepcap/deps/include/pcap/ipnet.h +43 -43
- package/cpp/nodepcap/deps/include/pcap/namedb.h +84 -84
- package/cpp/nodepcap/deps/include/pcap/nflog.h +94 -94
- package/cpp/nodepcap/deps/include/pcap/pcap-inttypes.h +101 -101
- package/cpp/nodepcap/deps/include/pcap/pcap.h +1219 -1219
- package/cpp/nodepcap/deps/include/pcap/sll.h +149 -149
- package/cpp/nodepcap/deps/include/pcap/socket.h +84 -84
- package/cpp/nodepcap/deps/include/pcap/usb.h +143 -143
- package/cpp/nodepcap/deps/include/pcap/vlan.h +46 -46
- package/cpp/nodepcap/deps/include/pcap-bpf.h +45 -45
- package/cpp/nodepcap/deps/include/pcap-namedb.h +40 -40
- package/cpp/nodepcap/deps/include/pcap.h +43 -43
- package/dist/PcapExports.d.ts +13 -0
- package/dist/PcapExports.d.ts.map +1 -1
- package/dist/PcapExports.js +16 -1
- package/dist/lib/codec/Codec.js +1 -1
- package/dist/lib/codec/PacketHeaders.d.ts +5 -0
- package/dist/lib/codec/PacketHeaders.d.ts.map +1 -1
- package/dist/lib/codec/PacketHeaders.js +13 -1
- package/dist/lib/codec/abstracts/BaseHeader.d.ts +2 -2
- package/dist/lib/codec/abstracts/BaseHeader.d.ts.map +1 -1
- package/dist/lib/codec/abstracts/BaseHeader.js +4 -4
- package/dist/lib/codec/headers/EthernetII.js +1 -1
- package/dist/lib/codec/headers/Goose.js +5 -5
- package/dist/lib/codec/headers/IEC61850SampledValues.js +1 -1
- package/dist/lib/codec/headers/IPv4.js +2 -2
- package/dist/lib/codec/headers/TLS_Alert.d.ts +10 -0
- package/dist/lib/codec/headers/TLS_Alert.d.ts.map +1 -0
- package/dist/lib/codec/headers/TLS_Alert.js +624 -0
- package/dist/lib/codec/headers/TLS_ApplicationData.d.ts +10 -0
- package/dist/lib/codec/headers/TLS_ApplicationData.d.ts.map +1 -0
- package/dist/lib/codec/headers/TLS_ApplicationData.js +155 -0
- package/dist/lib/codec/headers/TLS_ChangeCipherSpec.d.ts +10 -0
- package/dist/lib/codec/headers/TLS_ChangeCipherSpec.d.ts.map +1 -0
- package/dist/lib/codec/headers/TLS_ChangeCipherSpec.js +154 -0
- package/dist/lib/codec/headers/TLS_Handshake.d.ts +10 -0
- package/dist/lib/codec/headers/TLS_Handshake.d.ts.map +1 -0
- package/dist/lib/codec/headers/TLS_Handshake.js +339 -0
- package/dist/lib/codec/headers/TLS_Heartbeat.d.ts +10 -0
- package/dist/lib/codec/headers/TLS_Heartbeat.d.ts.map +1 -0
- package/dist/lib/codec/headers/TLS_Heartbeat.js +206 -0
- package/dist/lib/codec/headers/VLAN_802dot1Q.js +1 -1
- package/dist/lib/pcap/PCAPGenerator.d.ts +2 -2
- package/dist/lib/pcap/PCAPGenerator.d.ts.map +1 -1
- package/dist/lib/pcap/PCAPGenerator.js +7 -1
- package/package.json +1 -1
- package/src/PcapExports.ts +16 -0
- package/src/lib/codec/Codec.ts +1 -1
- package/src/lib/codec/PacketHeaders.ts +7 -0
- package/src/lib/codec/abstracts/BaseHeader.ts +4 -4
- package/src/lib/codec/headers/EthernetII.ts +1 -1
- package/src/lib/codec/headers/Goose.ts +5 -5
- package/src/lib/codec/headers/IEC61850SampledValues.ts +1 -1
- package/src/lib/codec/headers/IPv4.ts +2 -2
- package/src/lib/codec/headers/TLS_Alert.ts +539 -0
- package/src/lib/codec/headers/TLS_ApplicationData.ts +145 -0
- package/src/lib/codec/headers/TLS_ChangeCipherSpec.ts +146 -0
- package/src/lib/codec/headers/TLS_Handshake.ts +313 -0
- package/src/lib/codec/headers/TLS_Heartbeat.ts +188 -0
- package/src/lib/codec/headers/VLAN_802dot1Q.ts +1 -1
- package/src/lib/pcap/PCAPGenerator.ts +8 -3
- package/dist/NetKitty.d.ts +0 -1
- package/dist/NetKitty.d.ts.map +0 -1
- package/dist/NetKitty.js +0 -90
- package/src/NetKitty.ts +0 -91
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import {ProtocolJSONSchema} from '../../schema/ProtocolJSONSchema'
|
|
2
|
+
import {BaseHeader} from '../abstracts/BaseHeader'
|
|
3
|
+
import {BufferToInt8, BufferToUInt16} from '../../helper/BufferToNumber'
|
|
4
|
+
import {BufferToHex} from '../../helper/BufferToHex'
|
|
5
|
+
import {UInt16ToBuffer, UInt8ToBuffer} from '../../helper/NumberToBuffer'
|
|
6
|
+
import {HexToBuffer} from '../../helper/HexToBuffer'
|
|
7
|
+
|
|
8
|
+
enum TLSver {
|
|
9
|
+
SSL_3_0 = 'SSL3.0',
|
|
10
|
+
TLS_1_0 = 'TLS1.0',
|
|
11
|
+
TLS_1_1 = 'TLS1.1',
|
|
12
|
+
TLS_1_2 = 'TLS1.2',
|
|
13
|
+
TLS_1_3 = 'TLS1.3',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class TLS_ChangeCipherSpec extends BaseHeader {
|
|
17
|
+
public SCHEMA: ProtocolJSONSchema = {
|
|
18
|
+
type: 'object',
|
|
19
|
+
properties: {
|
|
20
|
+
contentType: {
|
|
21
|
+
type: 'integer',
|
|
22
|
+
label: 'Content Type',
|
|
23
|
+
minimum: 0,
|
|
24
|
+
maximum: 255,
|
|
25
|
+
decode: (): void => {
|
|
26
|
+
this.instance.contentType.setValue(BufferToInt8(this.readBytes(0, 1)))
|
|
27
|
+
|
|
28
|
+
},
|
|
29
|
+
encode: (): void => {
|
|
30
|
+
|
|
31
|
+
const contentType: Buffer = UInt8ToBuffer(this.instance.contentType.getValue(0, (nodePath: string): void => this.recordError(nodePath, 'Not found')))
|
|
32
|
+
this.writeBytes(0, contentType)
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
version: {
|
|
37
|
+
type: 'string',
|
|
38
|
+
label: 'Legacy Version',
|
|
39
|
+
minimum: 0,
|
|
40
|
+
maximum: 65535,
|
|
41
|
+
decode: (): void => {
|
|
42
|
+
const version: number = BufferToUInt16(this.readBytes(1, 2))
|
|
43
|
+
switch (version) {
|
|
44
|
+
case 768: {
|
|
45
|
+
this.instance.version.setValue(TLSver.SSL_3_0)
|
|
46
|
+
}
|
|
47
|
+
break
|
|
48
|
+
case 769: {
|
|
49
|
+
this.instance.version.setValue(TLSver.TLS_1_0)
|
|
50
|
+
}
|
|
51
|
+
break
|
|
52
|
+
case 770: {
|
|
53
|
+
this.instance.version.setValue(TLSver.TLS_1_1)
|
|
54
|
+
}
|
|
55
|
+
break
|
|
56
|
+
case 771: {
|
|
57
|
+
this.instance.version.setValue(TLSver.TLS_1_2)
|
|
58
|
+
}
|
|
59
|
+
break
|
|
60
|
+
case 772: {
|
|
61
|
+
this.instance.version.setValue(TLSver.TLS_1_3)
|
|
62
|
+
}
|
|
63
|
+
break
|
|
64
|
+
default: {
|
|
65
|
+
this.instance.version.setValue('0')
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
},
|
|
71
|
+
encode: (): void => {
|
|
72
|
+
const version: string = this.instance.version.getValue('0', (nodePath: string): void => this.recordError(nodePath, 'Not found'))
|
|
73
|
+
switch (version) {
|
|
74
|
+
case TLSver.SSL_3_0: {
|
|
75
|
+
const version: Buffer = UInt16ToBuffer(768)
|
|
76
|
+
this.writeBytes(1, version)
|
|
77
|
+
}
|
|
78
|
+
break
|
|
79
|
+
case TLSver.TLS_1_0: {
|
|
80
|
+
const version: Buffer = UInt16ToBuffer(769)
|
|
81
|
+
this.writeBytes(1, version)
|
|
82
|
+
}
|
|
83
|
+
break
|
|
84
|
+
case TLSver.TLS_1_1: {
|
|
85
|
+
const version: Buffer = UInt16ToBuffer(770)
|
|
86
|
+
this.writeBytes(1, version)
|
|
87
|
+
}
|
|
88
|
+
break
|
|
89
|
+
case TLSver.TLS_1_2: {
|
|
90
|
+
const version: Buffer = UInt16ToBuffer(771)
|
|
91
|
+
this.writeBytes(1, version)
|
|
92
|
+
}
|
|
93
|
+
break
|
|
94
|
+
case TLSver.TLS_1_3: {
|
|
95
|
+
const version: Buffer = UInt16ToBuffer(772)
|
|
96
|
+
this.writeBytes(1, version)
|
|
97
|
+
}
|
|
98
|
+
break
|
|
99
|
+
default: {
|
|
100
|
+
this.writeBytes(1, UInt16ToBuffer(0))
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
length: {
|
|
106
|
+
type: 'integer',
|
|
107
|
+
label: 'Length',
|
|
108
|
+
minimum: 0,
|
|
109
|
+
maximum: 65535,
|
|
110
|
+
decode: (): void => {
|
|
111
|
+
this.instance.length.setValue(BufferToUInt16(this.readBytes(3, 2)))
|
|
112
|
+
},
|
|
113
|
+
encode: (): void => {
|
|
114
|
+
const length: Buffer = UInt16ToBuffer(this.instance.length.getValue(0, (nodePath: string): void => this.recordError(nodePath, 'Not found')))
|
|
115
|
+
this.writeBytes(3, length)
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
change_cipher_spec_message: {
|
|
119
|
+
type: 'string',
|
|
120
|
+
label: 'Change Cipher Spec Message',
|
|
121
|
+
decode: (): void => {
|
|
122
|
+
const length: number = this.instance.length.getValue(0, (nodePath: string): void => this.recordError(nodePath, 'Not found'))
|
|
123
|
+
this.instance.change_cipher_spec_message.setValue(BufferToHex(this.readBytes(5, length)))
|
|
124
|
+
},
|
|
125
|
+
encode: (): void => {
|
|
126
|
+
const message: Buffer = HexToBuffer(this.instance.change_cipher_spec_message.getValue('0', (nodePath: string): void => this.recordError(nodePath, 'Not found')))
|
|
127
|
+
this.writeBytes(5, message)
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
public id: string = 'tls-ccsp'
|
|
135
|
+
public name: string = 'Transport Layer Security(ChangeCipherSpec Protocol)'
|
|
136
|
+
public nickname: string = 'TLS'
|
|
137
|
+
|
|
138
|
+
public match(): boolean {
|
|
139
|
+
if (!this.prevCodecModule) return false
|
|
140
|
+
if (BufferToHex(this.readBytes(0, 1)) != '14') return false
|
|
141
|
+
const version: number = BufferToUInt16(this.readBytes(1, 2))
|
|
142
|
+
const validVersions: number[] = [768, 769, 770, 771, 772]
|
|
143
|
+
return validVersions.includes(version)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
}
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import {ProtocolJSONSchema} from '../../schema/ProtocolJSONSchema'
|
|
2
|
+
import {BaseHeader} from '../abstracts/BaseHeader'
|
|
3
|
+
import {
|
|
4
|
+
BufferToInt8,
|
|
5
|
+
BufferToUInt16,
|
|
6
|
+
BufferToUInt32,
|
|
7
|
+
BufferToUInt8
|
|
8
|
+
} from '../../helper/BufferToNumber'
|
|
9
|
+
import {BufferToHex} from '../../helper/BufferToHex'
|
|
10
|
+
import {UInt16ToBuffer, UInt8ToBuffer} from '../../helper/NumberToBuffer'
|
|
11
|
+
import {HexToBuffer} from '../../helper/HexToBuffer'
|
|
12
|
+
|
|
13
|
+
enum TLSver {
|
|
14
|
+
SSL_3_0 = 'SSL3.0',
|
|
15
|
+
TLS_1_0 = 'TLS1.0',
|
|
16
|
+
TLS_1_1 = 'TLS1.1',
|
|
17
|
+
TLS_1_2 = 'TLS1.2',
|
|
18
|
+
TLS_1_3 = 'TLS1.3',
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
enum HandshakeType {
|
|
22
|
+
Handshake_1 = 'HelloRequest',
|
|
23
|
+
Handshake_2 = 'ClientHello',
|
|
24
|
+
Handshake_3 = 'ServerHello',
|
|
25
|
+
Handshake_4 = 'NewSessionTicket',
|
|
26
|
+
Handshake_5 = 'EncryptedExtensions',
|
|
27
|
+
Handshake_6 = 'Certificate',
|
|
28
|
+
Handshake_7 = 'ServerKeyExchange',
|
|
29
|
+
Handshake_8 = 'CertificateRequest',
|
|
30
|
+
Handshake_9 = 'ServerHelloDone',
|
|
31
|
+
Handshake_10 = 'CertificateVerify',
|
|
32
|
+
Handshake_11 = 'ClientKeyExchange',
|
|
33
|
+
Handshake_12 = 'Finished',
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export class TLS_Handshake extends BaseHeader {
|
|
37
|
+
public SCHEMA: ProtocolJSONSchema = {
|
|
38
|
+
type: 'object',
|
|
39
|
+
properties: {
|
|
40
|
+
contentType: {
|
|
41
|
+
type: 'integer',
|
|
42
|
+
label: 'Content Type',
|
|
43
|
+
minimum: 0,
|
|
44
|
+
maximum: 255,
|
|
45
|
+
decode: (): void => {
|
|
46
|
+
this.instance.contentType.setValue(BufferToInt8(this.readBytes(0, 1)))
|
|
47
|
+
|
|
48
|
+
},
|
|
49
|
+
encode: (): void => {
|
|
50
|
+
|
|
51
|
+
const contentType: Buffer = UInt8ToBuffer(this.instance.contentType.getValue(0, (nodePath: string): void => this.recordError(nodePath, 'Not found')))
|
|
52
|
+
this.writeBytes(0, contentType)
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
version: {
|
|
57
|
+
type: 'string',
|
|
58
|
+
label: 'Legacy Version',
|
|
59
|
+
minimum: 0,
|
|
60
|
+
maximum: 65535,
|
|
61
|
+
decode: (): void => {
|
|
62
|
+
const version: number = BufferToUInt16(this.readBytes(1, 2))
|
|
63
|
+
switch (version) {
|
|
64
|
+
case 768: {
|
|
65
|
+
this.instance.version.setValue(TLSver.SSL_3_0)
|
|
66
|
+
}
|
|
67
|
+
break
|
|
68
|
+
case 769: {
|
|
69
|
+
this.instance.version.setValue(TLSver.TLS_1_0)
|
|
70
|
+
}
|
|
71
|
+
break
|
|
72
|
+
case 770: {
|
|
73
|
+
this.instance.version.setValue(TLSver.TLS_1_1)
|
|
74
|
+
}
|
|
75
|
+
break
|
|
76
|
+
case 771: {
|
|
77
|
+
this.instance.version.setValue(TLSver.TLS_1_2)
|
|
78
|
+
}
|
|
79
|
+
break
|
|
80
|
+
case 772: {
|
|
81
|
+
this.instance.version.setValue(TLSver.TLS_1_3)
|
|
82
|
+
}
|
|
83
|
+
break
|
|
84
|
+
default: {
|
|
85
|
+
this.instance.version.setValue('0')
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
},
|
|
91
|
+
encode: (): void => {
|
|
92
|
+
const version: string = this.instance.version.getValue('0', (nodePath: string): void => this.recordError(nodePath, 'Not found'))
|
|
93
|
+
switch (version) {
|
|
94
|
+
case TLSver.SSL_3_0: {
|
|
95
|
+
const version: Buffer = UInt16ToBuffer(768)
|
|
96
|
+
this.writeBytes(1, version)
|
|
97
|
+
}
|
|
98
|
+
break
|
|
99
|
+
case TLSver.TLS_1_0: {
|
|
100
|
+
const version: Buffer = UInt16ToBuffer(769)
|
|
101
|
+
this.writeBytes(1, version)
|
|
102
|
+
}
|
|
103
|
+
break
|
|
104
|
+
case TLSver.TLS_1_1: {
|
|
105
|
+
const version: Buffer = UInt16ToBuffer(770)
|
|
106
|
+
this.writeBytes(1, version)
|
|
107
|
+
}
|
|
108
|
+
break
|
|
109
|
+
case TLSver.TLS_1_2: {
|
|
110
|
+
const version: Buffer = UInt16ToBuffer(771)
|
|
111
|
+
this.writeBytes(1, version)
|
|
112
|
+
}
|
|
113
|
+
break
|
|
114
|
+
case TLSver.TLS_1_3: {
|
|
115
|
+
const version: Buffer = UInt16ToBuffer(772)
|
|
116
|
+
this.writeBytes(1, version)
|
|
117
|
+
}
|
|
118
|
+
break
|
|
119
|
+
default: {
|
|
120
|
+
this.writeBytes(1, UInt16ToBuffer(0))
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
length: {
|
|
126
|
+
type: 'integer',
|
|
127
|
+
label: 'Length',
|
|
128
|
+
minimum: 0,
|
|
129
|
+
maximum: 65535,
|
|
130
|
+
decode: (): void => {
|
|
131
|
+
this.instance.length.setValue(BufferToUInt16(this.readBytes(3, 2)))
|
|
132
|
+
},
|
|
133
|
+
encode: (): void => {
|
|
134
|
+
const length: Buffer = UInt16ToBuffer(this.instance.length.getValue(0, (nodePath: string): void => this.recordError(nodePath, 'Not found')))
|
|
135
|
+
this.writeBytes(3, length)
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
handshakeType: {
|
|
139
|
+
type: 'string',
|
|
140
|
+
label: 'Handshake Type',
|
|
141
|
+
minimum: 0,
|
|
142
|
+
maximum: 65535,
|
|
143
|
+
decode: (): void => {
|
|
144
|
+
const handshakeType: number = BufferToUInt8(this.readBytes(5, 1))
|
|
145
|
+
switch (handshakeType) {
|
|
146
|
+
case 0: {
|
|
147
|
+
this.instance.handshakeType.setValue(HandshakeType.Handshake_1)
|
|
148
|
+
}
|
|
149
|
+
break
|
|
150
|
+
case 1: {
|
|
151
|
+
this.instance.handshakeType.setValue(HandshakeType.Handshake_2)
|
|
152
|
+
}
|
|
153
|
+
break
|
|
154
|
+
case 2: {
|
|
155
|
+
this.instance.handshakeType.setValue(HandshakeType.Handshake_3)
|
|
156
|
+
}
|
|
157
|
+
break
|
|
158
|
+
case 4: {
|
|
159
|
+
this.instance.handshakeType.setValue(HandshakeType.Handshake_4)
|
|
160
|
+
}
|
|
161
|
+
break
|
|
162
|
+
case 8: {
|
|
163
|
+
this.instance.handshakeType.setValue(HandshakeType.Handshake_5)
|
|
164
|
+
}
|
|
165
|
+
break
|
|
166
|
+
case 11: {
|
|
167
|
+
this.instance.handshakeType.setValue(HandshakeType.Handshake_6)
|
|
168
|
+
}
|
|
169
|
+
break
|
|
170
|
+
case 12: {
|
|
171
|
+
this.instance.handshakeType.setValue(HandshakeType.Handshake_7)
|
|
172
|
+
}
|
|
173
|
+
break
|
|
174
|
+
case 13: {
|
|
175
|
+
this.instance.handshakeType.setValue(HandshakeType.Handshake_8)
|
|
176
|
+
}
|
|
177
|
+
break
|
|
178
|
+
case 14: {
|
|
179
|
+
this.instance.handshakeType.setValue(HandshakeType.Handshake_9)
|
|
180
|
+
}
|
|
181
|
+
break
|
|
182
|
+
case 15: {
|
|
183
|
+
this.instance.handshakeType.setValue(HandshakeType.Handshake_10)
|
|
184
|
+
}
|
|
185
|
+
break
|
|
186
|
+
case 16: {
|
|
187
|
+
this.instance.handshakeType.setValue(HandshakeType.Handshake_11)
|
|
188
|
+
}
|
|
189
|
+
break
|
|
190
|
+
case 20: {
|
|
191
|
+
this.instance.handshakeType.setValue(HandshakeType.Handshake_12)
|
|
192
|
+
}
|
|
193
|
+
break
|
|
194
|
+
default: {
|
|
195
|
+
this.instance.handshakeType.setValue(BufferToUInt8(this.readBytes(5, 1)))
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
encode: (): void => {
|
|
200
|
+
const handshakeType: string = this.instance.handshakeType.getValue('0')
|
|
201
|
+
switch (handshakeType) {
|
|
202
|
+
case HandshakeType.Handshake_1: {
|
|
203
|
+
const handshakeType: Buffer = UInt8ToBuffer(0)
|
|
204
|
+
this.writeBytes(5, handshakeType)
|
|
205
|
+
}
|
|
206
|
+
break
|
|
207
|
+
case HandshakeType.Handshake_2: {
|
|
208
|
+
const handshakeType: Buffer = UInt8ToBuffer(1)
|
|
209
|
+
this.writeBytes(5, handshakeType)
|
|
210
|
+
}
|
|
211
|
+
break
|
|
212
|
+
case HandshakeType.Handshake_3: {
|
|
213
|
+
const handshakeType: Buffer = UInt8ToBuffer(2)
|
|
214
|
+
this.writeBytes(5, handshakeType)
|
|
215
|
+
}
|
|
216
|
+
break
|
|
217
|
+
case HandshakeType.Handshake_4: {
|
|
218
|
+
const handshakeType: Buffer = UInt8ToBuffer(4)
|
|
219
|
+
this.writeBytes(5, handshakeType)
|
|
220
|
+
}
|
|
221
|
+
break
|
|
222
|
+
case HandshakeType.Handshake_5: {
|
|
223
|
+
const handshakeType: Buffer = UInt8ToBuffer(8)
|
|
224
|
+
this.writeBytes(5, handshakeType)
|
|
225
|
+
}
|
|
226
|
+
break
|
|
227
|
+
case HandshakeType.Handshake_6: {
|
|
228
|
+
const handshakeType: Buffer = UInt8ToBuffer(11)
|
|
229
|
+
this.writeBytes(5, handshakeType)
|
|
230
|
+
}
|
|
231
|
+
break
|
|
232
|
+
case HandshakeType.Handshake_7: {
|
|
233
|
+
const handshakeType: Buffer = UInt8ToBuffer(12)
|
|
234
|
+
this.writeBytes(5, handshakeType)
|
|
235
|
+
}
|
|
236
|
+
break
|
|
237
|
+
case HandshakeType.Handshake_8: {
|
|
238
|
+
const handshakeType: Buffer = UInt8ToBuffer(13)
|
|
239
|
+
this.writeBytes(5, handshakeType)
|
|
240
|
+
}
|
|
241
|
+
break
|
|
242
|
+
case HandshakeType.Handshake_9: {
|
|
243
|
+
const handshakeType: Buffer = UInt8ToBuffer(14)
|
|
244
|
+
this.writeBytes(5, handshakeType)
|
|
245
|
+
}
|
|
246
|
+
break
|
|
247
|
+
case HandshakeType.Handshake_10: {
|
|
248
|
+
const handshakeType: Buffer = UInt8ToBuffer(15)
|
|
249
|
+
this.writeBytes(5, handshakeType)
|
|
250
|
+
}
|
|
251
|
+
break
|
|
252
|
+
case HandshakeType.Handshake_11: {
|
|
253
|
+
const handshakeType: Buffer = UInt8ToBuffer(16)
|
|
254
|
+
this.writeBytes(5, handshakeType)
|
|
255
|
+
}
|
|
256
|
+
break
|
|
257
|
+
case HandshakeType.Handshake_12: {
|
|
258
|
+
const handshakeType: Buffer = UInt8ToBuffer(20)
|
|
259
|
+
this.writeBytes(5, handshakeType)
|
|
260
|
+
}
|
|
261
|
+
break
|
|
262
|
+
default: {
|
|
263
|
+
const handshakeType1: number = parseInt(handshakeType)
|
|
264
|
+
this.writeBytes(5, UInt8ToBuffer(handshakeType1))
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
handshakeLength: {
|
|
271
|
+
type: 'integer',
|
|
272
|
+
label: 'Length',
|
|
273
|
+
minimum: 0,
|
|
274
|
+
maximum: 1118481,
|
|
275
|
+
decode: (): void => {
|
|
276
|
+
this.instance.handshakeLength.setValue(BufferToUInt32(this.readBytes(6, 3)))
|
|
277
|
+
},
|
|
278
|
+
encode: (): void => {
|
|
279
|
+
const length1: number = (this.instance.handshakeLength.getValue(0, (nodePath: string): void => this.recordError(nodePath, 'Not found')))
|
|
280
|
+
const length2: string = length1.toString(16).padStart(6, '0')
|
|
281
|
+
const length3: Buffer = HexToBuffer(length2)
|
|
282
|
+
this.writeBytes(6, length3)
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
messagedata: {
|
|
286
|
+
type: 'string',
|
|
287
|
+
label: 'Messagedata',
|
|
288
|
+
decode: (): void => {
|
|
289
|
+
const length: number = (this.instance.handshakeLength.getValue(0, (nodePath: string): void => this.recordError(nodePath, 'Not found')))
|
|
290
|
+
this.instance.messagedata.setValue(BufferToHex(this.readBytes(9, length)))
|
|
291
|
+
},
|
|
292
|
+
encode: (): void => {
|
|
293
|
+
const message: Buffer = HexToBuffer(this.instance.messagedata.getValue('0', (nodePath: string): void => this.recordError(nodePath, 'Not found')))
|
|
294
|
+
this.writeBytes(9, message)
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
public id: string = 'tls-handshake'
|
|
302
|
+
public name: string = 'Transport Layer Security(Handshake Protocol)'
|
|
303
|
+
public nickname: string = 'TLS'
|
|
304
|
+
|
|
305
|
+
public match(): boolean {
|
|
306
|
+
if (!this.prevCodecModule) return false
|
|
307
|
+
if (BufferToHex(this.readBytes(0, 1)) != '16') return false
|
|
308
|
+
const version: number = BufferToUInt16(this.readBytes(1, 2))
|
|
309
|
+
const validVersions: number[] = [768, 769, 770, 771, 772]
|
|
310
|
+
return validVersions.includes(version)
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import {ProtocolJSONSchema} from '../../schema/ProtocolJSONSchema'
|
|
2
|
+
import {BaseHeader} from '../abstracts/BaseHeader'
|
|
3
|
+
import {BufferToUInt8, BufferToUInt16} from '../../helper/BufferToNumber'
|
|
4
|
+
import {HexToBuffer} from '../../helper/HexToBuffer'
|
|
5
|
+
import {BufferToHex} from '../../helper/BufferToHex'
|
|
6
|
+
import {UInt8ToBuffer, UInt16ToBuffer} from '../../helper/NumberToBuffer'
|
|
7
|
+
|
|
8
|
+
enum TLSver {
|
|
9
|
+
SSL_3_0 = 'SSL3.0',
|
|
10
|
+
TLS_1_0 = 'TLS1.0',
|
|
11
|
+
TLS_1_1 = 'TLS1.1',
|
|
12
|
+
TLS_1_2 = 'TLS1.2',
|
|
13
|
+
TLS_1_3 = 'TLS1.3',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class TLS_Heartbeat extends BaseHeader {
|
|
17
|
+
public SCHEMA: ProtocolJSONSchema = {
|
|
18
|
+
type: 'object',
|
|
19
|
+
properties: {
|
|
20
|
+
contentType: {
|
|
21
|
+
type: 'integer',
|
|
22
|
+
label: 'Content Type',
|
|
23
|
+
minimum: 0,
|
|
24
|
+
maximum: 255,
|
|
25
|
+
decode: (): void => {
|
|
26
|
+
this.instance.contentType.setValue(BufferToUInt8(this.readBytes(0, 1)))
|
|
27
|
+
},
|
|
28
|
+
encode: (): void => {
|
|
29
|
+
const contentType: number = this.instance.contentType.getValue(0, (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
|
|
30
|
+
this.writeBytes(0, UInt8ToBuffer(contentType))
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
version: {
|
|
34
|
+
type: 'string',
|
|
35
|
+
label: 'Version',
|
|
36
|
+
minimum: 0,
|
|
37
|
+
maximum: 65535,
|
|
38
|
+
decode: (): void => {
|
|
39
|
+
const version: number = BufferToUInt16(this.readBytes(1, 2))
|
|
40
|
+
switch (version) {
|
|
41
|
+
case 768: {
|
|
42
|
+
this.instance.version.setValue(TLSver.SSL_3_0)
|
|
43
|
+
}
|
|
44
|
+
break
|
|
45
|
+
case 769: {
|
|
46
|
+
this.instance.version.setValue(TLSver.TLS_1_0)
|
|
47
|
+
}
|
|
48
|
+
break
|
|
49
|
+
case 770: {
|
|
50
|
+
this.instance.version.setValue(TLSver.TLS_1_1)
|
|
51
|
+
}
|
|
52
|
+
break
|
|
53
|
+
case 771: {
|
|
54
|
+
this.instance.version.setValue(TLSver.TLS_1_2)
|
|
55
|
+
}
|
|
56
|
+
break
|
|
57
|
+
case 772: {
|
|
58
|
+
this.instance.version.setValue(TLSver.TLS_1_3)
|
|
59
|
+
}
|
|
60
|
+
break
|
|
61
|
+
default: {
|
|
62
|
+
this.instance.version.setValue(0)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
encode: (): void => {
|
|
67
|
+
const version: string = this.instance.version.getValue('0', (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
|
|
68
|
+
switch (version) {
|
|
69
|
+
case TLSver.SSL_3_0: {
|
|
70
|
+
this.writeBytes(1, UInt16ToBuffer(768))
|
|
71
|
+
}
|
|
72
|
+
break
|
|
73
|
+
case TLSver.TLS_1_0: {
|
|
74
|
+
this.writeBytes(1, UInt16ToBuffer(769))
|
|
75
|
+
}
|
|
76
|
+
break
|
|
77
|
+
case TLSver.TLS_1_1: {
|
|
78
|
+
this.writeBytes(1, UInt16ToBuffer(770))
|
|
79
|
+
}
|
|
80
|
+
break
|
|
81
|
+
case TLSver.TLS_1_2: {
|
|
82
|
+
this.writeBytes(1, UInt16ToBuffer(771))
|
|
83
|
+
}
|
|
84
|
+
break
|
|
85
|
+
case TLSver.TLS_1_3: {
|
|
86
|
+
this.writeBytes(1, UInt16ToBuffer(772))
|
|
87
|
+
}
|
|
88
|
+
break
|
|
89
|
+
default: {
|
|
90
|
+
this.writeBytes(1, UInt16ToBuffer(0))
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
length: {
|
|
96
|
+
type: 'integer',
|
|
97
|
+
label: 'Length',
|
|
98
|
+
minimum: 0,
|
|
99
|
+
maximum: 65535,
|
|
100
|
+
decode: (): void => {
|
|
101
|
+
this.instance.length.setValue(BufferToUInt16(this.readBytes(3, 2)))
|
|
102
|
+
},
|
|
103
|
+
encode: (): void => {
|
|
104
|
+
const length: number = this.instance.length.getValue(0, (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
|
|
105
|
+
this.writeBytes(3, UInt16ToBuffer(length))
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
heartbeatType: {
|
|
109
|
+
type: 'string',
|
|
110
|
+
label: 'Heartbeat Type',
|
|
111
|
+
minimum: 0,
|
|
112
|
+
maximum: 255,
|
|
113
|
+
decode: (): void => {
|
|
114
|
+
const heartbeatType: number = BufferToUInt8(this.readBytes(5, 1))
|
|
115
|
+
switch (heartbeatType) {
|
|
116
|
+
case 1: {
|
|
117
|
+
this.instance.heartbeatType.setValue('HeartbeatRequest')
|
|
118
|
+
}
|
|
119
|
+
break
|
|
120
|
+
case 2: {
|
|
121
|
+
this.instance.heartbeatType.setValue('HeartbeatResponse')
|
|
122
|
+
}
|
|
123
|
+
break
|
|
124
|
+
default: {
|
|
125
|
+
this.instance.heartbeatType.setValue(heartbeatType)
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
encode: (): void => {
|
|
130
|
+
const heartbeatType: string = this.instance.heartbeatType.getValue('0', (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
|
|
131
|
+
switch (heartbeatType) {
|
|
132
|
+
case 'HeartbeatRequest': {
|
|
133
|
+
this.writeBytes(5, UInt8ToBuffer(1))
|
|
134
|
+
}
|
|
135
|
+
break
|
|
136
|
+
case 'HeartbeatResponse': {
|
|
137
|
+
this.writeBytes(5, UInt8ToBuffer(2))
|
|
138
|
+
}
|
|
139
|
+
break
|
|
140
|
+
default: {
|
|
141
|
+
const heartbeatType1: number = parseInt(heartbeatType)
|
|
142
|
+
this.writeBytes(5, UInt8ToBuffer(heartbeatType1))
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
payloadLength: {
|
|
148
|
+
type: 'integer',
|
|
149
|
+
label: 'Payload Length',
|
|
150
|
+
minimum: 0,
|
|
151
|
+
maximum: 65535,
|
|
152
|
+
decode: (): void => {
|
|
153
|
+
this.instance.payloadLength.setValue(BufferToUInt16(this.readBytes(6, 2)))
|
|
154
|
+
},
|
|
155
|
+
encode: (): void => {
|
|
156
|
+
const payloadLength: number = this.instance.payloadLength.getValue(0, (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
|
|
157
|
+
this.writeBytes(6, UInt16ToBuffer(payloadLength))
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
payloadMessage: {
|
|
161
|
+
type: 'string',
|
|
162
|
+
label: 'Payload Message',
|
|
163
|
+
decode: (): void => {
|
|
164
|
+
const payloadLength: number = this.instance.payloadLength.getValue(0, (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
|
|
165
|
+
const payloadMessage: string = BufferToHex(this.readBytes(8, payloadLength))
|
|
166
|
+
this.instance.payloadMessage.setValue(payloadMessage)
|
|
167
|
+
},
|
|
168
|
+
encode: (): void => {
|
|
169
|
+
const payloadMessage: string = this.instance.payloadMessage.getValue('0', (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
|
|
170
|
+
this.writeBytes(8, HexToBuffer(payloadMessage))
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
public id: string = 'tls-heartbeat'
|
|
178
|
+
public name: string = 'Transport Layer Security(Heartbeat Protocol)'
|
|
179
|
+
public nickname: string = 'TLS'
|
|
180
|
+
|
|
181
|
+
public match(): boolean {
|
|
182
|
+
if (!this.prevCodecModule) return false
|
|
183
|
+
if (BufferToHex(this.readBytes(0, 1)) != '18') return false
|
|
184
|
+
const version: number = BufferToUInt16(this.readBytes(1, 2))
|
|
185
|
+
const validVersions: number[] = [768, 769, 770, 771, 772]
|
|
186
|
+
return validVersions.includes(version)
|
|
187
|
+
}
|
|
188
|
+
}
|
|
@@ -53,7 +53,7 @@ export class VLAN_802dot1Q extends BaseHeader {
|
|
|
53
53
|
this.instance.etherType.setValue(BufferToHex(this.readBytes(2, 2)))
|
|
54
54
|
},
|
|
55
55
|
encode: (): void => {
|
|
56
|
-
|
|
56
|
+
const etherType: string = this.instance.etherType.getValue(UInt16ToHex(0x0000), (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
|
|
57
57
|
const typeBuffer: Buffer = Buffer.from(etherType, 'hex')
|
|
58
58
|
if (typeBuffer.length < 2) typeBuffer.fill(0, 0, 1)
|
|
59
59
|
this.writeBytes(2, typeBuffer.subarray(0, 2))
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import BigNumber from 'bignumber.js'
|
|
6
6
|
|
|
7
7
|
export type GeneratePCAPInputPacket = {
|
|
8
|
-
timestamp: number
|
|
9
8
|
frameBase64Data: string
|
|
9
|
+
timestamp?: number
|
|
10
10
|
microsecond?: {
|
|
11
11
|
seconds: number
|
|
12
12
|
microseconds: number
|
|
@@ -15,7 +15,7 @@ export type GeneratePCAPInputPacket = {
|
|
|
15
15
|
|
|
16
16
|
export type GeneratePCAPPacket = {
|
|
17
17
|
buffer: Buffer,
|
|
18
|
-
timestamp
|
|
18
|
+
timestamp?: number,
|
|
19
19
|
microsecond?: {
|
|
20
20
|
seconds: number
|
|
21
21
|
microseconds: number
|
|
@@ -90,7 +90,12 @@ export function GeneratePCAPData(packet: GeneratePCAPPacket): Buffer {
|
|
|
90
90
|
seconds = packet.microsecond.seconds
|
|
91
91
|
microseconds = packet.microsecond.microseconds
|
|
92
92
|
} else {
|
|
93
|
-
|
|
93
|
+
if (packet.timestamp) {
|
|
94
|
+
[seconds, microseconds] = convertMillisecond2Microsecond(packet.timestamp)
|
|
95
|
+
} else {
|
|
96
|
+
seconds = 0
|
|
97
|
+
microseconds = 0
|
|
98
|
+
}
|
|
94
99
|
}
|
|
95
100
|
packetHeader.writeUInt32BE(seconds, 0) // 4
|
|
96
101
|
if (packet.microsecond) {
|