diff --git a/README.md b/README.md index 299b5d87..c0996378 100755 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ [](https://travis-ci.org/gchq/CyberChef) [](https://david-dm.org/gchq/CyberChef) [](https://www.npmjs.com/package/cyberchef) - [](https://github.com/gchq/CyberChef/blob/master/LICENSE) [](https://gitter.im/gchq/CyberChef?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) diff --git a/src/core/operations/ParseUDP.mjs b/src/core/operations/ParseUDP.mjs index 234a08f6..0a88fd5d 100644 --- a/src/core/operations/ParseUDP.mjs +++ b/src/core/operations/ParseUDP.mjs @@ -24,37 +24,35 @@ class ParseUDP extends Operation { this.module = "Default"; this.description = "Parses a UDP header and payload (if present)."; this.infoURL = "https://wikipedia.org/wiki/User_Datagram_Protocol"; - this.inputType = "byteArray"; + this.inputType = "ArrayBuffer"; this.outputType = "json"; this.presentType = "html"; this.args = []; } /** - * @param {Uint8Array} input + * @param {ArrayBuffer} input * @returns {Object} */ run(input, args) { - - if (input.length < "8"){ + if (input.byteLength < 8) { throw new OperationError("Need 8 bytes for a UDP Header"); } - const s = new Stream(input); - //Parse Header + const s = new Stream(new Uint8Array(input)); + // Parse Header const UDPPacket = { "Source port": s.readInt(2), "Destination port": s.readInt(2), "Length": s.readInt(2), - "Checksum": toHex(s.getBytes(2), "0x") + "Checksum": toHex(s.getBytes(2), "") }; - //Parse data if present - if (s.hasMore()){ - UDPPacket.Data = toHex(s.getBytes(UDPPacket.Length - 8), "0x"); + // Parse data if present + if (s.hasMore()) { + UDPPacket.Data = toHex(s.getBytes(UDPPacket.Length - 8), ""); } return UDPPacket; - } /** @@ -64,21 +62,17 @@ class ParseUDP extends Operation { */ present(data) { const html = []; - html.push("
Field | "); html.push("Value | "); html.push("
---|---|
" + key + " | "); - html.push("" + data[key] + " | "); - html.push("
" + key + " | "); + html.push("" + data[key] + " | "); + html.push("