@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,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.NBDS = 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 BufferToNumber_1 = require("../helper/BufferToNumber");
|
|
9
|
+
const NumberToBuffer_1 = require("../helper/NumberToBuffer");
|
|
10
|
+
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
11
|
+
/**
|
|
12
|
+
* NBDS — NetBIOS Datagram Service (RFC 1002 §4.4), the NetBIOS-over-TCP/IP datagram service on UDP 138.
|
|
13
|
+
* Every NBDS packet opens with a fixed 10-byte common prefix — a 1-byte Message Type, a 1-byte Flags
|
|
14
|
+
* octet (MORE/FIRST fragment bits + 2-bit Source End-Node Type + reserved bits), a 2-byte Datagram ID,
|
|
15
|
+
* the 4-byte Source IP and the 2-byte Source Port of the originating node.
|
|
16
|
+
*
|
|
17
|
+
* What follows the prefix depends on the Message Type. The DIRECT_UNIQUE (0x10), DIRECT_GROUP (0x11)
|
|
18
|
+
* and BROADCAST (0x12) datagrams add a 2-byte Datagram Length and a 2-byte Packet Offset (fragmentation
|
|
19
|
+
* offset), then the second-level-encoded Source and Destination NetBIOS names followed by the user data
|
|
20
|
+
* (an SMB mailslot payload, e.g. a browser announcement). DATAGRAM ERROR (0x13) carries a 1-byte error
|
|
21
|
+
* code; the QUERY messages (0x14/0x15/0x16) carry only a destination name. So only the Direct/Broadcast
|
|
22
|
+
* types have the Datagram-Length / Packet-Offset words — they are structured for those types and left out
|
|
23
|
+
* of the byte stream otherwise (mirroring COTP's DT-only fields).
|
|
24
|
+
*
|
|
25
|
+
* The names + user data (for Direct/Broadcast) or the type-specific remainder (for the other types) are
|
|
26
|
+
* kept verbatim as `body` hex, bounded by the UDP payload length so trailing bytes are not absorbed:
|
|
27
|
+
* decoding the second-level NetBIOS names and handing the user data to SMB is a later enrichment. Message
|
|
28
|
+
* Type is stored as the raw octet (fieldUInt — no enum, so a crafted/unknown type still round-trips) and
|
|
29
|
+
* the Datagram Length is honored on encode when supplied, else derived from the body. A well-formed
|
|
30
|
+
* datagram of any type round-trips byte-for-byte.
|
|
31
|
+
*/
|
|
32
|
+
class NBDS extends BaseHeader_1.BaseHeader {
|
|
33
|
+
constructor() {
|
|
34
|
+
super(...arguments);
|
|
35
|
+
this.id = 'nbds';
|
|
36
|
+
this.name = 'NetBIOS Datagram Service';
|
|
37
|
+
this.nickname = 'NBDS';
|
|
38
|
+
this.matchKeys = ['udpport:138'];
|
|
39
|
+
//A leaf header — the NetBIOS names and the SMB mailslot user data are kept verbatim and decoded later.
|
|
40
|
+
this.demuxProducers = [];
|
|
41
|
+
}
|
|
42
|
+
static #schemaCache;
|
|
43
|
+
get SCHEMA() {
|
|
44
|
+
return (_a.#schemaCache ??= _a.#buildSchema());
|
|
45
|
+
}
|
|
46
|
+
/** The DIRECT_UNIQUE / DIRECT_GROUP / BROADCAST types (0x10-0x12) carry the length + offset words and names. */
|
|
47
|
+
static #isDirect(msgType) {
|
|
48
|
+
return msgType >= 0x10 && msgType <= 0x12;
|
|
49
|
+
}
|
|
50
|
+
/** End of this datagram within the captured bytes: bounded by the parent UDP payload (udp.length − 8). */
|
|
51
|
+
#payloadEnd() {
|
|
52
|
+
let end = this.packet.length - this.startPos;
|
|
53
|
+
const prev = this.prevCodecModule;
|
|
54
|
+
if (prev && prev.id === 'udp') {
|
|
55
|
+
const udpLength = prev.instance.length.getValue(0);
|
|
56
|
+
if (udpLength >= 8 && udpLength - 8 < end)
|
|
57
|
+
end = udpLength - 8;
|
|
58
|
+
}
|
|
59
|
+
return end < 0 ? 0 : end;
|
|
60
|
+
}
|
|
61
|
+
/** The offset where the type-specific body begins: after the length/offset words for Direct types, else right after the 10-byte prefix. */
|
|
62
|
+
#bodyStart() {
|
|
63
|
+
return _a.#isDirect(this.instance.msgType.getValue(0)) ? 14 : 10;
|
|
64
|
+
}
|
|
65
|
+
static #buildSchema() {
|
|
66
|
+
return {
|
|
67
|
+
type: 'object',
|
|
68
|
+
summary: 'NBDS type=${msgType} id=${dgmId}',
|
|
69
|
+
properties: {
|
|
70
|
+
//The Message Type octet, kept raw (0x10 DIRECT_UNIQUE, 0x11 DIRECT_GROUP, 0x12 BROADCAST,
|
|
71
|
+
//0x13 DATAGRAM ERROR, 0x14 QUERY REQUEST, 0x15/0x16 QUERY RESPONSE, …). No enum: an unknown
|
|
72
|
+
//or crafted type must still decode and re-encode.
|
|
73
|
+
msgType: this.fieldUInt('msgType', 0, 1, 'Message Type'),
|
|
74
|
+
//The Flags octet, kept whole so the MORE/FIRST fragment bits, the 2-bit Source End-Node
|
|
75
|
+
//Type and the reserved bits all round-trip untouched.
|
|
76
|
+
flags: this.fieldUInt('flags', 1, 1, 'Flags'),
|
|
77
|
+
dgmId: this.fieldUInt('dgmId', 2, 2, 'Datagram ID'),
|
|
78
|
+
sourceIP: this.fieldIPv4('sourceIP', 4, 'Source IP'),
|
|
79
|
+
sourcePort: this.fieldUInt('sourcePort', 8, 2, 'Source Port'),
|
|
80
|
+
//Direct/Broadcast only: the 2-byte Datagram Length — the count of bytes that follow the
|
|
81
|
+
//Packet Offset (the NetBIOS names + user data). Honored on encode when supplied, else
|
|
82
|
+
//derived from the body. Meaningless for other types (not present on the wire — left 0).
|
|
83
|
+
dgmLength: {
|
|
84
|
+
type: 'integer',
|
|
85
|
+
label: 'Datagram Length',
|
|
86
|
+
minimum: 0,
|
|
87
|
+
maximum: 65535,
|
|
88
|
+
decode: function () {
|
|
89
|
+
if (!_a.#isDirect(this.instance.msgType.getValue(0)))
|
|
90
|
+
return;
|
|
91
|
+
this.instance.dgmLength.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(10, 2)));
|
|
92
|
+
},
|
|
93
|
+
encode: function () {
|
|
94
|
+
if (!_a.#isDirect(this.instance.msgType.getValue(0)))
|
|
95
|
+
return;
|
|
96
|
+
const provided = this.instance.dgmLength.getValue();
|
|
97
|
+
let value = (provided !== undefined && provided !== null)
|
|
98
|
+
? provided
|
|
99
|
+
: (0, HexToBuffer_1.HexToBuffer)(this.instance.body.getValue('')).length;
|
|
100
|
+
if (value > 65535) {
|
|
101
|
+
this.recordError(this.instance.dgmLength.getPath(), 'Maximum value is 65535');
|
|
102
|
+
value = 65535;
|
|
103
|
+
}
|
|
104
|
+
this.instance.dgmLength.setValue(value);
|
|
105
|
+
this.writeBytes(10, (0, NumberToBuffer_1.UInt16ToBuffer)(value));
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
//Direct/Broadcast only: the 2-byte Packet Offset (fragmentation offset within the datagram).
|
|
109
|
+
packetOffset: {
|
|
110
|
+
type: 'integer',
|
|
111
|
+
label: 'Packet Offset',
|
|
112
|
+
minimum: 0,
|
|
113
|
+
maximum: 65535,
|
|
114
|
+
decode: function () {
|
|
115
|
+
if (!_a.#isDirect(this.instance.msgType.getValue(0)))
|
|
116
|
+
return;
|
|
117
|
+
this.instance.packetOffset.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(12, 2)));
|
|
118
|
+
},
|
|
119
|
+
encode: function () {
|
|
120
|
+
if (!_a.#isDirect(this.instance.msgType.getValue(0)))
|
|
121
|
+
return;
|
|
122
|
+
let value = this.instance.packetOffset.getValue(0);
|
|
123
|
+
if (value > 65535) {
|
|
124
|
+
this.recordError(this.instance.packetOffset.getPath(), 'Maximum value is 65535');
|
|
125
|
+
value = 65535;
|
|
126
|
+
}
|
|
127
|
+
if (value < 0) {
|
|
128
|
+
this.recordError(this.instance.packetOffset.getPath(), 'Minimum value is 0');
|
|
129
|
+
value = 0;
|
|
130
|
+
}
|
|
131
|
+
this.instance.packetOffset.setValue(value);
|
|
132
|
+
this.writeBytes(12, (0, NumberToBuffer_1.UInt16ToBuffer)(value));
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
//The type-specific remainder kept verbatim: for Direct/Broadcast it is the second-level
|
|
136
|
+
//encoded Source + Destination NetBIOS names followed by the user data (SMB mailslot); for
|
|
137
|
+
//the error/query types it is their small type-specific tail. Bounded by the UDP payload
|
|
138
|
+
//length so any trailing bytes are left to the codec's recursion / RawData.
|
|
139
|
+
body: {
|
|
140
|
+
type: 'string',
|
|
141
|
+
label: 'Body',
|
|
142
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
143
|
+
decode: function () {
|
|
144
|
+
const start = this.#bodyStart();
|
|
145
|
+
const end = this.#payloadEnd();
|
|
146
|
+
this.instance.body.setValue(end > start ? (0, BufferToHex_1.BufferToHex)(this.readBytes(start, end - start)) : '');
|
|
147
|
+
},
|
|
148
|
+
encode: function () {
|
|
149
|
+
const body = this.instance.body.getValue('');
|
|
150
|
+
if (body)
|
|
151
|
+
this.writeBytes(this.#bodyStart(), (0, HexToBuffer_1.HexToBuffer)(body));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
match() {
|
|
158
|
+
//NBDS rides UDP port 138 (selected via the udpport:138 bucket). Port-bucket only, NO
|
|
159
|
+
//heuristicFallback — the header has no strong content signature, so non-NBDS traffic on 138 must
|
|
160
|
+
//fall through to raw. Require at least the 10-byte common prefix within the UDP payload.
|
|
161
|
+
if (!this.prevCodecModule || this.prevCodecModule.id !== 'udp')
|
|
162
|
+
return false;
|
|
163
|
+
const available = this.#payloadEnd();
|
|
164
|
+
if (available < 10)
|
|
165
|
+
return false;
|
|
166
|
+
//Direct/Broadcast types (0x10-0x12) carry a 2-byte Datagram Length + 2-byte Packet Offset that are
|
|
167
|
+
//always re-emitted on encode, so require the full 14-byte fixed header. A shorter direct datagram
|
|
168
|
+
//could not round-trip those words (encode would sprout bytes the wire never had), so leave it to
|
|
169
|
+
//RawData rather than claim it. Non-direct types only need the 10-byte common prefix.
|
|
170
|
+
if (_a.#isDirect(this.readBytes(0, 1, true)[0]) && available < 14)
|
|
171
|
+
return false;
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
exports.NBDS = NBDS;
|
|
176
|
+
_a = NBDS;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { DNS } from './DNS';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
/** A decoded DNS name {value, raw} — mirrors DNS's internal type (value = readable, raw = wire bytes). */
|
|
4
|
+
type DnsName = {
|
|
5
|
+
value: string;
|
|
6
|
+
raw: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* NBNS — NetBIOS Name Service (RFC 1002), the NetBIOS-over-TCP/IP name service on UDP 137. The message
|
|
10
|
+
* uses the DNS wire format (RFC 1035): the same 12-byte header, questions, and resource records with
|
|
11
|
+
* label compression — so it reuses the DNS decode/encode wholesale.
|
|
12
|
+
*
|
|
13
|
+
* The one NBNS-specific twist is the name: a NetBIOS name is a 16-byte value (15-byte name + 1-byte
|
|
14
|
+
* suffix) carried in a single DNS label of length 32 via "first-level encoding" (RFC 1001 §4.1) — each
|
|
15
|
+
* of the 16 bytes is split into two nibbles, each offset by 'A' (0x41) into a printable byte. This
|
|
16
|
+
* subclass overrides readName/writeName to present the readable "NAME<suffix>" form while re-emitting
|
|
17
|
+
* the exact wire bytes (`raw`) for a byte-perfect round-trip; crafting from `value` re-encodes the
|
|
18
|
+
* first-level form. Everything else (header bits, counts, RR structure, compression) is inherited DNS.
|
|
19
|
+
*/
|
|
20
|
+
export declare class NBNS extends DNS {
|
|
21
|
+
#private;
|
|
22
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
23
|
+
protected readName(offset: number): {
|
|
24
|
+
name: DnsName;
|
|
25
|
+
next: number;
|
|
26
|
+
};
|
|
27
|
+
protected writeName(offset: number, name: DnsName | undefined): number;
|
|
28
|
+
readonly id: string;
|
|
29
|
+
readonly name: string;
|
|
30
|
+
readonly nickname: string;
|
|
31
|
+
readonly matchKeys: string[];
|
|
32
|
+
match(): boolean;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NBNS = void 0;
|
|
4
|
+
const DNS_1 = require("./DNS");
|
|
5
|
+
/**
|
|
6
|
+
* NBNS — NetBIOS Name Service (RFC 1002), the NetBIOS-over-TCP/IP name service on UDP 137. The message
|
|
7
|
+
* uses the DNS wire format (RFC 1035): the same 12-byte header, questions, and resource records with
|
|
8
|
+
* label compression — so it reuses the DNS decode/encode wholesale.
|
|
9
|
+
*
|
|
10
|
+
* The one NBNS-specific twist is the name: a NetBIOS name is a 16-byte value (15-byte name + 1-byte
|
|
11
|
+
* suffix) carried in a single DNS label of length 32 via "first-level encoding" (RFC 1001 §4.1) — each
|
|
12
|
+
* of the 16 bytes is split into two nibbles, each offset by 'A' (0x41) into a printable byte. This
|
|
13
|
+
* subclass overrides readName/writeName to present the readable "NAME<suffix>" form while re-emitting
|
|
14
|
+
* the exact wire bytes (`raw`) for a byte-perfect round-trip; crafting from `value` re-encodes the
|
|
15
|
+
* first-level form. Everything else (header bits, counts, RR structure, compression) is inherited DNS.
|
|
16
|
+
*/
|
|
17
|
+
class NBNS extends DNS_1.DNS {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.id = 'nbns';
|
|
21
|
+
this.name = 'NetBIOS Name Service';
|
|
22
|
+
this.nickname = 'NBNS';
|
|
23
|
+
this.matchKeys = ['udpport:137'];
|
|
24
|
+
}
|
|
25
|
+
static #schemaCache;
|
|
26
|
+
get SCHEMA() {
|
|
27
|
+
return (NBNS.#schemaCache ??= { ...super.SCHEMA, summary: 'NBNS ${id} queries=${qdcount} answers=${ancount}' });
|
|
28
|
+
}
|
|
29
|
+
/** Decode a 32-char first-level-encoded label into "NAME<XX>" (suffix in hex). Non-32-char labels pass through. */
|
|
30
|
+
static #decodeNetBIOSName(label) {
|
|
31
|
+
if (label.length !== 32)
|
|
32
|
+
return label;
|
|
33
|
+
const bytes = [];
|
|
34
|
+
for (let i = 0; i < 32; i += 2) {
|
|
35
|
+
const high = (label.charCodeAt(i) - 0x41) & 0x0f;
|
|
36
|
+
const low = (label.charCodeAt(i + 1) - 0x41) & 0x0f;
|
|
37
|
+
bytes.push((high << 4) | low);
|
|
38
|
+
}
|
|
39
|
+
const buffer = Buffer.from(bytes);
|
|
40
|
+
const name = buffer.subarray(0, 15).toString('latin1').replace(/ +$/, '');
|
|
41
|
+
return `${name}<${buffer[15].toString(16).padStart(2, '0')}>`;
|
|
42
|
+
}
|
|
43
|
+
/** Encode "NAME<XX>" back to a 32-char first-level-encoded label. Non-matching values pass through. */
|
|
44
|
+
static #encodeNetBIOSName(value) {
|
|
45
|
+
const match = value.match(/^(.*)<([0-9a-fA-F]{2})>$/);
|
|
46
|
+
if (!match)
|
|
47
|
+
return value;
|
|
48
|
+
const buffer = Buffer.alloc(16, 0x20);
|
|
49
|
+
Buffer.from(match[1], 'latin1').copy(buffer, 0, 0, 15);
|
|
50
|
+
buffer[15] = parseInt(match[2], 16);
|
|
51
|
+
let out = '';
|
|
52
|
+
for (const octet of buffer) {
|
|
53
|
+
out += String.fromCharCode(0x41 + ((octet >> 4) & 0x0f));
|
|
54
|
+
out += String.fromCharCode(0x41 + (octet & 0x0f));
|
|
55
|
+
}
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
readName(offset) {
|
|
59
|
+
const result = super.readName(offset);
|
|
60
|
+
const parts = result.name.value.split('.');
|
|
61
|
+
parts[0] = NBNS.#decodeNetBIOSName(parts[0]);
|
|
62
|
+
return { name: { value: parts.join('.'), raw: result.name.raw }, next: result.next };
|
|
63
|
+
}
|
|
64
|
+
writeName(offset, name) {
|
|
65
|
+
//Byte-perfect for a decoded name: re-emit the exact wire bytes.
|
|
66
|
+
if (name && name.raw)
|
|
67
|
+
return super.writeName(offset, name);
|
|
68
|
+
//Crafted from value: first-level-encode the NetBIOS name label, then let DNS build the labels.
|
|
69
|
+
const value = name && name.value ? name.value : '';
|
|
70
|
+
const parts = value.split('.');
|
|
71
|
+
parts[0] = NBNS.#encodeNetBIOSName(parts[0]);
|
|
72
|
+
return super.writeName(offset, { value: parts.join('.'), raw: '' });
|
|
73
|
+
}
|
|
74
|
+
match() {
|
|
75
|
+
return !!this.prevCodecModule && this.prevCodecModule.id === 'udp';
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.NBNS = NBNS;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* NBSS — NetBIOS Session Service (RFC 1002), TCP port 139. Every session-service PDU begins with a fixed
|
|
6
|
+
* 4-byte header:
|
|
7
|
+
*
|
|
8
|
+
* 0 1 2 3
|
|
9
|
+
* +-------------- -+---------------+-------------------------------+
|
|
10
|
+
* | TYPE | FLAGS |E| LENGTH |
|
|
11
|
+
* +---------------+---------------+-------------------------------+
|
|
12
|
+
*
|
|
13
|
+
* TYPE (1 byte) names the PDU (0x00 Session Message, 0x81 Session Request, 0x82/0x83 Positive/Negative
|
|
14
|
+
* Session Response, 0x84 Retarget, 0x85 Keep Alive). FLAGS (1 byte) is seven reserved bits plus an
|
|
15
|
+
* Extension bit E in its least-significant position — E is bit 16 (the high-order bit) of a 17-bit LENGTH
|
|
16
|
+
* whose low 16 bits are the following 2-byte field. So the trailer byte count is
|
|
17
|
+
* ((FLAGS & 0x01) << 16) | LENGTH16, and the payload (an SMB message for a Session Message, the encoded
|
|
18
|
+
* Called/Calling NetBIOS names for a Session Request, empty for Keep Alive / responses) follows the header.
|
|
19
|
+
*
|
|
20
|
+
* Byte-perfect strategy: structure type + flags (both verbatim, so the reserved bits and the E bit
|
|
21
|
+
* round-trip exactly) + the 16-bit length, and keep the payload verbatim as `payload` hex bounded by the
|
|
22
|
+
* 17-bit length. The length is honored when supplied (a crafted PDU may lie) else derived from the actual
|
|
23
|
+
* payload byte count; the payload is bounded by the length so a second pipelined PDU or Ethernet padding is
|
|
24
|
+
* left to the codec's recursion / RawData. Sub-decoding the SMB payload / the NetBIOS names is a later
|
|
25
|
+
* enrichment. A well-formed PDU round-trips byte-for-byte.
|
|
26
|
+
*/
|
|
27
|
+
export declare class NBSS extends BaseHeader {
|
|
28
|
+
#private;
|
|
29
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
30
|
+
readonly id: string;
|
|
31
|
+
readonly name: string;
|
|
32
|
+
readonly nickname: string;
|
|
33
|
+
readonly matchKeys: string[];
|
|
34
|
+
match(): boolean;
|
|
35
|
+
readonly demuxProducers: DemuxProducer[];
|
|
36
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NBSS = 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
|
+
* The valid NetBIOS Session Service packet types (RFC 1002 §4.3.1): 0x00 Session Message,
|
|
12
|
+
* 0x81 Session Request, 0x82 Positive Session Response, 0x83 Negative Session Response,
|
|
13
|
+
* 0x84 Retarget Response, 0x85 Session Keep Alive. Used as the match() signature on port 139.
|
|
14
|
+
*/
|
|
15
|
+
const NBSS_TYPES = new Set([0x00, 0x81, 0x82, 0x83, 0x84, 0x85]);
|
|
16
|
+
/**
|
|
17
|
+
* NBSS — NetBIOS Session Service (RFC 1002), TCP port 139. Every session-service PDU begins with a fixed
|
|
18
|
+
* 4-byte header:
|
|
19
|
+
*
|
|
20
|
+
* 0 1 2 3
|
|
21
|
+
* +-------------- -+---------------+-------------------------------+
|
|
22
|
+
* | TYPE | FLAGS |E| LENGTH |
|
|
23
|
+
* +---------------+---------------+-------------------------------+
|
|
24
|
+
*
|
|
25
|
+
* TYPE (1 byte) names the PDU (0x00 Session Message, 0x81 Session Request, 0x82/0x83 Positive/Negative
|
|
26
|
+
* Session Response, 0x84 Retarget, 0x85 Keep Alive). FLAGS (1 byte) is seven reserved bits plus an
|
|
27
|
+
* Extension bit E in its least-significant position — E is bit 16 (the high-order bit) of a 17-bit LENGTH
|
|
28
|
+
* whose low 16 bits are the following 2-byte field. So the trailer byte count is
|
|
29
|
+
* ((FLAGS & 0x01) << 16) | LENGTH16, and the payload (an SMB message for a Session Message, the encoded
|
|
30
|
+
* Called/Calling NetBIOS names for a Session Request, empty for Keep Alive / responses) follows the header.
|
|
31
|
+
*
|
|
32
|
+
* Byte-perfect strategy: structure type + flags (both verbatim, so the reserved bits and the E bit
|
|
33
|
+
* round-trip exactly) + the 16-bit length, and keep the payload verbatim as `payload` hex bounded by the
|
|
34
|
+
* 17-bit length. The length is honored when supplied (a crafted PDU may lie) else derived from the actual
|
|
35
|
+
* payload byte count; the payload is bounded by the length so a second pipelined PDU or Ethernet padding is
|
|
36
|
+
* left to the codec's recursion / RawData. Sub-decoding the SMB payload / the NetBIOS names is a later
|
|
37
|
+
* enrichment. A well-formed PDU round-trips byte-for-byte.
|
|
38
|
+
*/
|
|
39
|
+
class NBSS extends BaseHeader_1.BaseHeader {
|
|
40
|
+
constructor() {
|
|
41
|
+
super(...arguments);
|
|
42
|
+
this.id = 'nbss';
|
|
43
|
+
this.name = 'NetBIOS Session Service';
|
|
44
|
+
this.nickname = 'NBSS';
|
|
45
|
+
this.matchKeys = ['tcpport:139'];
|
|
46
|
+
//A leaf header — the SMB payload / the encoded NetBIOS names are kept verbatim for now.
|
|
47
|
+
this.demuxProducers = [];
|
|
48
|
+
}
|
|
49
|
+
static #schemaCache;
|
|
50
|
+
get SCHEMA() {
|
|
51
|
+
return (NBSS.#schemaCache ??= NBSS.#buildSchema());
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The 17-bit trailer byte count = the Extension bit E (FLAGS bit 0) as bit 16, plus the 16-bit LENGTH.
|
|
55
|
+
* Read dry-run so it can be used to bound the payload without disturbing the decoded header length.
|
|
56
|
+
*/
|
|
57
|
+
#declaredLength() {
|
|
58
|
+
const flags = this.readBytes(1, 1, true)[0];
|
|
59
|
+
const low16 = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2, true));
|
|
60
|
+
return ((flags & 0x01) * 0x10000) + low16;
|
|
61
|
+
}
|
|
62
|
+
static #buildSchema() {
|
|
63
|
+
return {
|
|
64
|
+
type: 'object',
|
|
65
|
+
summary: 'NBSS type=${type} len=${length}',
|
|
66
|
+
properties: {
|
|
67
|
+
//0x00 Session Message, 0x81 Session Request, 0x82/0x83 Positive/Negative Response,
|
|
68
|
+
//0x84 Retarget, 0x85 Keep Alive. Kept verbatim.
|
|
69
|
+
type: this.fieldUInt('type', 0, 1, 'Type'),
|
|
70
|
+
//Seven reserved bits + the Extension bit E in the LSB (bit 16 of the 17-bit length). Kept
|
|
71
|
+
//verbatim so the reserved bits and E round-trip; the payload boundary reads E from here.
|
|
72
|
+
flags: this.fieldUInt('flags', 1, 1, 'Flags'),
|
|
73
|
+
length: {
|
|
74
|
+
type: 'integer',
|
|
75
|
+
label: 'Length',
|
|
76
|
+
minimum: 0,
|
|
77
|
+
maximum: 65535,
|
|
78
|
+
decode: function () {
|
|
79
|
+
this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
|
|
80
|
+
},
|
|
81
|
+
encode: function () {
|
|
82
|
+
//The low 16 bits of the trailer byte count. Honored when supplied (a crafted PDU may
|
|
83
|
+
//lie); else derived from the actual payload length (its low 16 bits — the E bit lives
|
|
84
|
+
//in the verbatim FLAGS byte and is not synthesized here).
|
|
85
|
+
const provided = this.instance.length.getValue();
|
|
86
|
+
let value = (provided !== undefined && provided !== null)
|
|
87
|
+
? provided
|
|
88
|
+
: (0, HexToBuffer_1.HexToBuffer)(this.instance.payload.getValue('')).length % 0x10000;
|
|
89
|
+
if (value > 65535) {
|
|
90
|
+
this.recordError(this.instance.length.getPath(), 'Maximum value is 65535');
|
|
91
|
+
value = 65535;
|
|
92
|
+
}
|
|
93
|
+
if (value < 0) {
|
|
94
|
+
this.recordError(this.instance.length.getPath(), 'Minimum value is 0');
|
|
95
|
+
value = 0;
|
|
96
|
+
}
|
|
97
|
+
this.instance.length.setValue(value);
|
|
98
|
+
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(value));
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
//The PDU payload after the 4-byte header, kept verbatim. Bounded by the 17-bit declared
|
|
102
|
+
//length and the captured bytes, so trailing / pipelined PDUs and Ethernet padding are left
|
|
103
|
+
//to the codec's recursion / RawData (never read to the buffer end).
|
|
104
|
+
payload: {
|
|
105
|
+
type: 'string',
|
|
106
|
+
label: 'Payload',
|
|
107
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
108
|
+
decode: function () {
|
|
109
|
+
const remaining = this.packet.length - this.startPos - 4;
|
|
110
|
+
let length = this.#declaredLength();
|
|
111
|
+
if (length > remaining)
|
|
112
|
+
length = remaining;
|
|
113
|
+
this.instance.payload.setValue(length > 0 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(4, length)) : '');
|
|
114
|
+
},
|
|
115
|
+
encode: function () {
|
|
116
|
+
const payload = this.instance.payload.getValue('');
|
|
117
|
+
if (payload)
|
|
118
|
+
this.writeBytes(4, (0, HexToBuffer_1.HexToBuffer)(payload));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
match() {
|
|
125
|
+
//NBSS rides on TCP port 139 (selected via the tcpport:139 bucket). This stays a port-bucket
|
|
126
|
+
//protocol: matchKeys only, NO heuristicFallback — a single valid type byte is too weak a signature
|
|
127
|
+
//to claim NBSS off port 139, and non-NBSS traffic on 139 must fall through to raw. Require the full
|
|
128
|
+
//4-byte header within the captured bytes and a recognized packet type.
|
|
129
|
+
if (!this.prevCodecModule || this.prevCodecModule.id !== 'tcp')
|
|
130
|
+
return false;
|
|
131
|
+
if (this.packet.length - this.startPos < 4)
|
|
132
|
+
return false;
|
|
133
|
+
const type = this.readBytes(0, 1, true)[0];
|
|
134
|
+
return NBSS_TYPES.has(type);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.NBSS = NBSS;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* Network File System (NFS, RFC 1813 v3 / RFC 7530 v4), TCP + UDP port 2049. NFS is carried inside an
|
|
6
|
+
* ONC RPC (RFC 5531) message, so on the wire an NFS packet is a plain RPC message: a 4-byte XID followed
|
|
7
|
+
* by a 4-byte Message Type (0 CALL, 1 REPLY). A CALL body continues with the RPC version (== 2), the
|
|
8
|
+
* program number (NFS = 100003), the program version, the procedure, then the credential + verifier auth
|
|
9
|
+
* structures and the NFS procedure arguments. NFS parses this RPC envelope itself at its 2049 port bucket
|
|
10
|
+
* (it does not depend on the SunRPC header, which is scoped to the portmapper's port 111).
|
|
11
|
+
*
|
|
12
|
+
* Transport framing differs by L4 (RFC 5531 §11): over UDP the RPC message is the whole datagram; over
|
|
13
|
+
* TCP a 4-byte Record Marking prefix precedes it — the high bit is the last-fragment flag and the low 31
|
|
14
|
+
* bits are the fragment length. This header detects the transport via prevCodecModule.id and structures
|
|
15
|
+
* accordingly: TCP → recordMark (lastFragment + fragmentLength) then the message at offset 4; UDP → the
|
|
16
|
+
* message directly at offset 0.
|
|
17
|
+
*
|
|
18
|
+
* Byte-perfect strategy (minimal slice): structure the XID and Message Type, and for a CALL the four
|
|
19
|
+
* fixed program-identity words (rpcVersion / program / programVersion / procedure); the remainder — the
|
|
20
|
+
* credential, verifier and NFS procedure arguments for a CALL, or the whole REPLY body — is kept verbatim
|
|
21
|
+
* as `body` hex, bounded by the transport payload (UDP length − 8, or the TCP Record Marking fragment
|
|
22
|
+
* length). The TCP fragmentLength is honored when supplied (a crafted frame may lie) else derived as the
|
|
23
|
+
* encoded message length; a well-formed message round-trips byte-for-byte. Trailing / pipelined bytes are
|
|
24
|
+
* left to the codec's recursion / RawData. Sub-decoding the per-procedure NFS argument/reply structures
|
|
25
|
+
* (GETATTR fh, LOOKUP dir+name, READ/WRITE, …) is a later enrichment.
|
|
26
|
+
*/
|
|
27
|
+
export declare class NFS extends BaseHeader {
|
|
28
|
+
#private;
|
|
29
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
30
|
+
readonly id: string;
|
|
31
|
+
readonly name: string;
|
|
32
|
+
readonly nickname: string;
|
|
33
|
+
readonly matchKeys: string[];
|
|
34
|
+
match(): boolean;
|
|
35
|
+
readonly demuxProducers: DemuxProducer[];
|
|
36
|
+
}
|