@netkitty/codec 1.0.0

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.
Files changed (463) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE +21 -0
  3. package/README.md +352 -0
  4. package/README.zh-CN.md +342 -0
  5. package/dist/Codec.d.ts +133 -0
  6. package/dist/Codec.js +632 -0
  7. package/dist/PacketHeaders.d.ts +189 -0
  8. package/dist/PacketHeaders.js +384 -0
  9. package/dist/abstracts/BaseHeader.d.ts +325 -0
  10. package/dist/abstracts/BaseHeader.js +734 -0
  11. package/dist/errors/CodecSchemaValidateError.d.ts +4 -0
  12. package/dist/errors/CodecSchemaValidateError.js +11 -0
  13. package/dist/headers/ADSAMS.d.ts +33 -0
  14. package/dist/headers/ADSAMS.js +208 -0
  15. package/dist/headers/AH.d.ts +28 -0
  16. package/dist/headers/AH.js +137 -0
  17. package/dist/headers/AMQP.d.ts +31 -0
  18. package/dist/headers/AMQP.js +316 -0
  19. package/dist/headers/ARP.d.ts +26 -0
  20. package/dist/headers/ARP.js +243 -0
  21. package/dist/headers/BACnetIP.d.ts +27 -0
  22. package/dist/headers/BACnetIP.js +97 -0
  23. package/dist/headers/BFD.d.ts +28 -0
  24. package/dist/headers/BFD.js +155 -0
  25. package/dist/headers/BGP.d.ts +27 -0
  26. package/dist/headers/BGP.js +111 -0
  27. package/dist/headers/BSAPIP.d.ts +33 -0
  28. package/dist/headers/BSAPIP.js +78 -0
  29. package/dist/headers/Babel.d.ts +32 -0
  30. package/dist/headers/Babel.js +224 -0
  31. package/dist/headers/BitTorrent.d.ts +28 -0
  32. package/dist/headers/BitTorrent.js +72 -0
  33. package/dist/headers/C37118.d.ts +26 -0
  34. package/dist/headers/C37118.js +147 -0
  35. package/dist/headers/CAPWAP.d.ts +38 -0
  36. package/dist/headers/CAPWAP.js +275 -0
  37. package/dist/headers/CDP.d.ts +25 -0
  38. package/dist/headers/CDP.js +117 -0
  39. package/dist/headers/CMS.d.ts +33 -0
  40. package/dist/headers/CMS.js +238 -0
  41. package/dist/headers/COTP.d.ts +30 -0
  42. package/dist/headers/COTP.js +193 -0
  43. package/dist/headers/CassandraCQL.d.ts +28 -0
  44. package/dist/headers/CassandraCQL.js +117 -0
  45. package/dist/headers/CoAP.d.ts +29 -0
  46. package/dist/headers/CoAP.js +140 -0
  47. package/dist/headers/Codesys.d.ts +32 -0
  48. package/dist/headers/Codesys.js +119 -0
  49. package/dist/headers/Collectd.d.ts +29 -0
  50. package/dist/headers/Collectd.js +154 -0
  51. package/dist/headers/DCCP.d.ts +30 -0
  52. package/dist/headers/DCCP.js +204 -0
  53. package/dist/headers/DHCP.d.ts +26 -0
  54. package/dist/headers/DHCP.js +148 -0
  55. package/dist/headers/DHCPFailover.d.ts +30 -0
  56. package/dist/headers/DHCPFailover.js +104 -0
  57. package/dist/headers/DHCPv6.d.ts +25 -0
  58. package/dist/headers/DHCPv6.js +145 -0
  59. package/dist/headers/DNP3.d.ts +27 -0
  60. package/dist/headers/DNP3.js +150 -0
  61. package/dist/headers/DNS.d.ts +55 -0
  62. package/dist/headers/DNS.js +309 -0
  63. package/dist/headers/DTLS.d.ts +33 -0
  64. package/dist/headers/DTLS.js +142 -0
  65. package/dist/headers/Diameter.d.ts +34 -0
  66. package/dist/headers/Diameter.js +229 -0
  67. package/dist/headers/EAPOL.d.ts +32 -0
  68. package/dist/headers/EAPOL.js +135 -0
  69. package/dist/headers/EIGRP.d.ts +28 -0
  70. package/dist/headers/EIGRP.js +165 -0
  71. package/dist/headers/ENIP.d.ts +31 -0
  72. package/dist/headers/ENIP.js +164 -0
  73. package/dist/headers/ESP.d.ts +27 -0
  74. package/dist/headers/ESP.js +140 -0
  75. package/dist/headers/Elasticsearch.d.ts +30 -0
  76. package/dist/headers/Elasticsearch.js +125 -0
  77. package/dist/headers/EtherCAT.d.ts +35 -0
  78. package/dist/headers/EtherCAT.js +150 -0
  79. package/dist/headers/EthernetII.d.ts +28 -0
  80. package/dist/headers/EthernetII.js +117 -0
  81. package/dist/headers/FCoE.d.ts +38 -0
  82. package/dist/headers/FCoE.js +210 -0
  83. package/dist/headers/FTP.d.ts +34 -0
  84. package/dist/headers/FTP.js +158 -0
  85. package/dist/headers/Finger.d.ts +41 -0
  86. package/dist/headers/Finger.js +135 -0
  87. package/dist/headers/FoundationFieldbusHSE.d.ts +43 -0
  88. package/dist/headers/FoundationFieldbusHSE.js +163 -0
  89. package/dist/headers/GELF.d.ts +35 -0
  90. package/dist/headers/GELF.js +261 -0
  91. package/dist/headers/GENEVE.d.ts +26 -0
  92. package/dist/headers/GENEVE.js +209 -0
  93. package/dist/headers/GESRTP.d.ts +32 -0
  94. package/dist/headers/GESRTP.js +141 -0
  95. package/dist/headers/GLBP.d.ts +29 -0
  96. package/dist/headers/GLBP.js +159 -0
  97. package/dist/headers/GRE.d.ts +27 -0
  98. package/dist/headers/GRE.js +181 -0
  99. package/dist/headers/GTPU.d.ts +25 -0
  100. package/dist/headers/GTPU.js +203 -0
  101. package/dist/headers/GTPv2C.d.ts +30 -0
  102. package/dist/headers/GTPv2C.js +281 -0
  103. package/dist/headers/GitProtocol.d.ts +34 -0
  104. package/dist/headers/GitProtocol.js +141 -0
  105. package/dist/headers/Goose.d.ts +115 -0
  106. package/dist/headers/Goose.js +1067 -0
  107. package/dist/headers/Gopher.d.ts +43 -0
  108. package/dist/headers/Gopher.js +182 -0
  109. package/dist/headers/HARTIP.d.ts +30 -0
  110. package/dist/headers/HARTIP.js +145 -0
  111. package/dist/headers/HSR.d.ts +27 -0
  112. package/dist/headers/HSR.js +105 -0
  113. package/dist/headers/HSRP.d.ts +26 -0
  114. package/dist/headers/HSRP.js +173 -0
  115. package/dist/headers/HTTP.d.ts +32 -0
  116. package/dist/headers/HTTP.js +153 -0
  117. package/dist/headers/HTTP2.d.ts +34 -0
  118. package/dist/headers/HTTP2.js +190 -0
  119. package/dist/headers/IAX2.d.ts +33 -0
  120. package/dist/headers/IAX2.js +274 -0
  121. package/dist/headers/ICMP.d.ts +15 -0
  122. package/dist/headers/ICMP.js +148 -0
  123. package/dist/headers/ICMPv6.d.ts +15 -0
  124. package/dist/headers/ICMPv6.js +129 -0
  125. package/dist/headers/IEC104_I_Frame.d.ts +23 -0
  126. package/dist/headers/IEC104_I_Frame.js +6489 -0
  127. package/dist/headers/IEC104_S_Frame.d.ts +26 -0
  128. package/dist/headers/IEC104_S_Frame.js +135 -0
  129. package/dist/headers/IEC104_U_Frame.d.ts +27 -0
  130. package/dist/headers/IEC104_U_Frame.js +176 -0
  131. package/dist/headers/IEC61850SampledValues.d.ts +20 -0
  132. package/dist/headers/IEC61850SampledValues.js +420 -0
  133. package/dist/headers/IGMP.d.ts +31 -0
  134. package/dist/headers/IGMP.js +274 -0
  135. package/dist/headers/IMAP.d.ts +32 -0
  136. package/dist/headers/IMAP.js +185 -0
  137. package/dist/headers/IPFIX.d.ts +29 -0
  138. package/dist/headers/IPFIX.js +156 -0
  139. package/dist/headers/IPv4.d.ts +20 -0
  140. package/dist/headers/IPv4.js +370 -0
  141. package/dist/headers/IPv6.d.ts +29 -0
  142. package/dist/headers/IPv6.js +209 -0
  143. package/dist/headers/IPv6HopByHopOptions.d.ts +81 -0
  144. package/dist/headers/IPv6HopByHopOptions.js +495 -0
  145. package/dist/headers/IRC.d.ts +34 -0
  146. package/dist/headers/IRC.js +175 -0
  147. package/dist/headers/ISAKMP.d.ts +29 -0
  148. package/dist/headers/ISAKMP.js +197 -0
  149. package/dist/headers/ISCSI.d.ts +39 -0
  150. package/dist/headers/ISCSI.js +289 -0
  151. package/dist/headers/ISIS.d.ts +25 -0
  152. package/dist/headers/ISIS.js +79 -0
  153. package/dist/headers/ISOSession.d.ts +27 -0
  154. package/dist/headers/ISOSession.js +343 -0
  155. package/dist/headers/Ident.d.ts +42 -0
  156. package/dist/headers/Ident.js +184 -0
  157. package/dist/headers/KNXnetIP.d.ts +30 -0
  158. package/dist/headers/KNXnetIP.js +135 -0
  159. package/dist/headers/Kafka.d.ts +35 -0
  160. package/dist/headers/Kafka.js +128 -0
  161. package/dist/headers/Kerberos.d.ts +30 -0
  162. package/dist/headers/Kerberos.js +217 -0
  163. package/dist/headers/L2TP.d.ts +26 -0
  164. package/dist/headers/L2TP.js +297 -0
  165. package/dist/headers/LACP.d.ts +31 -0
  166. package/dist/headers/LACP.js +151 -0
  167. package/dist/headers/LDAP.d.ts +31 -0
  168. package/dist/headers/LDAP.js +226 -0
  169. package/dist/headers/LDP.d.ts +31 -0
  170. package/dist/headers/LDP.js +138 -0
  171. package/dist/headers/LISP.d.ts +30 -0
  172. package/dist/headers/LISP.js +103 -0
  173. package/dist/headers/LLC.d.ts +27 -0
  174. package/dist/headers/LLC.js +81 -0
  175. package/dist/headers/LLDP.d.ts +26 -0
  176. package/dist/headers/LLDP.js +126 -0
  177. package/dist/headers/LLMNR.d.ts +23 -0
  178. package/dist/headers/LLMNR.js +40 -0
  179. package/dist/headers/LPD.d.ts +31 -0
  180. package/dist/headers/LPD.js +159 -0
  181. package/dist/headers/MACsec.d.ts +34 -0
  182. package/dist/headers/MACsec.js +178 -0
  183. package/dist/headers/MDNS.d.ts +26 -0
  184. package/dist/headers/MDNS.js +45 -0
  185. package/dist/headers/MGCP.d.ts +30 -0
  186. package/dist/headers/MGCP.js +155 -0
  187. package/dist/headers/MMS.d.ts +29 -0
  188. package/dist/headers/MMS.js +243 -0
  189. package/dist/headers/MPLS.d.ts +31 -0
  190. package/dist/headers/MPLS.js +145 -0
  191. package/dist/headers/MQTT.d.ts +30 -0
  192. package/dist/headers/MQTT.js +173 -0
  193. package/dist/headers/MQTTSN.d.ts +34 -0
  194. package/dist/headers/MQTTSN.js +177 -0
  195. package/dist/headers/MarkerProtocol.d.ts +32 -0
  196. package/dist/headers/MarkerProtocol.js +153 -0
  197. package/dist/headers/Megaco.d.ts +32 -0
  198. package/dist/headers/Megaco.js +144 -0
  199. package/dist/headers/Memcached.d.ts +44 -0
  200. package/dist/headers/Memcached.js +285 -0
  201. package/dist/headers/ModbusTCP.d.ts +25 -0
  202. package/dist/headers/ModbusTCP.js +99 -0
  203. package/dist/headers/ModbusUDP.d.ts +26 -0
  204. package/dist/headers/ModbusUDP.js +100 -0
  205. package/dist/headers/MongoDB.d.ts +33 -0
  206. package/dist/headers/MongoDB.js +143 -0
  207. package/dist/headers/MySQL.d.ts +30 -0
  208. package/dist/headers/MySQL.js +114 -0
  209. package/dist/headers/NATS.d.ts +29 -0
  210. package/dist/headers/NATS.js +135 -0
  211. package/dist/headers/NBDS.d.ts +34 -0
  212. package/dist/headers/NBDS.js +176 -0
  213. package/dist/headers/NBNS.d.ts +34 -0
  214. package/dist/headers/NBNS.js +78 -0
  215. package/dist/headers/NBSS.d.ts +36 -0
  216. package/dist/headers/NBSS.js +137 -0
  217. package/dist/headers/NFS.d.ts +36 -0
  218. package/dist/headers/NFS.js +273 -0
  219. package/dist/headers/NHRP.d.ts +32 -0
  220. package/dist/headers/NHRP.js +154 -0
  221. package/dist/headers/NNTP.d.ts +35 -0
  222. package/dist/headers/NNTP.js +162 -0
  223. package/dist/headers/NTP.d.ts +18 -0
  224. package/dist/headers/NTP.js +73 -0
  225. package/dist/headers/NetFlowV5.d.ts +28 -0
  226. package/dist/headers/NetFlowV5.js +205 -0
  227. package/dist/headers/OLSR.d.ts +31 -0
  228. package/dist/headers/OLSR.js +213 -0
  229. package/dist/headers/OPCUA.d.ts +33 -0
  230. package/dist/headers/OPCUA.js +165 -0
  231. package/dist/headers/OPCUAPubSub.d.ts +33 -0
  232. package/dist/headers/OPCUAPubSub.js +144 -0
  233. package/dist/headers/OSPF.d.ts +31 -0
  234. package/dist/headers/OSPF.js +365 -0
  235. package/dist/headers/OmronFINS.d.ts +31 -0
  236. package/dist/headers/OmronFINS.js +90 -0
  237. package/dist/headers/OpenFlow.d.ts +30 -0
  238. package/dist/headers/OpenFlow.js +113 -0
  239. package/dist/headers/OpenVPN.d.ts +35 -0
  240. package/dist/headers/OpenVPN.js +214 -0
  241. package/dist/headers/PCWorx.d.ts +35 -0
  242. package/dist/headers/PCWorx.js +115 -0
  243. package/dist/headers/PIM.d.ts +27 -0
  244. package/dist/headers/PIM.js +129 -0
  245. package/dist/headers/POP3.d.ts +31 -0
  246. package/dist/headers/POP3.js +152 -0
  247. package/dist/headers/POWERLINK.d.ts +28 -0
  248. package/dist/headers/POWERLINK.js +116 -0
  249. package/dist/headers/PPPoEDiscovery.d.ts +29 -0
  250. package/dist/headers/PPPoEDiscovery.js +198 -0
  251. package/dist/headers/PPPoESession.d.ts +28 -0
  252. package/dist/headers/PPPoESession.js +125 -0
  253. package/dist/headers/PPTP.d.ts +30 -0
  254. package/dist/headers/PPTP.js +122 -0
  255. package/dist/headers/PROFINETRT.d.ts +28 -0
  256. package/dist/headers/PROFINETRT.js +74 -0
  257. package/dist/headers/PTP.d.ts +34 -0
  258. package/dist/headers/PTP.js +213 -0
  259. package/dist/headers/PostgreSQL.d.ts +40 -0
  260. package/dist/headers/PostgreSQL.js +236 -0
  261. package/dist/headers/QUIC.d.ts +34 -0
  262. package/dist/headers/QUIC.js +308 -0
  263. package/dist/headers/RADIUS.d.ts +24 -0
  264. package/dist/headers/RADIUS.js +138 -0
  265. package/dist/headers/RDP.d.ts +27 -0
  266. package/dist/headers/RDP.js +93 -0
  267. package/dist/headers/RFB.d.ts +39 -0
  268. package/dist/headers/RFB.js +151 -0
  269. package/dist/headers/RGoose.d.ts +72 -0
  270. package/dist/headers/RGoose.js +340 -0
  271. package/dist/headers/RIP.d.ts +29 -0
  272. package/dist/headers/RIP.js +133 -0
  273. package/dist/headers/RIPng.d.ts +26 -0
  274. package/dist/headers/RIPng.js +140 -0
  275. package/dist/headers/RMCP.d.ts +26 -0
  276. package/dist/headers/RMCP.js +155 -0
  277. package/dist/headers/RSVP.d.ts +31 -0
  278. package/dist/headers/RSVP.js +263 -0
  279. package/dist/headers/RTCP.d.ts +34 -0
  280. package/dist/headers/RTCP.js +217 -0
  281. package/dist/headers/RTP.d.ts +33 -0
  282. package/dist/headers/RTP.js +291 -0
  283. package/dist/headers/RTPS.d.ts +33 -0
  284. package/dist/headers/RTPS.js +182 -0
  285. package/dist/headers/RTSP.d.ts +36 -0
  286. package/dist/headers/RTSP.js +184 -0
  287. package/dist/headers/RawData.d.ts +17 -0
  288. package/dist/headers/RawData.js +43 -0
  289. package/dist/headers/Redis.d.ts +32 -0
  290. package/dist/headers/Redis.js +202 -0
  291. package/dist/headers/Rlogin.d.ts +42 -0
  292. package/dist/headers/Rlogin.js +139 -0
  293. package/dist/headers/Rsync.d.ts +28 -0
  294. package/dist/headers/Rsync.js +117 -0
  295. package/dist/headers/S7comm.d.ts +36 -0
  296. package/dist/headers/S7comm.js +244 -0
  297. package/dist/headers/SCTP.d.ts +35 -0
  298. package/dist/headers/SCTP.js +174 -0
  299. package/dist/headers/SFlow.d.ts +29 -0
  300. package/dist/headers/SFlow.js +242 -0
  301. package/dist/headers/SIP.d.ts +27 -0
  302. package/dist/headers/SIP.js +146 -0
  303. package/dist/headers/SLMP.d.ts +36 -0
  304. package/dist/headers/SLMP.js +154 -0
  305. package/dist/headers/SLP.d.ts +30 -0
  306. package/dist/headers/SLP.js +207 -0
  307. package/dist/headers/SLPv1.d.ts +32 -0
  308. package/dist/headers/SLPv1.js +138 -0
  309. package/dist/headers/SMB1.d.ts +37 -0
  310. package/dist/headers/SMB1.js +200 -0
  311. package/dist/headers/SMB2.d.ts +36 -0
  312. package/dist/headers/SMB2.js +203 -0
  313. package/dist/headers/SMPP.d.ts +33 -0
  314. package/dist/headers/SMPP.js +119 -0
  315. package/dist/headers/SMTP.d.ts +33 -0
  316. package/dist/headers/SMTP.js +157 -0
  317. package/dist/headers/SNAP.d.ts +22 -0
  318. package/dist/headers/SNAP.js +68 -0
  319. package/dist/headers/SNMP.d.ts +28 -0
  320. package/dist/headers/SNMP.js +302 -0
  321. package/dist/headers/SOCKS4.d.ts +42 -0
  322. package/dist/headers/SOCKS4.js +302 -0
  323. package/dist/headers/SOCKS5.d.ts +45 -0
  324. package/dist/headers/SOCKS5.js +223 -0
  325. package/dist/headers/SSDP.d.ts +27 -0
  326. package/dist/headers/SSDP.js +161 -0
  327. package/dist/headers/SSH.d.ts +44 -0
  328. package/dist/headers/SSH.js +274 -0
  329. package/dist/headers/STOMP.d.ts +48 -0
  330. package/dist/headers/STOMP.js +177 -0
  331. package/dist/headers/STP.d.ts +26 -0
  332. package/dist/headers/STP.js +150 -0
  333. package/dist/headers/STUN.d.ts +25 -0
  334. package/dist/headers/STUN.js +183 -0
  335. package/dist/headers/SercosIII.d.ts +43 -0
  336. package/dist/headers/SercosIII.js +199 -0
  337. package/dist/headers/Skinny.d.ts +32 -0
  338. package/dist/headers/Skinny.js +139 -0
  339. package/dist/headers/StatsD.d.ts +27 -0
  340. package/dist/headers/StatsD.js +134 -0
  341. package/dist/headers/SunRPC.d.ts +34 -0
  342. package/dist/headers/SunRPC.js +268 -0
  343. package/dist/headers/Syslog.d.ts +21 -0
  344. package/dist/headers/Syslog.js +91 -0
  345. package/dist/headers/TCP.d.ts +19 -0
  346. package/dist/headers/TCP.js +905 -0
  347. package/dist/headers/TFTP.d.ts +28 -0
  348. package/dist/headers/TFTP.js +224 -0
  349. package/dist/headers/TLS_Alert.d.ts +24 -0
  350. package/dist/headers/TLS_Alert.js +639 -0
  351. package/dist/headers/TLS_ApplicationData.d.ts +24 -0
  352. package/dist/headers/TLS_ApplicationData.js +170 -0
  353. package/dist/headers/TLS_ChangeCipherSpec.d.ts +23 -0
  354. package/dist/headers/TLS_ChangeCipherSpec.js +168 -0
  355. package/dist/headers/TLS_Handshake.d.ts +65 -0
  356. package/dist/headers/TLS_Handshake.js +860 -0
  357. package/dist/headers/TLS_Heartbeat.d.ts +27 -0
  358. package/dist/headers/TLS_Heartbeat.js +247 -0
  359. package/dist/headers/TPKT.d.ts +26 -0
  360. package/dist/headers/TPKT.js +99 -0
  361. package/dist/headers/TacacsPlus.d.ts +27 -0
  362. package/dist/headers/TacacsPlus.js +133 -0
  363. package/dist/headers/Telnet.d.ts +40 -0
  364. package/dist/headers/Telnet.js +193 -0
  365. package/dist/headers/Teredo.d.ts +40 -0
  366. package/dist/headers/Teredo.js +251 -0
  367. package/dist/headers/TimeProtocol.d.ts +25 -0
  368. package/dist/headers/TimeProtocol.js +53 -0
  369. package/dist/headers/UDP.d.ts +19 -0
  370. package/dist/headers/UDP.js +171 -0
  371. package/dist/headers/VLAN_802dot1Q.d.ts +24 -0
  372. package/dist/headers/VLAN_802dot1Q.js +96 -0
  373. package/dist/headers/VRRP.d.ts +26 -0
  374. package/dist/headers/VRRP.js +309 -0
  375. package/dist/headers/VXLAN.d.ts +24 -0
  376. package/dist/headers/VXLAN.js +75 -0
  377. package/dist/headers/WCCP.d.ts +29 -0
  378. package/dist/headers/WCCP.js +117 -0
  379. package/dist/headers/WHOIS.d.ts +37 -0
  380. package/dist/headers/WHOIS.js +126 -0
  381. package/dist/headers/WSDiscovery.d.ts +29 -0
  382. package/dist/headers/WSDiscovery.js +118 -0
  383. package/dist/headers/WakeOnLAN.d.ts +30 -0
  384. package/dist/headers/WakeOnLAN.js +126 -0
  385. package/dist/headers/WebSocket.d.ts +26 -0
  386. package/dist/headers/WebSocket.js +173 -0
  387. package/dist/headers/WireGuard.d.ts +38 -0
  388. package/dist/headers/WireGuard.js +216 -0
  389. package/dist/headers/XMPP.d.ts +37 -0
  390. package/dist/headers/XMPP.js +149 -0
  391. package/dist/headers/Zabbix.d.ts +35 -0
  392. package/dist/headers/Zabbix.js +153 -0
  393. package/dist/headers/cms/AcsiPdu.d.ts +45 -0
  394. package/dist/headers/cms/AcsiPdu.js +112 -0
  395. package/dist/headers/cms/PerDecoder.d.ts +68 -0
  396. package/dist/headers/cms/PerDecoder.js +211 -0
  397. package/dist/headers/cms/PerReader.d.ts +64 -0
  398. package/dist/headers/cms/PerReader.js +155 -0
  399. package/dist/helper/BufferToHex.d.ts +5 -0
  400. package/dist/helper/BufferToHex.js +10 -0
  401. package/dist/helper/BufferToIP.d.ts +12 -0
  402. package/dist/helper/BufferToIP.js +23 -0
  403. package/dist/helper/BufferToNumber.d.ts +18 -0
  404. package/dist/helper/BufferToNumber.js +47 -0
  405. package/dist/helper/HexToBuffer.d.ts +7 -0
  406. package/dist/helper/HexToBuffer.js +27 -0
  407. package/dist/helper/HexToNumber.d.ts +18 -0
  408. package/dist/helper/HexToNumber.js +48 -0
  409. package/dist/helper/IPToBuffer.d.ts +12 -0
  410. package/dist/helper/IPToBuffer.js +34 -0
  411. package/dist/helper/NumberToBERBuffer.d.ts +18 -0
  412. package/dist/helper/NumberToBERBuffer.js +31 -0
  413. package/dist/helper/NumberToBERHex.d.ts +18 -0
  414. package/dist/helper/NumberToBERHex.js +52 -0
  415. package/dist/helper/NumberToBuffer.d.ts +18 -0
  416. package/dist/helper/NumberToBuffer.js +38 -0
  417. package/dist/helper/NumberToHex.d.ts +18 -0
  418. package/dist/helper/NumberToHex.js +35 -0
  419. package/dist/index.d.ts +52 -0
  420. package/dist/index.js +113 -0
  421. package/dist/lib/FlexibleObject.d.ts +27 -0
  422. package/dist/lib/FlexibleObject.js +113 -0
  423. package/dist/lib/GetBERIntegerLengthFromBuffer.d.ts +6 -0
  424. package/dist/lib/GetBERIntegerLengthFromBuffer.js +16 -0
  425. package/dist/lib/ProcessPacketPostHandlers.d.ts +13 -0
  426. package/dist/lib/ProcessPacketPostHandlers.js +53 -0
  427. package/dist/lib/SortPostHandlers.d.ts +7 -0
  428. package/dist/lib/SortPostHandlers.js +11 -0
  429. package/dist/lib/StringContentEncodingEnum.d.ts +10 -0
  430. package/dist/lib/StringContentEncodingEnum.js +14 -0
  431. package/dist/schema/ProtocolFieldJSONSchema.d.ts +35 -0
  432. package/dist/schema/ProtocolFieldJSONSchema.js +2 -0
  433. package/dist/schema/ProtocolFieldJSONSchemaDefinition.d.ts +2 -0
  434. package/dist/schema/ProtocolFieldJSONSchemaDefinition.js +2 -0
  435. package/dist/schema/ProtocolJSONSchema.d.ts +32 -0
  436. package/dist/schema/ProtocolJSONSchema.js +2 -0
  437. package/dist/types/CodecData.d.ts +7 -0
  438. package/dist/types/CodecData.js +2 -0
  439. package/dist/types/CodecDecodeResult.d.ts +10 -0
  440. package/dist/types/CodecDecodeResult.js +2 -0
  441. package/dist/types/CodecEncodeInput.d.ts +2 -0
  442. package/dist/types/CodecEncodeInput.js +2 -0
  443. package/dist/types/CodecEncodeResult.d.ts +5 -0
  444. package/dist/types/CodecEncodeResult.js +2 -0
  445. package/dist/types/CodecErrorInfo.d.ts +5 -0
  446. package/dist/types/CodecErrorInfo.js +2 -0
  447. package/dist/types/CodecModule.d.ts +2 -0
  448. package/dist/types/CodecModule.js +2 -0
  449. package/dist/types/CodecModuleConstructor.d.ts +2 -0
  450. package/dist/types/CodecModuleConstructor.js +2 -0
  451. package/dist/types/CodecSchema.d.ts +6 -0
  452. package/dist/types/CodecSchema.js +2 -0
  453. package/dist/types/DemuxProducer.d.ts +23 -0
  454. package/dist/types/DemuxProducer.js +2 -0
  455. package/dist/types/Dissection.d.ts +23 -0
  456. package/dist/types/Dissection.js +2 -0
  457. package/dist/types/HeaderTreeNode.d.ts +4 -0
  458. package/dist/types/HeaderTreeNode.js +2 -0
  459. package/dist/types/LayerGraph.d.ts +32 -0
  460. package/dist/types/LayerGraph.js +2 -0
  461. package/dist/types/PostHandlerItem.d.ts +4 -0
  462. package/dist/types/PostHandlerItem.js +2 -0
  463. package/package.json +141 -0
