@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.
- package/CHANGELOG.md +17 -0
- package/LICENSE +21 -0
- package/README.md +352 -0
- package/README.zh-CN.md +342 -0
- package/dist/Codec.d.ts +133 -0
- package/dist/Codec.js +632 -0
- package/dist/PacketHeaders.d.ts +189 -0
- package/dist/PacketHeaders.js +384 -0
- package/dist/abstracts/BaseHeader.d.ts +325 -0
- package/dist/abstracts/BaseHeader.js +734 -0
- package/dist/errors/CodecSchemaValidateError.d.ts +4 -0
- package/dist/errors/CodecSchemaValidateError.js +11 -0
- package/dist/headers/ADSAMS.d.ts +33 -0
- package/dist/headers/ADSAMS.js +208 -0
- package/dist/headers/AH.d.ts +28 -0
- package/dist/headers/AH.js +137 -0
- package/dist/headers/AMQP.d.ts +31 -0
- package/dist/headers/AMQP.js +316 -0
- package/dist/headers/ARP.d.ts +26 -0
- package/dist/headers/ARP.js +243 -0
- package/dist/headers/BACnetIP.d.ts +27 -0
- package/dist/headers/BACnetIP.js +97 -0
- package/dist/headers/BFD.d.ts +28 -0
- package/dist/headers/BFD.js +155 -0
- package/dist/headers/BGP.d.ts +27 -0
- package/dist/headers/BGP.js +111 -0
- package/dist/headers/BSAPIP.d.ts +33 -0
- package/dist/headers/BSAPIP.js +78 -0
- package/dist/headers/Babel.d.ts +32 -0
- package/dist/headers/Babel.js +224 -0
- package/dist/headers/BitTorrent.d.ts +28 -0
- package/dist/headers/BitTorrent.js +72 -0
- package/dist/headers/C37118.d.ts +26 -0
- package/dist/headers/C37118.js +147 -0
- package/dist/headers/CAPWAP.d.ts +38 -0
- package/dist/headers/CAPWAP.js +275 -0
- package/dist/headers/CDP.d.ts +25 -0
- package/dist/headers/CDP.js +117 -0
- package/dist/headers/CMS.d.ts +33 -0
- package/dist/headers/CMS.js +238 -0
- package/dist/headers/COTP.d.ts +30 -0
- package/dist/headers/COTP.js +193 -0
- package/dist/headers/CassandraCQL.d.ts +28 -0
- package/dist/headers/CassandraCQL.js +117 -0
- package/dist/headers/CoAP.d.ts +29 -0
- package/dist/headers/CoAP.js +140 -0
- package/dist/headers/Codesys.d.ts +32 -0
- package/dist/headers/Codesys.js +119 -0
- package/dist/headers/Collectd.d.ts +29 -0
- package/dist/headers/Collectd.js +154 -0
- package/dist/headers/DCCP.d.ts +30 -0
- package/dist/headers/DCCP.js +204 -0
- package/dist/headers/DHCP.d.ts +26 -0
- package/dist/headers/DHCP.js +148 -0
- package/dist/headers/DHCPFailover.d.ts +30 -0
- package/dist/headers/DHCPFailover.js +104 -0
- package/dist/headers/DHCPv6.d.ts +25 -0
- package/dist/headers/DHCPv6.js +145 -0
- package/dist/headers/DNP3.d.ts +27 -0
- package/dist/headers/DNP3.js +150 -0
- package/dist/headers/DNS.d.ts +55 -0
- package/dist/headers/DNS.js +309 -0
- package/dist/headers/DTLS.d.ts +33 -0
- package/dist/headers/DTLS.js +142 -0
- package/dist/headers/Diameter.d.ts +34 -0
- package/dist/headers/Diameter.js +229 -0
- package/dist/headers/EAPOL.d.ts +32 -0
- package/dist/headers/EAPOL.js +135 -0
- package/dist/headers/EIGRP.d.ts +28 -0
- package/dist/headers/EIGRP.js +165 -0
- package/dist/headers/ENIP.d.ts +31 -0
- package/dist/headers/ENIP.js +164 -0
- package/dist/headers/ESP.d.ts +27 -0
- package/dist/headers/ESP.js +140 -0
- package/dist/headers/Elasticsearch.d.ts +30 -0
- package/dist/headers/Elasticsearch.js +125 -0
- package/dist/headers/EtherCAT.d.ts +35 -0
- package/dist/headers/EtherCAT.js +150 -0
- package/dist/headers/EthernetII.d.ts +28 -0
- package/dist/headers/EthernetII.js +117 -0
- package/dist/headers/FCoE.d.ts +38 -0
- package/dist/headers/FCoE.js +210 -0
- package/dist/headers/FTP.d.ts +34 -0
- package/dist/headers/FTP.js +158 -0
- package/dist/headers/Finger.d.ts +41 -0
- package/dist/headers/Finger.js +135 -0
- package/dist/headers/FoundationFieldbusHSE.d.ts +43 -0
- package/dist/headers/FoundationFieldbusHSE.js +163 -0
- package/dist/headers/GELF.d.ts +35 -0
- package/dist/headers/GELF.js +261 -0
- package/dist/headers/GENEVE.d.ts +26 -0
- package/dist/headers/GENEVE.js +209 -0
- package/dist/headers/GESRTP.d.ts +32 -0
- package/dist/headers/GESRTP.js +141 -0
- package/dist/headers/GLBP.d.ts +29 -0
- package/dist/headers/GLBP.js +159 -0
- package/dist/headers/GRE.d.ts +27 -0
- package/dist/headers/GRE.js +181 -0
- package/dist/headers/GTPU.d.ts +25 -0
- package/dist/headers/GTPU.js +203 -0
- package/dist/headers/GTPv2C.d.ts +30 -0
- package/dist/headers/GTPv2C.js +281 -0
- package/dist/headers/GitProtocol.d.ts +34 -0
- package/dist/headers/GitProtocol.js +141 -0
- package/dist/headers/Goose.d.ts +115 -0
- package/dist/headers/Goose.js +1067 -0
- package/dist/headers/Gopher.d.ts +43 -0
- package/dist/headers/Gopher.js +182 -0
- package/dist/headers/HARTIP.d.ts +30 -0
- package/dist/headers/HARTIP.js +145 -0
- package/dist/headers/HSR.d.ts +27 -0
- package/dist/headers/HSR.js +105 -0
- package/dist/headers/HSRP.d.ts +26 -0
- package/dist/headers/HSRP.js +173 -0
- package/dist/headers/HTTP.d.ts +32 -0
- package/dist/headers/HTTP.js +153 -0
- package/dist/headers/HTTP2.d.ts +34 -0
- package/dist/headers/HTTP2.js +190 -0
- package/dist/headers/IAX2.d.ts +33 -0
- package/dist/headers/IAX2.js +274 -0
- package/dist/headers/ICMP.d.ts +15 -0
- package/dist/headers/ICMP.js +148 -0
- package/dist/headers/ICMPv6.d.ts +15 -0
- package/dist/headers/ICMPv6.js +129 -0
- package/dist/headers/IEC104_I_Frame.d.ts +23 -0
- package/dist/headers/IEC104_I_Frame.js +6489 -0
- package/dist/headers/IEC104_S_Frame.d.ts +26 -0
- package/dist/headers/IEC104_S_Frame.js +135 -0
- package/dist/headers/IEC104_U_Frame.d.ts +27 -0
- package/dist/headers/IEC104_U_Frame.js +176 -0
- package/dist/headers/IEC61850SampledValues.d.ts +20 -0
- package/dist/headers/IEC61850SampledValues.js +420 -0
- package/dist/headers/IGMP.d.ts +31 -0
- package/dist/headers/IGMP.js +274 -0
- package/dist/headers/IMAP.d.ts +32 -0
- package/dist/headers/IMAP.js +185 -0
- package/dist/headers/IPFIX.d.ts +29 -0
- package/dist/headers/IPFIX.js +156 -0
- package/dist/headers/IPv4.d.ts +20 -0
- package/dist/headers/IPv4.js +370 -0
- package/dist/headers/IPv6.d.ts +29 -0
- package/dist/headers/IPv6.js +209 -0
- package/dist/headers/IPv6HopByHopOptions.d.ts +81 -0
- package/dist/headers/IPv6HopByHopOptions.js +495 -0
- package/dist/headers/IRC.d.ts +34 -0
- package/dist/headers/IRC.js +175 -0
- package/dist/headers/ISAKMP.d.ts +29 -0
- package/dist/headers/ISAKMP.js +197 -0
- package/dist/headers/ISCSI.d.ts +39 -0
- package/dist/headers/ISCSI.js +289 -0
- package/dist/headers/ISIS.d.ts +25 -0
- package/dist/headers/ISIS.js +79 -0
- package/dist/headers/ISOSession.d.ts +27 -0
- package/dist/headers/ISOSession.js +343 -0
- package/dist/headers/Ident.d.ts +42 -0
- package/dist/headers/Ident.js +184 -0
- package/dist/headers/KNXnetIP.d.ts +30 -0
- package/dist/headers/KNXnetIP.js +135 -0
- package/dist/headers/Kafka.d.ts +35 -0
- package/dist/headers/Kafka.js +128 -0
- package/dist/headers/Kerberos.d.ts +30 -0
- package/dist/headers/Kerberos.js +217 -0
- package/dist/headers/L2TP.d.ts +26 -0
- package/dist/headers/L2TP.js +297 -0
- package/dist/headers/LACP.d.ts +31 -0
- package/dist/headers/LACP.js +151 -0
- package/dist/headers/LDAP.d.ts +31 -0
- package/dist/headers/LDAP.js +226 -0
- package/dist/headers/LDP.d.ts +31 -0
- package/dist/headers/LDP.js +138 -0
- package/dist/headers/LISP.d.ts +30 -0
- package/dist/headers/LISP.js +103 -0
- package/dist/headers/LLC.d.ts +27 -0
- package/dist/headers/LLC.js +81 -0
- package/dist/headers/LLDP.d.ts +26 -0
- package/dist/headers/LLDP.js +126 -0
- package/dist/headers/LLMNR.d.ts +23 -0
- package/dist/headers/LLMNR.js +40 -0
- package/dist/headers/LPD.d.ts +31 -0
- package/dist/headers/LPD.js +159 -0
- package/dist/headers/MACsec.d.ts +34 -0
- package/dist/headers/MACsec.js +178 -0
- package/dist/headers/MDNS.d.ts +26 -0
- package/dist/headers/MDNS.js +45 -0
- package/dist/headers/MGCP.d.ts +30 -0
- package/dist/headers/MGCP.js +155 -0
- package/dist/headers/MMS.d.ts +29 -0
- package/dist/headers/MMS.js +243 -0
- package/dist/headers/MPLS.d.ts +31 -0
- package/dist/headers/MPLS.js +145 -0
- package/dist/headers/MQTT.d.ts +30 -0
- package/dist/headers/MQTT.js +173 -0
- package/dist/headers/MQTTSN.d.ts +34 -0
- package/dist/headers/MQTTSN.js +177 -0
- package/dist/headers/MarkerProtocol.d.ts +32 -0
- package/dist/headers/MarkerProtocol.js +153 -0
- package/dist/headers/Megaco.d.ts +32 -0
- package/dist/headers/Megaco.js +144 -0
- package/dist/headers/Memcached.d.ts +44 -0
- package/dist/headers/Memcached.js +285 -0
- package/dist/headers/ModbusTCP.d.ts +25 -0
- package/dist/headers/ModbusTCP.js +99 -0
- package/dist/headers/ModbusUDP.d.ts +26 -0
- package/dist/headers/ModbusUDP.js +100 -0
- package/dist/headers/MongoDB.d.ts +33 -0
- package/dist/headers/MongoDB.js +143 -0
- package/dist/headers/MySQL.d.ts +30 -0
- package/dist/headers/MySQL.js +114 -0
- package/dist/headers/NATS.d.ts +29 -0
- package/dist/headers/NATS.js +135 -0
- package/dist/headers/NBDS.d.ts +34 -0
- package/dist/headers/NBDS.js +176 -0
- package/dist/headers/NBNS.d.ts +34 -0
- package/dist/headers/NBNS.js +78 -0
- package/dist/headers/NBSS.d.ts +36 -0
- package/dist/headers/NBSS.js +137 -0
- package/dist/headers/NFS.d.ts +36 -0
- package/dist/headers/NFS.js +273 -0
- package/dist/headers/NHRP.d.ts +32 -0
- package/dist/headers/NHRP.js +154 -0
- package/dist/headers/NNTP.d.ts +35 -0
- package/dist/headers/NNTP.js +162 -0
- package/dist/headers/NTP.d.ts +18 -0
- package/dist/headers/NTP.js +73 -0
- package/dist/headers/NetFlowV5.d.ts +28 -0
- package/dist/headers/NetFlowV5.js +205 -0
- package/dist/headers/OLSR.d.ts +31 -0
- package/dist/headers/OLSR.js +213 -0
- package/dist/headers/OPCUA.d.ts +33 -0
- package/dist/headers/OPCUA.js +165 -0
- package/dist/headers/OPCUAPubSub.d.ts +33 -0
- package/dist/headers/OPCUAPubSub.js +144 -0
- package/dist/headers/OSPF.d.ts +31 -0
- package/dist/headers/OSPF.js +365 -0
- package/dist/headers/OmronFINS.d.ts +31 -0
- package/dist/headers/OmronFINS.js +90 -0
- package/dist/headers/OpenFlow.d.ts +30 -0
- package/dist/headers/OpenFlow.js +113 -0
- package/dist/headers/OpenVPN.d.ts +35 -0
- package/dist/headers/OpenVPN.js +214 -0
- package/dist/headers/PCWorx.d.ts +35 -0
- package/dist/headers/PCWorx.js +115 -0
- package/dist/headers/PIM.d.ts +27 -0
- package/dist/headers/PIM.js +129 -0
- package/dist/headers/POP3.d.ts +31 -0
- package/dist/headers/POP3.js +152 -0
- package/dist/headers/POWERLINK.d.ts +28 -0
- package/dist/headers/POWERLINK.js +116 -0
- package/dist/headers/PPPoEDiscovery.d.ts +29 -0
- package/dist/headers/PPPoEDiscovery.js +198 -0
- package/dist/headers/PPPoESession.d.ts +28 -0
- package/dist/headers/PPPoESession.js +125 -0
- package/dist/headers/PPTP.d.ts +30 -0
- package/dist/headers/PPTP.js +122 -0
- package/dist/headers/PROFINETRT.d.ts +28 -0
- package/dist/headers/PROFINETRT.js +74 -0
- package/dist/headers/PTP.d.ts +34 -0
- package/dist/headers/PTP.js +213 -0
- package/dist/headers/PostgreSQL.d.ts +40 -0
- package/dist/headers/PostgreSQL.js +236 -0
- package/dist/headers/QUIC.d.ts +34 -0
- package/dist/headers/QUIC.js +308 -0
- package/dist/headers/RADIUS.d.ts +24 -0
- package/dist/headers/RADIUS.js +138 -0
- package/dist/headers/RDP.d.ts +27 -0
- package/dist/headers/RDP.js +93 -0
- package/dist/headers/RFB.d.ts +39 -0
- package/dist/headers/RFB.js +151 -0
- package/dist/headers/RGoose.d.ts +72 -0
- package/dist/headers/RGoose.js +340 -0
- package/dist/headers/RIP.d.ts +29 -0
- package/dist/headers/RIP.js +133 -0
- package/dist/headers/RIPng.d.ts +26 -0
- package/dist/headers/RIPng.js +140 -0
- package/dist/headers/RMCP.d.ts +26 -0
- package/dist/headers/RMCP.js +155 -0
- package/dist/headers/RSVP.d.ts +31 -0
- package/dist/headers/RSVP.js +263 -0
- package/dist/headers/RTCP.d.ts +34 -0
- package/dist/headers/RTCP.js +217 -0
- package/dist/headers/RTP.d.ts +33 -0
- package/dist/headers/RTP.js +291 -0
- package/dist/headers/RTPS.d.ts +33 -0
- package/dist/headers/RTPS.js +182 -0
- package/dist/headers/RTSP.d.ts +36 -0
- package/dist/headers/RTSP.js +184 -0
- package/dist/headers/RawData.d.ts +17 -0
- package/dist/headers/RawData.js +43 -0
- package/dist/headers/Redis.d.ts +32 -0
- package/dist/headers/Redis.js +202 -0
- package/dist/headers/Rlogin.d.ts +42 -0
- package/dist/headers/Rlogin.js +139 -0
- package/dist/headers/Rsync.d.ts +28 -0
- package/dist/headers/Rsync.js +117 -0
- package/dist/headers/S7comm.d.ts +36 -0
- package/dist/headers/S7comm.js +244 -0
- package/dist/headers/SCTP.d.ts +35 -0
- package/dist/headers/SCTP.js +174 -0
- package/dist/headers/SFlow.d.ts +29 -0
- package/dist/headers/SFlow.js +242 -0
- package/dist/headers/SIP.d.ts +27 -0
- package/dist/headers/SIP.js +146 -0
- package/dist/headers/SLMP.d.ts +36 -0
- package/dist/headers/SLMP.js +154 -0
- package/dist/headers/SLP.d.ts +30 -0
- package/dist/headers/SLP.js +207 -0
- package/dist/headers/SLPv1.d.ts +32 -0
- package/dist/headers/SLPv1.js +138 -0
- package/dist/headers/SMB1.d.ts +37 -0
- package/dist/headers/SMB1.js +200 -0
- package/dist/headers/SMB2.d.ts +36 -0
- package/dist/headers/SMB2.js +203 -0
- package/dist/headers/SMPP.d.ts +33 -0
- package/dist/headers/SMPP.js +119 -0
- package/dist/headers/SMTP.d.ts +33 -0
- package/dist/headers/SMTP.js +157 -0
- package/dist/headers/SNAP.d.ts +22 -0
- package/dist/headers/SNAP.js +68 -0
- package/dist/headers/SNMP.d.ts +28 -0
- package/dist/headers/SNMP.js +302 -0
- package/dist/headers/SOCKS4.d.ts +42 -0
- package/dist/headers/SOCKS4.js +302 -0
- package/dist/headers/SOCKS5.d.ts +45 -0
- package/dist/headers/SOCKS5.js +223 -0
- package/dist/headers/SSDP.d.ts +27 -0
- package/dist/headers/SSDP.js +161 -0
- package/dist/headers/SSH.d.ts +44 -0
- package/dist/headers/SSH.js +274 -0
- package/dist/headers/STOMP.d.ts +48 -0
- package/dist/headers/STOMP.js +177 -0
- package/dist/headers/STP.d.ts +26 -0
- package/dist/headers/STP.js +150 -0
- package/dist/headers/STUN.d.ts +25 -0
- package/dist/headers/STUN.js +183 -0
- package/dist/headers/SercosIII.d.ts +43 -0
- package/dist/headers/SercosIII.js +199 -0
- package/dist/headers/Skinny.d.ts +32 -0
- package/dist/headers/Skinny.js +139 -0
- package/dist/headers/StatsD.d.ts +27 -0
- package/dist/headers/StatsD.js +134 -0
- package/dist/headers/SunRPC.d.ts +34 -0
- package/dist/headers/SunRPC.js +268 -0
- package/dist/headers/Syslog.d.ts +21 -0
- package/dist/headers/Syslog.js +91 -0
- package/dist/headers/TCP.d.ts +19 -0
- package/dist/headers/TCP.js +905 -0
- package/dist/headers/TFTP.d.ts +28 -0
- package/dist/headers/TFTP.js +224 -0
- package/dist/headers/TLS_Alert.d.ts +24 -0
- package/dist/headers/TLS_Alert.js +639 -0
- package/dist/headers/TLS_ApplicationData.d.ts +24 -0
- package/dist/headers/TLS_ApplicationData.js +170 -0
- package/dist/headers/TLS_ChangeCipherSpec.d.ts +23 -0
- package/dist/headers/TLS_ChangeCipherSpec.js +168 -0
- package/dist/headers/TLS_Handshake.d.ts +65 -0
- package/dist/headers/TLS_Handshake.js +860 -0
- package/dist/headers/TLS_Heartbeat.d.ts +27 -0
- package/dist/headers/TLS_Heartbeat.js +247 -0
- package/dist/headers/TPKT.d.ts +26 -0
- package/dist/headers/TPKT.js +99 -0
- package/dist/headers/TacacsPlus.d.ts +27 -0
- package/dist/headers/TacacsPlus.js +133 -0
- package/dist/headers/Telnet.d.ts +40 -0
- package/dist/headers/Telnet.js +193 -0
- package/dist/headers/Teredo.d.ts +40 -0
- package/dist/headers/Teredo.js +251 -0
- package/dist/headers/TimeProtocol.d.ts +25 -0
- package/dist/headers/TimeProtocol.js +53 -0
- package/dist/headers/UDP.d.ts +19 -0
- package/dist/headers/UDP.js +171 -0
- package/dist/headers/VLAN_802dot1Q.d.ts +24 -0
- package/dist/headers/VLAN_802dot1Q.js +96 -0
- package/dist/headers/VRRP.d.ts +26 -0
- package/dist/headers/VRRP.js +309 -0
- package/dist/headers/VXLAN.d.ts +24 -0
- package/dist/headers/VXLAN.js +75 -0
- package/dist/headers/WCCP.d.ts +29 -0
- package/dist/headers/WCCP.js +117 -0
- package/dist/headers/WHOIS.d.ts +37 -0
- package/dist/headers/WHOIS.js +126 -0
- package/dist/headers/WSDiscovery.d.ts +29 -0
- package/dist/headers/WSDiscovery.js +118 -0
- package/dist/headers/WakeOnLAN.d.ts +30 -0
- package/dist/headers/WakeOnLAN.js +126 -0
- package/dist/headers/WebSocket.d.ts +26 -0
- package/dist/headers/WebSocket.js +173 -0
- package/dist/headers/WireGuard.d.ts +38 -0
- package/dist/headers/WireGuard.js +216 -0
- package/dist/headers/XMPP.d.ts +37 -0
- package/dist/headers/XMPP.js +149 -0
- package/dist/headers/Zabbix.d.ts +35 -0
- package/dist/headers/Zabbix.js +153 -0
- package/dist/headers/cms/AcsiPdu.d.ts +45 -0
- package/dist/headers/cms/AcsiPdu.js +112 -0
- package/dist/headers/cms/PerDecoder.d.ts +68 -0
- package/dist/headers/cms/PerDecoder.js +211 -0
- package/dist/headers/cms/PerReader.d.ts +64 -0
- package/dist/headers/cms/PerReader.js +155 -0
- package/dist/helper/BufferToHex.d.ts +5 -0
- package/dist/helper/BufferToHex.js +10 -0
- package/dist/helper/BufferToIP.d.ts +12 -0
- package/dist/helper/BufferToIP.js +23 -0
- package/dist/helper/BufferToNumber.d.ts +18 -0
- package/dist/helper/BufferToNumber.js +47 -0
- package/dist/helper/HexToBuffer.d.ts +7 -0
- package/dist/helper/HexToBuffer.js +27 -0
- package/dist/helper/HexToNumber.d.ts +18 -0
- package/dist/helper/HexToNumber.js +48 -0
- package/dist/helper/IPToBuffer.d.ts +12 -0
- package/dist/helper/IPToBuffer.js +34 -0
- package/dist/helper/NumberToBERBuffer.d.ts +18 -0
- package/dist/helper/NumberToBERBuffer.js +31 -0
- package/dist/helper/NumberToBERHex.d.ts +18 -0
- package/dist/helper/NumberToBERHex.js +52 -0
- package/dist/helper/NumberToBuffer.d.ts +18 -0
- package/dist/helper/NumberToBuffer.js +38 -0
- package/dist/helper/NumberToHex.d.ts +18 -0
- package/dist/helper/NumberToHex.js +35 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.js +113 -0
- package/dist/lib/FlexibleObject.d.ts +27 -0
- package/dist/lib/FlexibleObject.js +113 -0
- package/dist/lib/GetBERIntegerLengthFromBuffer.d.ts +6 -0
- package/dist/lib/GetBERIntegerLengthFromBuffer.js +16 -0
- package/dist/lib/ProcessPacketPostHandlers.d.ts +13 -0
- package/dist/lib/ProcessPacketPostHandlers.js +53 -0
- package/dist/lib/SortPostHandlers.d.ts +7 -0
- package/dist/lib/SortPostHandlers.js +11 -0
- package/dist/lib/StringContentEncodingEnum.d.ts +10 -0
- package/dist/lib/StringContentEncodingEnum.js +14 -0
- package/dist/schema/ProtocolFieldJSONSchema.d.ts +35 -0
- package/dist/schema/ProtocolFieldJSONSchema.js +2 -0
- package/dist/schema/ProtocolFieldJSONSchemaDefinition.d.ts +2 -0
- package/dist/schema/ProtocolFieldJSONSchemaDefinition.js +2 -0
- package/dist/schema/ProtocolJSONSchema.d.ts +32 -0
- package/dist/schema/ProtocolJSONSchema.js +2 -0
- package/dist/types/CodecData.d.ts +7 -0
- package/dist/types/CodecData.js +2 -0
- package/dist/types/CodecDecodeResult.d.ts +10 -0
- package/dist/types/CodecDecodeResult.js +2 -0
- package/dist/types/CodecEncodeInput.d.ts +2 -0
- package/dist/types/CodecEncodeInput.js +2 -0
- package/dist/types/CodecEncodeResult.d.ts +5 -0
- package/dist/types/CodecEncodeResult.js +2 -0
- package/dist/types/CodecErrorInfo.d.ts +5 -0
- package/dist/types/CodecErrorInfo.js +2 -0
- package/dist/types/CodecModule.d.ts +2 -0
- package/dist/types/CodecModule.js +2 -0
- package/dist/types/CodecModuleConstructor.d.ts +2 -0
- package/dist/types/CodecModuleConstructor.js +2 -0
- package/dist/types/CodecSchema.d.ts +6 -0
- package/dist/types/CodecSchema.js +2 -0
- package/dist/types/DemuxProducer.d.ts +23 -0
- package/dist/types/DemuxProducer.js +2 -0
- package/dist/types/Dissection.d.ts +23 -0
- package/dist/types/Dissection.js +2 -0
- package/dist/types/HeaderTreeNode.d.ts +4 -0
- package/dist/types/HeaderTreeNode.js +2 -0
- package/dist/types/LayerGraph.d.ts +32 -0
- package/dist/types/LayerGraph.js +2 -0
- package/dist/types/PostHandlerItem.d.ts +4 -0
- package/dist/types/PostHandlerItem.js +2 -0
- package/package.json +141 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.SSDP = void 0;
|
|
5
|
+
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
6
|
+
const BufferToHex_1 = require("../helper/BufferToHex");
|
|
7
|
+
const HexToBuffer_1 = require("../helper/HexToBuffer");
|
|
8
|
+
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
9
|
+
/** SSDP request methods (UPnP Device Architecture) used only to recognize a request start-line. */
|
|
10
|
+
const SSDP_METHODS = ['NOTIFY', 'M-SEARCH'];
|
|
11
|
+
/**
|
|
12
|
+
* SSDP — the Simple Service Discovery Protocol (UPnP Device Architecture), the discovery layer of UPnP
|
|
13
|
+
* carried over UDP port 1900 (advertisements/searches to the multicast group 239.255.255.250, unicast
|
|
14
|
+
* search responses). An SSDP message is HTTP/1.1-shaped US-ASCII text but is NOT HTTP: a start-line,
|
|
15
|
+
* then header lines, and a terminating CRLF. Requests use `NOTIFY * HTTP/1.1` (advertise) or
|
|
16
|
+
* `M-SEARCH * HTTP/1.1` (search); responses use a `HTTP/1.1 200 OK` Status-Line.
|
|
17
|
+
*
|
|
18
|
+
* Like SIP and HTTP, the message body is text whose full internal structure (HOST/NT/NTS/USN/ST/MAN/…
|
|
19
|
+
* header fields, significant whitespace/header ordering/casing) is far richer than a form needs. So the
|
|
20
|
+
* ENTIRE raw message is kept verbatim as the authoritative `message` field (hex) and re-emitted
|
|
21
|
+
* untouched; only the start-line is parsed on decode into display-only metadata (method/uri/version or
|
|
22
|
+
* status-code/reason). Encode never reconstructs the message from the parsed fields — it writes
|
|
23
|
+
* `message` back byte-for-byte — so any conformant (or even malformed) SSDP message round-trips exactly.
|
|
24
|
+
*/
|
|
25
|
+
class SSDP extends BaseHeader_1.BaseHeader {
|
|
26
|
+
constructor() {
|
|
27
|
+
super(...arguments);
|
|
28
|
+
this.id = 'ssdp';
|
|
29
|
+
this.name = 'Simple Service Discovery Protocol';
|
|
30
|
+
this.nickname = 'SSDP';
|
|
31
|
+
//SSDP is strictly UDP port 1900 — the port bucket alone dispatches. No heuristicFallback: the
|
|
32
|
+
//start-line signature (NOTIFY/M-SEARCH/HTTP-1.1) overlaps HTTP, so recognition stays confined to the
|
|
33
|
+
//1900 bucket to avoid claiming HTTP traffic on arbitrary ports.
|
|
34
|
+
this.matchKeys = ['udpport:1900'];
|
|
35
|
+
//A leaf header — the referenced device description (LOCATION URL) and the discovery exchange are a
|
|
36
|
+
//higher-layer concern.
|
|
37
|
+
this.demuxProducers = [];
|
|
38
|
+
}
|
|
39
|
+
static #schemaCache;
|
|
40
|
+
get SCHEMA() {
|
|
41
|
+
return (_a.#schemaCache ??= _a.#buildSchema());
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Bytes of this header: SSDP rides on UDP, so it is bounded by the datagram length (so a retained
|
|
45
|
+
* FCS/padding is not absorbed). Falls back to the rest of the captured buffer if the UDP length is
|
|
46
|
+
* absent/implausible.
|
|
47
|
+
*/
|
|
48
|
+
#payloadLength() {
|
|
49
|
+
let available = this.packet.length - this.startPos;
|
|
50
|
+
if (this.prevCodecModule && this.prevCodecModule.id === 'udp') {
|
|
51
|
+
const udpLength = this.prevCodecModule.instance.length.getValue(0);
|
|
52
|
+
if (udpLength >= 8 && udpLength - 8 < available)
|
|
53
|
+
available = udpLength - 8;
|
|
54
|
+
}
|
|
55
|
+
return available < 0 ? 0 : available;
|
|
56
|
+
}
|
|
57
|
+
/** The first line of the message (up to the first CRLF, or the whole payload if none). */
|
|
58
|
+
static #firstLine(text) {
|
|
59
|
+
const idx = text.indexOf('\r\n');
|
|
60
|
+
return idx >= 0 ? text.slice(0, idx) : text;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Parse the start-line into the display-only metadata fields. A Status-Line begins with the
|
|
64
|
+
* HTTP-Version ("HTTP/1.1"); anything else is treated as a Request-Line. Populated on decode only —
|
|
65
|
+
* these fields have no encode, so they never affect the re-emitted bytes and never mutate `message`.
|
|
66
|
+
* Never throws: a non-numeric status yields 0, missing tokens yield empty strings.
|
|
67
|
+
*/
|
|
68
|
+
#parseStartLine(text) {
|
|
69
|
+
const line = _a.#firstLine(text);
|
|
70
|
+
if (line.startsWith('HTTP/')) {
|
|
71
|
+
//Status-Line: HTTP-Version SP Status-Code SP Reason-Phrase
|
|
72
|
+
const match = line.match(/^(\S+)\s+(\d{3})\s*(.*)$/);
|
|
73
|
+
this.instance.isRequest.setValue(false);
|
|
74
|
+
this.instance.method.setValue('');
|
|
75
|
+
this.instance.requestUri.setValue('');
|
|
76
|
+
this.instance.version.setValue(match ? match[1] : (line.split(' ')[0] || ''));
|
|
77
|
+
this.instance.statusCode.setValue(match ? Number(match[2]) : 0);
|
|
78
|
+
this.instance.reasonPhrase.setValue(match ? match[3] : '');
|
|
79
|
+
//Info-column text for a response: "200 OK". Kept separate from the numeric statusCode so the
|
|
80
|
+
//summary never renders a stray "0" for requests (whose statusCode is 0).
|
|
81
|
+
this.instance.info.setValue((match ? match[2] : '') + (match && match[3] ? ' ' + match[3] : ''));
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
//Request-Line: METHOD SP Request-URI SP HTTP-Version (Request-URI is "*" for SSDP)
|
|
85
|
+
const parts = line.split(' ');
|
|
86
|
+
this.instance.isRequest.setValue(true);
|
|
87
|
+
this.instance.method.setValue(parts[0] ? parts[0] : '');
|
|
88
|
+
this.instance.requestUri.setValue(parts.length > 1 ? parts[1] : '');
|
|
89
|
+
//The HTTP-Version is the last whitespace-delimited token; the Request-URI itself has no spaces.
|
|
90
|
+
this.instance.version.setValue(parts.length > 2 ? parts[parts.length - 1] : '');
|
|
91
|
+
this.instance.statusCode.setValue(0);
|
|
92
|
+
this.instance.reasonPhrase.setValue('');
|
|
93
|
+
//Info-column text for a request: "M-SEARCH *".
|
|
94
|
+
this.instance.info.setValue((parts[0] ? parts[0] : '') + (parts.length > 1 && parts[1] ? ' ' + parts[1] : ''));
|
|
95
|
+
}
|
|
96
|
+
static #buildSchema() {
|
|
97
|
+
return {
|
|
98
|
+
type: 'object',
|
|
99
|
+
summary: 'SSDP ${info}',
|
|
100
|
+
properties: {
|
|
101
|
+
//The whole raw message is the single source of truth: decoded verbatim to hex and
|
|
102
|
+
//re-emitted untouched (byte-perfect for any SSDP message). The start-line is parsed into
|
|
103
|
+
//the display-only metadata below, which carry no codec of their own.
|
|
104
|
+
message: {
|
|
105
|
+
type: 'string',
|
|
106
|
+
label: 'Message',
|
|
107
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
108
|
+
decode: function () {
|
|
109
|
+
const available = this.#payloadLength();
|
|
110
|
+
if (available <= 0) {
|
|
111
|
+
this.instance.message.setValue('');
|
|
112
|
+
this.#parseStartLine('');
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const raw = this.readBytes(0, available);
|
|
116
|
+
this.instance.message.setValue((0, BufferToHex_1.BufferToHex)(raw));
|
|
117
|
+
this.#parseStartLine(raw.toString('latin1'));
|
|
118
|
+
},
|
|
119
|
+
encode: function () {
|
|
120
|
+
//Re-emit the authoritative message verbatim — never reconstruct from metadata.
|
|
121
|
+
this.writeBytes(0, (0, HexToBuffer_1.HexToBuffer)(this.instance.message.getValue('')));
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
//Display-only metadata parsed from the start-line on decode (no encode — populated by the
|
|
125
|
+
//message field above, never read back). isRequest distinguishes a Request-Line from a
|
|
126
|
+
//Status-Line; method/requestUri are for requests, statusCode/reasonPhrase for responses.
|
|
127
|
+
isRequest: { type: 'boolean', label: 'Is Request' },
|
|
128
|
+
//Display-only Info-column text ("M-SEARCH *" / "200 OK"), set on decode; no encode, so it
|
|
129
|
+
//never affects the re-emitted bytes.
|
|
130
|
+
info: { type: 'string', label: 'Info' },
|
|
131
|
+
method: { type: 'string', label: 'Method' },
|
|
132
|
+
requestUri: { type: 'string', label: 'Request URI' },
|
|
133
|
+
version: { type: 'string', label: 'Version' },
|
|
134
|
+
statusCode: { type: 'integer', label: 'Status Code', minimum: 0, maximum: 999 },
|
|
135
|
+
reasonPhrase: { type: 'string', label: 'Reason Phrase' }
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
match() {
|
|
140
|
+
//SSDP rides on UDP port 1900 as HTTP/1.1-shaped US-ASCII text. Recognize it by the start-line
|
|
141
|
+
//signature: a known request method followed by a space (the trailing space rejects e.g.
|
|
142
|
+
//"NOTIFYX"), or the "HTTP/1." response version — so non-SSDP traffic on port 1900 falls through
|
|
143
|
+
//to raw rather than claiming an un-decodable text layer.
|
|
144
|
+
if (!this.prevCodecModule)
|
|
145
|
+
return false;
|
|
146
|
+
if (this.prevCodecModule.id !== 'udp')
|
|
147
|
+
return false;
|
|
148
|
+
if (this.#payloadLength() <= 0)
|
|
149
|
+
return false;
|
|
150
|
+
const lead = this.readBytes(0, 16, true).toString('latin1');
|
|
151
|
+
if (lead.startsWith('HTTP/1.'))
|
|
152
|
+
return true;
|
|
153
|
+
for (const method of SSDP_METHODS) {
|
|
154
|
+
if (lead.startsWith(method + ' '))
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
exports.SSDP = SSDP;
|
|
161
|
+
_a = SSDP;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* SSH — the Secure Shell Transport Layer Protocol (RFC 4253), carried over TCP well-known port 22.
|
|
6
|
+
*
|
|
7
|
+
* An SSH connection has two shapes on the wire, and this codec handles BOTH:
|
|
8
|
+
*
|
|
9
|
+
* 1. Identification string. The very first thing each side sends is a US-ASCII line
|
|
10
|
+
* `SSH-protoversion-softwareversion[ SP comments]` terminated by CR LF (a lone LF is tolerated),
|
|
11
|
+
* e.g. `SSH-2.0-OpenSSH_9.6\r\n` (also seen: `SSH-1.99-…` for 2.0 servers that also speak 1.x, and
|
|
12
|
+
* legacy `SSH-1.5-…`). Like the other US-ASCII line protocols in this codec (HTTP/SIP/FTP), the
|
|
13
|
+
* structure a form needs is far poorer than the exact bytes a peer sees, so the ENTIRE line is kept
|
|
14
|
+
* verbatim as the authoritative `message` field (hex) and re-emitted untouched; only the first line
|
|
15
|
+
* is parsed on decode into display-only metadata (protoVersion/softwareVersion/identString). Encode
|
|
16
|
+
* never reconstructs the line from those fields — it writes `message` back byte-for-byte.
|
|
17
|
+
*
|
|
18
|
+
* 2. Binary Packet Protocol. After the identifications comes the framed protocol:
|
|
19
|
+
* `packet_length(4, BE) · padding_length(1) · payload(packet_length - padding_length - 1) ·
|
|
20
|
+
* padding(padding_length) · MAC(mac_len)`. The MAC is present only once keys are exchanged; the
|
|
21
|
+
* first binary packet (SSH_MSG_KEXINIT) is sent in cleartext and is readable. This codec keeps the
|
|
22
|
+
* framing minimal and byte-exact: `packet_length` and `padding_length` are structured, editable
|
|
23
|
+
* fields, and everything they bound (payload + padding) is kept verbatim as `data` hex. The packet
|
|
24
|
+
* is bounded by `packet_length + 4` bytes; any MAC/trailing/pipelined bytes are left to the codec's
|
|
25
|
+
* recursion / RawData (decoding the MAC needs cross-message negotiated cipher/MAC state, which is
|
|
26
|
+
* out of scope for a single-message codec). A well-formed message round-trips byte-for-byte.
|
|
27
|
+
*
|
|
28
|
+
* Matching rationale (NO heuristicFallback): SSH is claimed ONLY on the tcp:22 bucket. The
|
|
29
|
+
* identification line has a strong, distinctive signature ("SSH-") — but the Binary Packet Protocol has
|
|
30
|
+
* NO content magic at all (a 4-byte length + a padding byte is indistinguishable from arbitrary binary
|
|
31
|
+
* data), so recognizing binary SSH packets relies entirely on the well-known port. Joining the global
|
|
32
|
+
* content-heuristic chain would therefore let SSH mislabel arbitrary binary TCP payloads on any port.
|
|
33
|
+
* Confining SSH to tcp:22 keeps that impossible; alt-port SSH is rare and falls losslessly to raw.
|
|
34
|
+
*/
|
|
35
|
+
export declare class SSH extends BaseHeader {
|
|
36
|
+
#private;
|
|
37
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
38
|
+
readonly id: string;
|
|
39
|
+
readonly name: string;
|
|
40
|
+
readonly nickname: string;
|
|
41
|
+
readonly matchKeys: string[];
|
|
42
|
+
match(): boolean;
|
|
43
|
+
readonly demuxProducers: DemuxProducer[];
|
|
44
|
+
}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SSH = 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 StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
8
|
+
/**
|
|
9
|
+
* SSH — the Secure Shell Transport Layer Protocol (RFC 4253), carried over TCP well-known port 22.
|
|
10
|
+
*
|
|
11
|
+
* An SSH connection has two shapes on the wire, and this codec handles BOTH:
|
|
12
|
+
*
|
|
13
|
+
* 1. Identification string. The very first thing each side sends is a US-ASCII line
|
|
14
|
+
* `SSH-protoversion-softwareversion[ SP comments]` terminated by CR LF (a lone LF is tolerated),
|
|
15
|
+
* e.g. `SSH-2.0-OpenSSH_9.6\r\n` (also seen: `SSH-1.99-…` for 2.0 servers that also speak 1.x, and
|
|
16
|
+
* legacy `SSH-1.5-…`). Like the other US-ASCII line protocols in this codec (HTTP/SIP/FTP), the
|
|
17
|
+
* structure a form needs is far poorer than the exact bytes a peer sees, so the ENTIRE line is kept
|
|
18
|
+
* verbatim as the authoritative `message` field (hex) and re-emitted untouched; only the first line
|
|
19
|
+
* is parsed on decode into display-only metadata (protoVersion/softwareVersion/identString). Encode
|
|
20
|
+
* never reconstructs the line from those fields — it writes `message` back byte-for-byte.
|
|
21
|
+
*
|
|
22
|
+
* 2. Binary Packet Protocol. After the identifications comes the framed protocol:
|
|
23
|
+
* `packet_length(4, BE) · padding_length(1) · payload(packet_length - padding_length - 1) ·
|
|
24
|
+
* padding(padding_length) · MAC(mac_len)`. The MAC is present only once keys are exchanged; the
|
|
25
|
+
* first binary packet (SSH_MSG_KEXINIT) is sent in cleartext and is readable. This codec keeps the
|
|
26
|
+
* framing minimal and byte-exact: `packet_length` and `padding_length` are structured, editable
|
|
27
|
+
* fields, and everything they bound (payload + padding) is kept verbatim as `data` hex. The packet
|
|
28
|
+
* is bounded by `packet_length + 4` bytes; any MAC/trailing/pipelined bytes are left to the codec's
|
|
29
|
+
* recursion / RawData (decoding the MAC needs cross-message negotiated cipher/MAC state, which is
|
|
30
|
+
* out of scope for a single-message codec). A well-formed message round-trips byte-for-byte.
|
|
31
|
+
*
|
|
32
|
+
* Matching rationale (NO heuristicFallback): SSH is claimed ONLY on the tcp:22 bucket. The
|
|
33
|
+
* identification line has a strong, distinctive signature ("SSH-") — but the Binary Packet Protocol has
|
|
34
|
+
* NO content magic at all (a 4-byte length + a padding byte is indistinguishable from arbitrary binary
|
|
35
|
+
* data), so recognizing binary SSH packets relies entirely on the well-known port. Joining the global
|
|
36
|
+
* content-heuristic chain would therefore let SSH mislabel arbitrary binary TCP payloads on any port.
|
|
37
|
+
* Confining SSH to tcp:22 keeps that impossible; alt-port SSH is rare and falls losslessly to raw.
|
|
38
|
+
*/
|
|
39
|
+
class SSH extends BaseHeader_1.BaseHeader {
|
|
40
|
+
constructor() {
|
|
41
|
+
super(...arguments);
|
|
42
|
+
this.id = 'ssh';
|
|
43
|
+
this.name = 'SSH';
|
|
44
|
+
this.nickname = 'SSH';
|
|
45
|
+
//SSH is recognized ONLY on the well-known port 22 — deliberately NOT via heuristicFallback. The
|
|
46
|
+
//Binary Packet Protocol has no content magic, so its recognition depends entirely on the port
|
|
47
|
+
//bucket; joining the global heuristic chain would mislabel arbitrary binary TCP traffic. See the
|
|
48
|
+
//class doc for the full rationale.
|
|
49
|
+
this.matchKeys = ['tcpport:22'];
|
|
50
|
+
//A leaf header — the SSH payload (KEXINIT contents, encrypted records, MACs) requires cross-message
|
|
51
|
+
//negotiated cipher state and is a higher-layer concern.
|
|
52
|
+
this.demuxProducers = [];
|
|
53
|
+
}
|
|
54
|
+
static #schemaCache;
|
|
55
|
+
get SCHEMA() {
|
|
56
|
+
return (SSH.#schemaCache ??= SSH.#buildSchema());
|
|
57
|
+
}
|
|
58
|
+
/** Bytes available to this header: SSH rides on TCP, which has no per-message length. */
|
|
59
|
+
#payloadLength() {
|
|
60
|
+
const available = this.packet.length - this.startPos;
|
|
61
|
+
return available < 0 ? 0 : available;
|
|
62
|
+
}
|
|
63
|
+
/** True when the payload begins with the ASCII identification signature "SSH-". */
|
|
64
|
+
#isIdentification() {
|
|
65
|
+
if (this.#payloadLength() < 4)
|
|
66
|
+
return false;
|
|
67
|
+
return this.readBytes(0, 4, true).toString('latin1') === 'SSH-';
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Parse the identification line into the display-only metadata fields. The line is
|
|
71
|
+
* `SSH-<protoversion>-<softwareversion>[ SP comments]` and neither protoversion nor softwareversion
|
|
72
|
+
* may contain '-' (RFC 4253 §4.2), so splitting on '-' is exact. Populated on decode only — these
|
|
73
|
+
* fields have no encode, so they never affect the re-emitted bytes and never mutate `message`.
|
|
74
|
+
* Never throws: a malformed banner yields empty strings.
|
|
75
|
+
*/
|
|
76
|
+
#parseIdent(text) {
|
|
77
|
+
//The identification is a single line ended by CR LF (or a lone LF). Keep only up to the first
|
|
78
|
+
//line ending for the display parse; `message` still holds the verbatim bytes.
|
|
79
|
+
let line = text;
|
|
80
|
+
const lf = line.indexOf('\n');
|
|
81
|
+
if (lf >= 0)
|
|
82
|
+
line = line.slice(0, lf);
|
|
83
|
+
if (line.endsWith('\r'))
|
|
84
|
+
line = line.slice(0, -1);
|
|
85
|
+
this.instance.identString.setValue(line);
|
|
86
|
+
//`SSH-` then protoversion up to the next '-', then softwareversion up to a space or end-of-line.
|
|
87
|
+
const match = line.match(/^SSH-([^-]*)-([^ ]*)/);
|
|
88
|
+
const protoVersion = match ? match[1] : '';
|
|
89
|
+
const softwareVersion = match ? match[2] : '';
|
|
90
|
+
this.instance.protoVersion.setValue(protoVersion);
|
|
91
|
+
this.instance.softwareVersion.setValue(softwareVersion);
|
|
92
|
+
this.instance.summaryInfo.setValue(softwareVersion ? softwareVersion : 'identification');
|
|
93
|
+
}
|
|
94
|
+
static #buildSchema() {
|
|
95
|
+
return {
|
|
96
|
+
type: 'object',
|
|
97
|
+
summary: 'SSH ${summaryInfo}',
|
|
98
|
+
properties: {
|
|
99
|
+
//Discriminator between the two on-wire shapes (see class doc). Decoded from the payload
|
|
100
|
+
//signature; on encode it is supplied by the input (default false = a Binary Packet) and
|
|
101
|
+
//read by every field below to decide which bytes it owns.
|
|
102
|
+
isIdentification: {
|
|
103
|
+
type: 'boolean',
|
|
104
|
+
label: 'Is Identification',
|
|
105
|
+
default: false,
|
|
106
|
+
decode: function () {
|
|
107
|
+
this.instance.isIdentification.setValue(this.#isIdentification());
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
//Display-only metadata parsed from the identification line on decode (no encode —
|
|
111
|
+
//populated by `message` below for the identification shape, empty for a binary packet).
|
|
112
|
+
protoVersion: { type: 'string', label: 'Protocol Version', default: '' },
|
|
113
|
+
softwareVersion: { type: 'string', label: 'Software Version', default: '' },
|
|
114
|
+
identString: { type: 'string', label: 'Identification String', default: '' },
|
|
115
|
+
//Drives the one-line summary: the software version for an identification, else 'packet'.
|
|
116
|
+
summaryInfo: { type: 'string', label: 'Summary', hidden: true, default: '' },
|
|
117
|
+
//IDENTIFICATION shape: the whole line kept verbatim (byte-perfect) and re-emitted
|
|
118
|
+
//untouched. The display metadata above is parsed from it on decode; encode never
|
|
119
|
+
//reconstructs the line from that metadata.
|
|
120
|
+
message: {
|
|
121
|
+
type: 'string',
|
|
122
|
+
label: 'Message',
|
|
123
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
124
|
+
default: '',
|
|
125
|
+
decode: function () {
|
|
126
|
+
if (!this.instance.isIdentification.getValue(false)) {
|
|
127
|
+
//Binary Packet shape: no verbatim line; clear the identification metadata.
|
|
128
|
+
this.instance.message.setValue('');
|
|
129
|
+
this.instance.protoVersion.setValue('');
|
|
130
|
+
this.instance.softwareVersion.setValue('');
|
|
131
|
+
this.instance.identString.setValue('');
|
|
132
|
+
this.instance.summaryInfo.setValue('packet');
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const available = this.#payloadLength();
|
|
136
|
+
const raw = this.readBytes(0, available);
|
|
137
|
+
this.instance.message.setValue((0, BufferToHex_1.BufferToHex)(raw));
|
|
138
|
+
this.#parseIdent(raw.toString('latin1'));
|
|
139
|
+
},
|
|
140
|
+
encode: function () {
|
|
141
|
+
//Only the identification shape owns the whole payload; re-emit it verbatim.
|
|
142
|
+
if (!this.instance.isIdentification.getValue(false))
|
|
143
|
+
return;
|
|
144
|
+
this.writeBytes(0, (0, HexToBuffer_1.HexToBuffer)(this.instance.message.getValue('')));
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
//BINARY PACKET shape: packet_length counts padding_length(1) + payload + padding, so the
|
|
148
|
+
//whole message spans packet_length + 4 bytes. Big-endian (unlike ENIP's CIP order).
|
|
149
|
+
packetLength: {
|
|
150
|
+
type: 'integer',
|
|
151
|
+
label: 'Packet Length',
|
|
152
|
+
minimum: 0,
|
|
153
|
+
maximum: 4294967295,
|
|
154
|
+
decode: function () {
|
|
155
|
+
if (this.instance.isIdentification.getValue(false)) {
|
|
156
|
+
this.instance.packetLength.setValue(0);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
this.instance.packetLength.setValue(this.readBytes(0, 4).readUInt32BE(0));
|
|
160
|
+
},
|
|
161
|
+
encode: function () {
|
|
162
|
+
if (this.instance.isIdentification.getValue(false))
|
|
163
|
+
return;
|
|
164
|
+
//Honored when supplied (a crafted message may lie); else derived from the data —
|
|
165
|
+
//packet_length = 1 (padding_length byte) + payload + padding = 1 + data.length.
|
|
166
|
+
const provided = this.instance.packetLength.getValue();
|
|
167
|
+
let value = (provided !== undefined && provided !== null)
|
|
168
|
+
? provided
|
|
169
|
+
: (0, HexToBuffer_1.HexToBuffer)(this.instance.data.getValue('')).length + 1;
|
|
170
|
+
if (value > 4294967295) {
|
|
171
|
+
this.recordError(this.instance.packetLength.getPath(), 'Maximum value is 4294967295');
|
|
172
|
+
value = 4294967295;
|
|
173
|
+
}
|
|
174
|
+
if (value < 0) {
|
|
175
|
+
this.recordError(this.instance.packetLength.getPath(), 'Minimum value is 0');
|
|
176
|
+
value = 0;
|
|
177
|
+
}
|
|
178
|
+
this.instance.packetLength.setValue(value);
|
|
179
|
+
const buffer = Buffer.alloc(4);
|
|
180
|
+
buffer.writeUInt32BE(value, 0);
|
|
181
|
+
this.writeBytes(0, buffer);
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
paddingLength: {
|
|
185
|
+
type: 'integer',
|
|
186
|
+
label: 'Padding Length',
|
|
187
|
+
minimum: 0,
|
|
188
|
+
maximum: 255,
|
|
189
|
+
default: 0,
|
|
190
|
+
decode: function () {
|
|
191
|
+
if (this.instance.isIdentification.getValue(false)) {
|
|
192
|
+
this.instance.paddingLength.setValue(0);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
this.instance.paddingLength.setValue(this.readBytes(4, 1).readUInt8(0));
|
|
196
|
+
},
|
|
197
|
+
encode: function () {
|
|
198
|
+
if (this.instance.isIdentification.getValue(false))
|
|
199
|
+
return;
|
|
200
|
+
const node = this.instance.paddingLength;
|
|
201
|
+
let value = node.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
202
|
+
if (value > 255) {
|
|
203
|
+
this.recordError(node.getPath(), 'Maximum value is 255');
|
|
204
|
+
value = 255;
|
|
205
|
+
}
|
|
206
|
+
if (value < 0) {
|
|
207
|
+
this.recordError(node.getPath(), 'Minimum value is 0');
|
|
208
|
+
value = 0;
|
|
209
|
+
}
|
|
210
|
+
node.setValue(value);
|
|
211
|
+
this.writeBytes(4, Buffer.from([value]));
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
//The payload + padding, kept verbatim. Bounded by packet_length (data ends at offset
|
|
215
|
+
//4 + packet_length) and the captured bytes, so a MAC / trailing / pipelined packet is
|
|
216
|
+
//left to the codec's recursion / RawData.
|
|
217
|
+
data: {
|
|
218
|
+
type: 'string',
|
|
219
|
+
label: 'Data',
|
|
220
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
221
|
+
default: '',
|
|
222
|
+
decode: function () {
|
|
223
|
+
if (this.instance.isIdentification.getValue(false)) {
|
|
224
|
+
this.instance.data.setValue('');
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
const remaining = this.#payloadLength();
|
|
228
|
+
const packetLength = this.instance.packetLength.getValue(0);
|
|
229
|
+
//data spans from offset 5 to 4 + packet_length (i.e. packet_length - 1 bytes).
|
|
230
|
+
let end = 4 + packetLength;
|
|
231
|
+
if (end > remaining)
|
|
232
|
+
end = remaining;
|
|
233
|
+
this.instance.data.setValue(end > 5 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(5, end - 5)) : '');
|
|
234
|
+
},
|
|
235
|
+
encode: function () {
|
|
236
|
+
if (this.instance.isIdentification.getValue(false))
|
|
237
|
+
return;
|
|
238
|
+
const data = this.instance.data.getValue('');
|
|
239
|
+
if (data)
|
|
240
|
+
this.writeBytes(5, (0, HexToBuffer_1.HexToBuffer)(data));
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
match() {
|
|
247
|
+
//Port-bucket + "SSH-" signature. Reached only on the tcp:22 bucket.
|
|
248
|
+
if (!this.prevCodecModule)
|
|
249
|
+
return false;
|
|
250
|
+
if (this.prevCodecModule.id !== 'tcp')
|
|
251
|
+
return false;
|
|
252
|
+
const available = this.#payloadLength();
|
|
253
|
+
if (available < 1)
|
|
254
|
+
return false;
|
|
255
|
+
//Identification string: the strong ASCII signature.
|
|
256
|
+
if (this.#isIdentification())
|
|
257
|
+
return true;
|
|
258
|
+
//Binary Packet Protocol (e.g. a cleartext KEXINIT). No content magic — validate the framing is
|
|
259
|
+
//plausible so genuinely unrelated binary payloads on port 22 still fall through to raw.
|
|
260
|
+
if (available < 6)
|
|
261
|
+
return false;
|
|
262
|
+
const head = this.readBytes(0, 5, true);
|
|
263
|
+
const packetLength = head.readUInt32BE(0);
|
|
264
|
+
const paddingLength = head.readUInt8(4);
|
|
265
|
+
//packet_length counts padding_length(1) + payload + padding; padding is 4..255 (RFC 4253 §6),
|
|
266
|
+
//and 35000 is the minimum max-packet a receiver must support — a generous plausibility ceiling.
|
|
267
|
+
if (packetLength < 5 || packetLength > 35000)
|
|
268
|
+
return false;
|
|
269
|
+
if (paddingLength < 4 || paddingLength > packetLength - 1)
|
|
270
|
+
return false;
|
|
271
|
+
return true;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
exports.SSH = SSH;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* STOMP — the Simple (or Streaming) Text Oriented Messaging Protocol (STOMP 1.2), a text framing for
|
|
6
|
+
* message brokers, carried over TCP (well-known port 61613, the ActiveMQ default). A STOMP frame is
|
|
7
|
+
* US-ASCII text: a COMMAND line, then zero or more `header:value` lines, a blank line, an optional body,
|
|
8
|
+
* and a terminating NUL (0x00):
|
|
9
|
+
*
|
|
10
|
+
* COMMAND{EOL}
|
|
11
|
+
* header1:value1{EOL}
|
|
12
|
+
* header2:value2{EOL}
|
|
13
|
+
* {EOL}
|
|
14
|
+
* body^@
|
|
15
|
+
*
|
|
16
|
+
* where {EOL} is a line feed (STOMP 1.2 also permits CR LF) and ^@ is the NUL octet. Between frames a
|
|
17
|
+
* client/server may send a bare {EOL} as a heartbeat.
|
|
18
|
+
*
|
|
19
|
+
* Like SIP/Ident/HTTP (the verbatim-message pattern): a frame is free-form text — arbitrary header
|
|
20
|
+
* ordering, header-value escaping (\c \n \r \\), and a body of any content-type whose length may be an
|
|
21
|
+
* explicit `content-length` header or run to the NUL — so the exact bytes a peer sees are richer than a
|
|
22
|
+
* form needs and whitespace/ordering is significant. The ENTIRE raw payload is therefore the single
|
|
23
|
+
* source of truth: decoded verbatim to hex in the authoritative `message` field and re-emitted
|
|
24
|
+
* byte-for-byte on encode. On top of that the frame's COMMAND line and a few common display headers
|
|
25
|
+
* (destination, content-type, content-length) are parsed into DISPLAY-ONLY metadata; those carry no
|
|
26
|
+
* codec of their own and never reconstruct the bytes — the message owns them. So any STOMP frame
|
|
27
|
+
* round-trips exactly.
|
|
28
|
+
*
|
|
29
|
+
* Framing: STOMP frames are NUL-terminated and several may be pipelined in one TCP segment, but — like
|
|
30
|
+
* the other text verbatim leaves (SIP/HTTP/Ident) and because TCP carries no per-message length here —
|
|
31
|
+
* this terminal layer consumes to the end of the segment and keeps it as one verbatim `message`. A
|
|
32
|
+
* well-formed single-frame segment round-trips byte-for-byte.
|
|
33
|
+
*
|
|
34
|
+
* Matching rationale (NO heuristicFallback): STOMP is claimed ONLY on the tcp:61613 bucket, and only
|
|
35
|
+
* when the first line is a known STOMP command — a defensive content gate (like SIP's start-line) so
|
|
36
|
+
* non-STOMP traffic on 61613 falls losslessly to raw. Joining the global content-heuristic chain would
|
|
37
|
+
* risk mislabeling arbitrary text TCP payloads on any port, so selection stays port-bucketed.
|
|
38
|
+
*/
|
|
39
|
+
export declare class STOMP extends BaseHeader {
|
|
40
|
+
#private;
|
|
41
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
42
|
+
readonly id: string;
|
|
43
|
+
readonly name: string;
|
|
44
|
+
readonly nickname: string;
|
|
45
|
+
readonly matchKeys: string[];
|
|
46
|
+
match(): boolean;
|
|
47
|
+
readonly demuxProducers: DemuxProducer[];
|
|
48
|
+
}
|