@@ -0,0 +1,27 @@
1
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
2
+ import { BaseHeader } from '../abstracts/BaseHeader';
3
+ /**
4
+ * TLS Heartbeat protocol (RFC 6520) — a TLS/SSL record carrying a heartbeat, over TCP (heuristically, port
5
+ * 443). This codec decodes the 5-octet TLS record header plus the HeartbeatMessage: an 8-bit Content Type
6
+ * (`contentType`, offset 0, = 24 / 0x18 for Heartbeat), a 16-bit legacy Version (`version`, offset 1,
7
+ * mapped to the labels SSL3.0 / TLS1.0 / TLS1.1 / TLS1.2 / TLS1.3 for 0x0300-0x0304, else 0), a 16-bit
8
+ * record Length (`length`, offset 3), then the HeartbeatMessageType (`heartbeatType`, offset 5; 1
9
+ * HeartbeatRequest, 2 HeartbeatResponse, else the numeric value), a 16-bit Payload Length (`payloadLength`,
10
+ * offset 6), the payload (`payloadMessage`, offset 8, `payloadLength` octets, kept verbatim as hex) and
11
+ * the trailing random Padding (`padding`, hex).
12
+ *
13
+ * Per RFC 6520 §4 the padding is at least 16 octets and fills the record after the type and payload, so its
14
+ * length is derived as recordLength - 3 - payloadLength and preserved for a byte-exact re-encode. The
15
+ * payload and padding are kept verbatim and lengths are honored as given, so a well-formed record
16
+ * round-trips byte-for-byte. In the heuristic chain (`heuristicFallback`), match() requires a Content Type
17
+ * of 0x18 and a recognized legacy Version (0x0300-0x0304).
18
+ */
19
+ export declare class TLS_Heartbeat extends BaseHeader {
20
+ SCHEMA: ProtocolJSONSchema;
21
+ id: string;
22
+ readonly matchKeys: string[];
23
+ readonly heuristicFallback: boolean;
24
+ name: string;
25
+ nickname: string;
26
+ match(): boolean;
27
+ }
@@ -0,0 +1,247 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TLS_Heartbeat = void 0;
4
+ const BaseHeader_1 = require("../abstracts/BaseHeader");
5
+ const BufferToNumber_1 = require("../helper/BufferToNumber");
6
+ const HexToBuffer_1 = require("../helper/HexToBuffer");
7
+ const BufferToHex_1 = require("../helper/BufferToHex");
8
+ const NumberToBuffer_1 = require("../helper/NumberToBuffer");
9
+ var TLSver;
10
+ (function (TLSver) {
11
+ TLSver["SSL_3_0"] = "SSL3.0";
12
+ TLSver["TLS_1_0"] = "TLS1.0";
13
+ TLSver["TLS_1_1"] = "TLS1.1";
14
+ TLSver["TLS_1_2"] = "TLS1.2";
15
+ TLSver["TLS_1_3"] = "TLS1.3";
16
+ })(TLSver || (TLSver = {}));
17
+ /**
18
+ * TLS Heartbeat protocol (RFC 6520) — a TLS/SSL record carrying a heartbeat, over TCP (heuristically, port
19
+ * 443). This codec decodes the 5-octet TLS record header plus the HeartbeatMessage: an 8-bit Content Type
20
+ * (`contentType`, offset 0, = 24 / 0x18 for Heartbeat), a 16-bit legacy Version (`version`, offset 1,
21
+ * mapped to the labels SSL3.0 / TLS1.0 / TLS1.1 / TLS1.2 / TLS1.3 for 0x0300-0x0304, else 0), a 16-bit
22
+ * record Length (`length`, offset 3), then the HeartbeatMessageType (`heartbeatType`, offset 5; 1
23
+ * HeartbeatRequest, 2 HeartbeatResponse, else the numeric value), a 16-bit Payload Length (`payloadLength`,
24
+ * offset 6), the payload (`payloadMessage`, offset 8, `payloadLength` octets, kept verbatim as hex) and
25
+ * the trailing random Padding (`padding`, hex).
26
+ *
27
+ * Per RFC 6520 §4 the padding is at least 16 octets and fills the record after the type and payload, so its
28
+ * length is derived as recordLength - 3 - payloadLength and preserved for a byte-exact re-encode. The
29
+ * payload and padding are kept verbatim and lengths are honored as given, so a well-formed record
30
+ * round-trips byte-for-byte. In the heuristic chain (`heuristicFallback`), match() requires a Content Type
31
+ * of 0x18 and a recognized legacy Version (0x0300-0x0304).
32
+ */
33
+ class TLS_Heartbeat extends BaseHeader_1.BaseHeader {
34
+ constructor() {
35
+ super(...arguments);
36
+ this.SCHEMA = {
37
+ type: 'object',
38
+ properties: {
39
+ contentType: {
40
+ type: 'integer',
41
+ label: 'Content Type',
42
+ minimum: 0,
43
+ maximum: 255,
44
+ decode: () => {
45
+ this.instance.contentType.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(0, 1)));
46
+ },
47
+ encode: () => {
48
+ const contentType = this.instance.contentType.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
49
+ this.writeBytes(0, (0, NumberToBuffer_1.UInt8ToBuffer)(contentType));
50
+ }
51
+ },
52
+ version: {
53
+ type: 'string',
54
+ label: 'Version',
55
+ minimum: 0,
56
+ maximum: 65535,
57
+ decode: () => {
58
+ const version = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(1, 2));
59
+ switch (version) {
60
+ case 768:
61
+ {
62
+ this.instance.version.setValue(TLSver.SSL_3_0);
63
+ }
64
+ break;
65
+ case 769:
66
+ {
67
+ this.instance.version.setValue(TLSver.TLS_1_0);
68
+ }
69
+ break;
70
+ case 770:
71
+ {
72
+ this.instance.version.setValue(TLSver.TLS_1_1);
73
+ }
74
+ break;
75
+ case 771:
76
+ {
77
+ this.instance.version.setValue(TLSver.TLS_1_2);
78
+ }
79
+ break;
80
+ case 772:
81
+ {
82
+ this.instance.version.setValue(TLSver.TLS_1_3);
83
+ }
84
+ break;
85
+ default: {
86
+ this.instance.version.setValue(0);
87
+ }
88
+ }
89
+ },
90
+ encode: () => {
91
+ const version = this.instance.version.getValue('0', (nodePath) => this.recordError(nodePath, 'Not Found'));
92
+ switch (version) {
93
+ case TLSver.SSL_3_0:
94
+ {
95
+ this.writeBytes(1, (0, NumberToBuffer_1.UInt16ToBuffer)(768));
96
+ }
97
+ break;
98
+ case TLSver.TLS_1_0:
99
+ {
100
+ this.writeBytes(1, (0, NumberToBuffer_1.UInt16ToBuffer)(769));
101
+ }
102
+ break;
103
+ case TLSver.TLS_1_1:
104
+ {
105
+ this.writeBytes(1, (0, NumberToBuffer_1.UInt16ToBuffer)(770));
106
+ }
107
+ break;
108
+ case TLSver.TLS_1_2:
109
+ {
110
+ this.writeBytes(1, (0, NumberToBuffer_1.UInt16ToBuffer)(771));
111
+ }
112
+ break;
113
+ case TLSver.TLS_1_3:
114
+ {
115
+ this.writeBytes(1, (0, NumberToBuffer_1.UInt16ToBuffer)(772));
116
+ }
117
+ break;
118
+ default: {
119
+ this.writeBytes(1, (0, NumberToBuffer_1.UInt16ToBuffer)(0));
120
+ }
121
+ }
122
+ }
123
+ },
124
+ length: {
125
+ type: 'integer',
126
+ label: 'Length',
127
+ minimum: 0,
128
+ maximum: 65535,
129
+ decode: () => {
130
+ this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(3, 2)));
131
+ },
132
+ encode: () => {
133
+ const length = this.instance.length.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
134
+ this.writeBytes(3, (0, NumberToBuffer_1.UInt16ToBuffer)(length));
135
+ }
136
+ },
137
+ heartbeatType: {
138
+ type: 'string',
139
+ label: 'Heartbeat Type',
140
+ minimum: 0,
141
+ maximum: 255,
142
+ decode: () => {
143
+ const heartbeatType = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(5, 1));
144
+ switch (heartbeatType) {
145
+ case 1:
146
+ {
147
+ this.instance.heartbeatType.setValue('HeartbeatRequest');
148
+ }
149
+ break;
150
+ case 2:
151
+ {
152
+ this.instance.heartbeatType.setValue('HeartbeatResponse');
153
+ }
154
+ break;
155
+ default: {
156
+ this.instance.heartbeatType.setValue(heartbeatType);
157
+ }
158
+ }
159
+ },
160
+ encode: () => {
161
+ const heartbeatType = this.instance.heartbeatType.getValue('0', (nodePath) => this.recordError(nodePath, 'Not Found'));
162
+ switch (heartbeatType) {
163
+ case 'HeartbeatRequest':
164
+ {
165
+ this.writeBytes(5, (0, NumberToBuffer_1.UInt8ToBuffer)(1));
166
+ }
167
+ break;
168
+ case 'HeartbeatResponse':
169
+ {
170
+ this.writeBytes(5, (0, NumberToBuffer_1.UInt8ToBuffer)(2));
171
+ }
172
+ break;
173
+ default: {
174
+ const heartbeatType1 = parseInt(heartbeatType);
175
+ this.writeBytes(5, (0, NumberToBuffer_1.UInt8ToBuffer)(heartbeatType1));
176
+ }
177
+ }
178
+ }
179
+ },
180
+ payloadLength: {
181
+ type: 'integer',
182
+ label: 'Payload Length',
183
+ minimum: 0,
184
+ maximum: 65535,
185
+ decode: () => {
186
+ this.instance.payloadLength.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(6, 2)));
187
+ },
188
+ encode: () => {
189
+ const payloadLength = this.instance.payloadLength.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
190
+ this.writeBytes(6, (0, NumberToBuffer_1.UInt16ToBuffer)(payloadLength));
191
+ }
192
+ },
193
+ payloadMessage: {
194
+ type: 'string',
195
+ label: 'Payload Message',
196
+ decode: () => {
197
+ const payloadLength = this.instance.payloadLength.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
198
+ const payloadMessage = (0, BufferToHex_1.BufferToHex)(this.readBytes(8, payloadLength));
199
+ this.instance.payloadMessage.setValue(payloadMessage);
200
+ },
201
+ encode: () => {
202
+ const payloadMessage = this.instance.payloadMessage.getValue('0', (nodePath) => this.recordError(nodePath, 'Not Found'));
203
+ this.writeBytes(8, (0, HexToBuffer_1.HexToBuffer)(payloadMessage));
204
+ }
205
+ },
206
+ padding: {
207
+ type: 'string',
208
+ contentEncoding: 'hex',
209
+ label: 'Padding',
210
+ //RFC 6520 §4: HeartbeatMessage ends with random padding of at least 16 octets.
211
+ //It fills the record after type(1)+payload_length(2)+payload, i.e.
212
+ //paddingLength = recordLength - 3 - payloadLength. Preserving it is required both
213
+ //for a faithful decode view and for a byte-exact re-encode.
214
+ decode: () => {
215
+ const recordLength = this.instance.length.getValue(0);
216
+ const payloadLength = this.instance.payloadLength.getValue(0);
217
+ const paddingLength = recordLength - 3 - payloadLength;
218
+ if (paddingLength <= 0)
219
+ return;
220
+ this.instance.padding.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(8 + payloadLength, paddingLength)));
221
+ },
222
+ encode: () => {
223
+ if (this.instance.padding.isUndefined())
224
+ return;
225
+ const payloadLength = this.instance.payloadLength.getValue(0);
226
+ this.writeBytes(8 + payloadLength, (0, HexToBuffer_1.HexToBuffer)(this.instance.padding.getValue('')));
227
+ }
228
+ }
229
+ }
230
+ };
231
+ this.id = 'tls-heartbeat';
232
+ this.matchKeys = ['tcpport:443'];
233
+ this.heuristicFallback = true;
234
+ this.name = 'Transport Layer Security(Heartbeat Protocol)';
235
+ this.nickname = 'TLS-Heartbeat';
236
+ }
237
+ match() {
238
+ if (!this.prevCodecModule)
239
+ return false;
240
+ if ((0, BufferToHex_1.BufferToHex)(this.readBytes(0, 1)) != '18')
241
+ return false;
242
+ const version = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(1, 2));
243
+ const validVersions = [768, 769, 770, 771, 772];
244
+ return validVersions.includes(version);
245
+ }
246
+ }
247
+ exports.TLS_Heartbeat = TLS_Heartbeat;
@@ -0,0 +1,26 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * TPKT — the RFC 1006 "ISO Transport Service on top of TCP" packetization layer, TCP port 102. It is the
6
+ * bottom of the IEC 61850 MMS / substation ISO stack: a fixed 4-byte header — Version (always 3), a
7
+ * Reserved byte (usually 0), and a 2-byte big-endian Length — precedes the COTP TPDU (and above it the
8
+ * ISO Session / Presentation / ACSE / MMS layers). The Length counts the WHOLE TPKT PDU, the 4-byte header
9
+ * included, so `Length − 4` bytes of COTP-and-above follow.
10
+ *
11
+ * TPKT is not a leaf: it decodes only its 4 bytes (headerLength = 4) and the codec dispatches COTP next
12
+ * (COTP is an unkeyed content-heuristic child gated on prev.id === 'tpkt'). The Length is honoured verbatim
13
+ * when supplied — a crafted packet may carry any Length, which we reproduce faithfully — otherwise it is
14
+ * derived at packet-post-encode time from this layer plus everything stacked above it (COTP + session/MMS),
15
+ * mirroring how UDP derives its own Length. A well-formed frame round-trips byte-for-byte.
16
+ */
17
+ export declare class TPKT extends BaseHeader {
18
+ #private;
19
+ get SCHEMA(): ProtocolJSONSchema;
20
+ readonly id: string;
21
+ readonly name: string;
22
+ readonly nickname: string;
23
+ readonly matchKeys: string[];
24
+ match(): boolean;
25
+ readonly demuxProducers: DemuxProducer[];
26
+ }
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TPKT = void 0;
4
+ const BaseHeader_1 = require("../abstracts/BaseHeader");
5
+ const BufferToNumber_1 = require("../helper/BufferToNumber");
6
+ const NumberToBuffer_1 = require("../helper/NumberToBuffer");
7
+ /**
8
+ * TPKT — the RFC 1006 "ISO Transport Service on top of TCP" packetization layer, TCP port 102. It is the
9
+ * bottom of the IEC 61850 MMS / substation ISO stack: a fixed 4-byte header — Version (always 3), a
10
+ * Reserved byte (usually 0), and a 2-byte big-endian Length — precedes the COTP TPDU (and above it the
11
+ * ISO Session / Presentation / ACSE / MMS layers). The Length counts the WHOLE TPKT PDU, the 4-byte header
12
+ * included, so `Length − 4` bytes of COTP-and-above follow.
13
+ *
14
+ * TPKT is not a leaf: it decodes only its 4 bytes (headerLength = 4) and the codec dispatches COTP next
15
+ * (COTP is an unkeyed content-heuristic child gated on prev.id === 'tpkt'). The Length is honoured verbatim
16
+ * when supplied — a crafted packet may carry any Length, which we reproduce faithfully — otherwise it is
17
+ * derived at packet-post-encode time from this layer plus everything stacked above it (COTP + session/MMS),
18
+ * mirroring how UDP derives its own Length. A well-formed frame round-trips byte-for-byte.
19
+ */
20
+ class TPKT extends BaseHeader_1.BaseHeader {
21
+ constructor() {
22
+ super(...arguments);
23
+ this.id = 'tpkt';
24
+ this.name = 'TPKT';
25
+ this.nickname = 'TPKT';
26
+ //TPKT rides on TCP port 102 (ISO-on-TCP / MMS / S7) and 3389 (RDP, which layers X.224 over TPKT).
27
+ this.matchKeys = ['tcpport:102', 'tcpport:3389'];
28
+ //Not a leaf, but it exposes no demux value: the codec routes COTP as an unkeyed content-heuristic
29
+ //child that matches on prev.id === 'tpkt'.
30
+ this.demuxProducers = [];
31
+ }
32
+ static #schemaCache;
33
+ get SCHEMA() {
34
+ return (TPKT.#schemaCache ??= TPKT.#buildSchema());
35
+ }
36
+ static #buildSchema() {
37
+ return {
38
+ type: 'object',
39
+ summary: 'TPKT v${version} len=${length}',
40
+ properties: {
41
+ version: this.fieldUInt('version', 0, 1, 'Version'),
42
+ reserved: this.fieldUInt('reserved', 1, 1, 'Reserved'),
43
+ length: {
44
+ type: 'integer',
45
+ label: 'Length',
46
+ minimum: 0,
47
+ maximum: 65535,
48
+ decode: function () {
49
+ this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
50
+ },
51
+ encode: function () {
52
+ //The Length counts the entire TPKT PDU (the 4-byte header + the COTP-and-above
53
+ //bytes). Honour it verbatim when supplied (a crafted frame may lie); otherwise
54
+ //derive it after every layer has encoded, summing this header plus all layers
55
+ //stacked on top of it — the same approach UDP uses for its length.
56
+ const length = this.instance.length.getValue(0);
57
+ if (length) {
58
+ this.instance.length.setValue(length);
59
+ this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(length));
60
+ }
61
+ else {
62
+ this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(0));
63
+ this.addPostPacketEncodeHandler(() => {
64
+ let startCount = false;
65
+ let total = 0;
66
+ this.codecModules.forEach((codecModule) => {
67
+ if (codecModule === this)
68
+ startCount = true;
69
+ if (startCount)
70
+ total += codecModule.length;
71
+ });
72
+ //The Length is a 16-bit field; a total beyond 65535 cannot be represented.
73
+ //Clamp and record rather than silently wrapping (mirrors the Ajv guard on
74
+ //the honored path). A real TPKT PDU physically cannot exceed 65535, so this
75
+ //only guards crafted over-length stacks.
76
+ if (total > 65535) {
77
+ this.recordError(this.instance.length.getPath(), 'Maximum value is 65535');
78
+ total = 65535;
79
+ }
80
+ this.instance.length.setValue(total);
81
+ this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(total));
82
+ }, 1);
83
+ }
84
+ }
85
+ }
86
+ }
87
+ };
88
+ }
89
+ match() {
90
+ //Selected via the tcpport:102 / tcpport:3389 buckets. Require the full 4-byte header and the
91
+ //Version == 3 content signature so non-TPKT traffic on those ports falls through to raw.
92
+ if (!this.prevCodecModule || this.prevCodecModule.id !== 'tcp')
93
+ return false;
94
+ if (this.packet.length - this.startPos < 4)
95
+ return false;
96
+ return this.readBytes(0, 1, true)[0] === 3;
97
+ }
98
+ }
99
+ exports.TPKT = TPKT;
@@ -0,0 +1,27 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * TACACS+ — Terminal Access Controller Access-Control System Plus (RFC 8907), a Cisco AAA protocol on
6
+ * TCP port 49. Every packet begins with a 12-byte big-endian header: a Version octet split into a
7
+ * major (high nibble, 0xc for TACACS+) and minor (low nibble) version, a Type (1 Authentication,
8
+ * 2 Authorization, 3 Accounting), a Sequence Number, a Flags octet (bit0 UNENCRYPTED_FLAG,
9
+ * bit2 SINGLE_CONNECT_FLAG), a 32-bit Session Id, and a 32-bit Length counting the body that follows.
10
+ *
11
+ * The body is almost always obfuscated (XOR-encrypted with the shared secret and a hash of the header
12
+ * fields), and recovering it is cross-packet, key-dependent state — so this single-packet codec keeps
13
+ * the body verbatim as `body` hex and does not sub-decode it. The Length is auto-computed from the body
14
+ * on encode when not supplied, else honored verbatim (a crafted packet may lie); the body is bounded by
15
+ * the Length-derived extent and the captured bytes, so a pipelined/trailing packet is left to RawData.
16
+ * A well-formed packet round-trips byte-for-byte.
17
+ */
18
+ export declare class TacacsPlus extends BaseHeader {
19
+ #private;
20
+ get SCHEMA(): ProtocolJSONSchema;
21
+ readonly id: string;
22
+ readonly name: string;
23
+ readonly nickname: string;
24
+ readonly matchKeys: string[];
25
+ match(): boolean;
26
+ readonly demuxProducers: DemuxProducer[];
27
+ }
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TacacsPlus = void 0;
4
+ const BaseHeader_1 = require("../abstracts/BaseHeader");
5
+ const BufferToHex_1 = require("../helper/BufferToHex");
6
+ const HexToBuffer_1 = require("../helper/HexToBuffer");
7
+ const BufferToNumber_1 = require("../helper/BufferToNumber");
8
+ const NumberToBuffer_1 = require("../helper/NumberToBuffer");
9
+ const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
10
+ /**
11
+ * TACACS+ — Terminal Access Controller Access-Control System Plus (RFC 8907), a Cisco AAA protocol on
12
+ * TCP port 49. Every packet begins with a 12-byte big-endian header: a Version octet split into a
13
+ * major (high nibble, 0xc for TACACS+) and minor (low nibble) version, a Type (1 Authentication,
14
+ * 2 Authorization, 3 Accounting), a Sequence Number, a Flags octet (bit0 UNENCRYPTED_FLAG,
15
+ * bit2 SINGLE_CONNECT_FLAG), a 32-bit Session Id, and a 32-bit Length counting the body that follows.
16
+ *
17
+ * The body is almost always obfuscated (XOR-encrypted with the shared secret and a hash of the header
18
+ * fields), and recovering it is cross-packet, key-dependent state — so this single-packet codec keeps
19
+ * the body verbatim as `body` hex and does not sub-decode it. The Length is auto-computed from the body
20
+ * on encode when not supplied, else honored verbatim (a crafted packet may lie); the body is bounded by
21
+ * the Length-derived extent and the captured bytes, so a pipelined/trailing packet is left to RawData.
22
+ * A well-formed packet round-trips byte-for-byte.
23
+ */
24
+ class TacacsPlus extends BaseHeader_1.BaseHeader {
25
+ constructor() {
26
+ super(...arguments);
27
+ this.id = 'tacacs';
28
+ this.name = 'TACACS+';
29
+ this.nickname = 'TACACS+';
30
+ this.matchKeys = ['tcpport:49'];
31
+ //A leaf header — the body is usually encrypted and is kept as hex, not demuxed further.
32
+ this.demuxProducers = [];
33
+ }
34
+ static #schemaCache;
35
+ get SCHEMA() {
36
+ return (TacacsPlus.#schemaCache ??= TacacsPlus.#buildSchema());
37
+ }
38
+ static #buildSchema() {
39
+ return {
40
+ type: 'object',
41
+ summary: 'TACACS+ type=${type} session=${sessionId}',
42
+ properties: {
43
+ //Version octet (byte 0, MSB first): major version (high nibble) + minor version (low nibble).
44
+ version: {
45
+ type: 'object',
46
+ label: 'Version',
47
+ properties: {
48
+ major: {
49
+ type: 'integer',
50
+ label: 'Major Version',
51
+ minimum: 0,
52
+ maximum: 15,
53
+ decode: function () { this.instance.version.major.setValue(this.readBits(0, 1, 0, 4)); },
54
+ encode: function () { this.writeBits(0, 1, 0, 4, this.instance.version.major.getValue(0)); }
55
+ },
56
+ minor: {
57
+ type: 'integer',
58
+ label: 'Minor Version',
59
+ minimum: 0,
60
+ maximum: 15,
61
+ decode: function () { this.instance.version.minor.setValue(this.readBits(0, 1, 4, 4)); },
62
+ encode: function () { this.writeBits(0, 1, 4, 4, this.instance.version.minor.getValue(0)); }
63
+ }
64
+ }
65
+ },
66
+ type: this.fieldUInt('type', 1, 1, 'Type'),
67
+ seqNo: this.fieldUInt('seqNo', 2, 1, 'Sequence Number'),
68
+ flags: this.fieldUInt('flags', 3, 1, 'Flags'),
69
+ sessionId: this.fieldUInt('sessionId', 4, 4, 'Session Id'),
70
+ length: {
71
+ type: 'integer',
72
+ label: 'Length',
73
+ minimum: 0,
74
+ maximum: 4294967295,
75
+ decode: function () {
76
+ this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt32)(this.readBytes(8, 4)));
77
+ },
78
+ encode: function () {
79
+ //Length counts only the body that follows the 12-byte header. Honored when supplied
80
+ //(a crafted packet may lie); else derived from the body. TACACS+ is big-endian, so
81
+ //UInt32ToBuffer (BE) is used directly — no hand little-endian assembly.
82
+ const provided = this.instance.length.getValue();
83
+ let value = (provided !== undefined && provided !== null)
84
+ ? provided
85
+ : (0, HexToBuffer_1.HexToBuffer)(this.instance.body.getValue('')).length;
86
+ if (value > 4294967295) {
87
+ this.recordError(this.instance.length.getPath(), 'Maximum value is 4294967295');
88
+ value = 4294967295;
89
+ }
90
+ if (value < 0) {
91
+ this.recordError(this.instance.length.getPath(), 'Minimum value is 0');
92
+ value = 0;
93
+ }
94
+ this.instance.length.setValue(value);
95
+ this.writeBytes(8, (0, NumberToBuffer_1.UInt32ToBuffer)(value));
96
+ }
97
+ },
98
+ //The body after the 12-byte header, kept verbatim (usually encrypted). Bounded by the
99
+ //Length field (the packet ends at offset 12 + Length) and the captured bytes, so trailing
100
+ //or pipelined data is not absorbed.
101
+ body: {
102
+ type: 'string',
103
+ label: 'Body',
104
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
105
+ decode: function () {
106
+ const remaining = this.packet.length - this.startPos;
107
+ const length = this.instance.length.getValue(0);
108
+ let end = 12 + length;
109
+ if (end > remaining)
110
+ end = remaining;
111
+ this.instance.body.setValue(end > 12 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(12, end - 12)) : '');
112
+ },
113
+ encode: function () {
114
+ const body = this.instance.body.getValue('');
115
+ if (body)
116
+ this.writeBytes(12, (0, HexToBuffer_1.HexToBuffer)(body));
117
+ }
118
+ }
119
+ }
120
+ };
121
+ }
122
+ match() {
123
+ //TACACS+ rides on TCP port 49. Require the 12-byte header and the 0xc major-version nibble (the
124
+ //TACACS+ signature) so non-TACACS+ port-49 traffic falls through to raw.
125
+ if (!this.prevCodecModule || this.prevCodecModule.id !== 'tcp')
126
+ return false;
127
+ if (this.packet.length - this.startPos < 12)
128
+ return false;
129
+ const byte0 = this.readBytes(0, 1, true)[0];
130
+ return (byte0 >> 4) === 0xc;
131
+ }
132
+ }
133
+ exports.TacacsPlus = TacacsPlus;
@@ -0,0 +1,40 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * Telnet — the Telnet Protocol (RFC 854), carried over TCP well-known port 23. Telnet is a raw byte
6
+ * stream that interleaves user data with in-band control commands. A command is introduced by the IAC
7
+ * (Interpret As Command) escape 0xFF and is followed by a command byte:
8
+ *
9
+ * 241 NOP · 242 DM · 243 BRK · 244 IP · 245 AO · 246 AYT · 247 EC · 248 EL · 249 GA (2-byte commands)
10
+ * 251 WILL · 252 WONT · 253 DO · 254 DONT (3-byte: FF <cmd> <option>)
11
+ * 250 SB … 240 SE (subnegotiation, ends at FF F0)
12
+ * 255 (escaped IAC — a literal 0xFF DATA byte)
13
+ *
14
+ * MINIMAL slice (mirrors the SSH/RFB verbatim-message pattern): the connection is a stream with no
15
+ * per-message framing, so the ENTIRE payload is the single source of truth — decoded verbatim to hex in
16
+ * the authoritative `message` field and re-emitted byte-for-byte on encode. On top of that, the leading
17
+ * run of IAC command sequences is parsed into DISPLAY-ONLY metadata: `commands` (an array of
18
+ * {command, option?}) and `isNegotiation` (true when the payload opens with an IAC byte). Those carry no
19
+ * codec of their own and never reconstruct the bytes — the message owns them. So any Telnet payload
20
+ * (option negotiation, subnegotiation, plain data, or a truncated fragment) round-trips exactly.
21
+ *
22
+ * Matching rationale (NO heuristicFallback): Telnet is claimed ONLY on the tcp:23 bucket. Telnet has NO
23
+ * distinctive off-port content signature — it is an arbitrary byte stream (a leading IAC is common but
24
+ * optional, and in binary mode the data can be anything), so recognizing it relies entirely on the
25
+ * well-known port. Joining the global content-heuristic chain would therefore let Telnet mislabel
26
+ * arbitrary TCP payloads on any port. Confining Telnet to tcp:23 keeps that impossible; alt-port Telnet
27
+ * is rare and falls losslessly to raw. For the same reason match() deliberately does NOT gate on a
28
+ * leading IAC or printable text: on the port-23 bucket every payload IS Telnet (including binary-mode
29
+ * data), so any non-empty payload is kept verbatim rather than dropped to raw.
30
+ */
31
+ export declare class Telnet extends BaseHeader {
32
+ #private;
33
+ get SCHEMA(): ProtocolJSONSchema;
34
+ readonly id: string;
35
+ readonly name: string;
36
+ readonly nickname: string;
37
+ readonly matchKeys: string[];
38
+ match(): boolean;
39
+ readonly demuxProducers: DemuxProducer[];
40
+ }