diff --git a/.travis.yml b/.travis.yml index 3cfad188..a67e99b4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ language: node_js node_js: - lts/dubnium cache: npm +os: linux addons: chrome: stable install: npm install @@ -19,16 +20,16 @@ before_deploy: - grunt copy:ghPages deploy: - provider: pages - skip_cleanup: true - github_token: $GITHUB_TOKEN + edge: true + token: $GITHUB_TOKEN local_dir: build/prod/ target_branch: gh-pages on: repo: gchq/CyberChef branch: master - provider: releases - skip_cleanup: true - api_key: + edge: true + token: secure: "HV1WSKv4l/0Y2bKKs1iBJocBcmLj08PCRUeEM/jTwA4jqJ8EiLHWiXtER/D5sEg2iibRVKd2OQjfrmS6bo4AiwdeVgAKmv0FtS2Jw+391N8Nd5AkEANHa5Om/IpHLTL2YRAjpJTsDpY72bMUTJIwjQA3TFJkgrpOw6KYfohOcgbxLpZ4XuNJRU3VL4Hsxdv5V9aOVmfFOmMOVPQlakXy7NgtW5POp1f2WJwgcZxylkR1CjwaqMyXmSoVl46pyH3tr5+dptsQoKSGdi6sIHGA60oDotFPcm+0ifa47wZw+vapuuDi4tdNxhrHGaDMG8xiE0WFDHwQUDlk2/+W7j9SEX0H3Em7us371JXRp56EDwEcDa34VpVkC6i8HGcHK55hnxVbMZXGf3qhOFD8wY7qMbjMRvIpucrMHBi86OfkDfv0vDj2LyvIl5APj/AX50BrE0tfH1MZbH26Jkx4NdlkcxQ14GumarmUqfmVvbX/fsoA6oUuAAE9ZgRRi3KHO4wci6KUcRfdm+XOeUkaBFsL86G3EEYIvrtBTuaypdz+Cx7nd1iPZyWMx5Y1gXnVzha4nBdV4+7l9JIsFggD8QVpw2uHXQiS1KXFjOeqA3DBD8tjMB7q26Fl2fD3jkOo4BTbQ2NrRIZUu/iL+fOmMPsyMt2qulB0yaSBCfkbEq8xrUA=" file_glob: true file: @@ -38,9 +39,9 @@ deploy: repo: gchq/CyberChef tags: true - provider: npm - skip_cleanup: true + edge: true email: "n1474335@gmail.com" - api_key: + api_token: secure: "UnDQL3Kh+GK2toL0TK3FObO0ujVssU3Eg4BBuYdjwLB81GhiGE5/DTh7THdZPOpbLo6wQeOwfZDuMeKC1OU+0Uf4NsdYFu1aq6xMO20qBQ4qUfgsyiK4Qgywj9gk0p1+OFZdGAZ/j1CNRAaF71XQIY6iV84c+SO4WoizXYrNT0Jh4sr2DA4/97G2xmJtPi0qOzYrJ09R56ZUozmqeik5G0pMRIuJRbpjS/7bZXV+N7WV0ombZc9RkUaetbabEVOLQ+Xx5YAIVq+VuEeMe9VBSnxY/FfCLmy1wJsjGzpLCyBI9nbrG4nw8Wgc2m8NfK9rcpIvBTGner9r2j60NVDkZ8kLZPrqXhq6AZMwa+oz6K5UQCqRo2RRQzSGwXxg67HY5Tcq+oNmjd+DqpPg4LZ3eGlluyP5XfG+hpSr9Ya4d8q8SrUWLxkoLHI6ZKMtoKFbTCSSQPiluW5hsZxjz3yDkkjsJw64M/EM8UyJrgaXqDklQu+7rBGKLfsK6os7RDiqjBWpQ7gwpo8HvY0O8yqEAabPz+QGkanpjcCOZCXFbSkzWxYy37RMAPu88iINVZVlZE4l+WJenCpZY95ueyy0mG9cyMSzVRPyX6A+/n4H6VMFPFjpGDLTD588ACEjY1lmHfS/eXwXJcgqPPD2gW0XdRdUheU/ssqlfCfGWQMTDXs=" on: tags: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 00c96618..55de1b0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ All major and minor version changes will be documented in this file. Details of patch-level version changes can be found in [commit messages](https://github.com/gchq/CyberChef/commits/master). +### [9.13.0] - 2020-02-13 +- 'Rail Fence Cipher Encode' and 'Rail Fence Cipher Decode' operations added [@Flavsditz] | [#948] + ### [9.12.0] - 2019-12-20 - 'Normalise Unicode' operation added [@matthieuxyz] | [#912] @@ -200,6 +203,10 @@ All major and minor version changes will be documented in this file. Details of +<<<<<<< HEAD +======= +[9.13.0]: https://github.com/gchq/CyberChef/releases/tag/v9.13.0 +>>>>>>> d78730edc0fcb9a03670ad7795908313e86002d6 [9.12.0]: https://github.com/gchq/CyberChef/releases/tag/v9.12.0 [9.11.0]: https://github.com/gchq/CyberChef/releases/tag/v9.11.0 [9.10.0]: https://github.com/gchq/CyberChef/releases/tag/v9.10.0 @@ -286,6 +293,10 @@ All major and minor version changes will be documented in this file. Details of [@VirtualColossus]: https://github.com/VirtualColossus [@cbeuw]: https://github.com/cbeuw [@matthieuxyz]: https://github.com/matthieuxyz +<<<<<<< HEAD +======= +[@Flavsditz]: https://github.com/Flavsditz +>>>>>>> d78730edc0fcb9a03670ad7795908313e86002d6 [#95]: https://github.com/gchq/CyberChef/pull/299 [#173]: https://github.com/gchq/CyberChef/pull/173 @@ -350,3 +361,7 @@ All major and minor version changes will be documented in this file. Details of [#653]: https://github.com/gchq/CyberChef/pull/653 [#865]: https://github.com/gchq/CyberChef/pull/865 [#912]: https://github.com/gchq/CyberChef/pull/912 +<<<<<<< HEAD +======= +[#948]: https://github.com/gchq/CyberChef/pull/948 +>>>>>>> d78730edc0fcb9a03670ad7795908313e86002d6 diff --git a/Gruntfile.js b/Gruntfile.js index e72bb238..1a9e3f2f 100755 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -219,6 +219,7 @@ module.exports = function (grunt) { options: { webpack: webpackConfig, host: "0.0.0.0", + port: grunt.option("port") || 8080, disableHostCheck: true, overlay: true, inline: false, @@ -275,7 +276,7 @@ module.exports = function (grunt) { connect: { prod: { options: { - port: 8000, + port: grunt.option("port") || 8000, base: "build/prod/" } } @@ -395,7 +396,7 @@ module.exports = function (grunt) { }, setupNodeConsumers: { command: chainCommands([ - "echo '\n--- Testing node conumers ---'", + "echo '\n--- Testing node consumers ---'", "npm link", `mkdir ${nodeConsumerTestPath}`, `cp tests/node/consumers/* ${nodeConsumerTestPath}`, diff --git a/package-lock.json b/package-lock.json index 22fa07df..fc13e8ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "cyberchef", - "version": "9.12.0", + "version": "9.13.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -7378,27 +7378,27 @@ "dependencies": { "abbrev": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "resolved": false, "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", "dev": true, "optional": true }, "ansi-regex": { "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "resolved": false, "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", "dev": true }, "aproba": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", + "resolved": false, "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", "dev": true, "optional": true }, "are-we-there-yet": { "version": "1.1.5", - "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz", + "resolved": false, "integrity": "sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w==", "dev": true, "optional": true, @@ -7409,13 +7409,13 @@ }, "balanced-match": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "resolved": false, "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, "brace-expansion": { "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "resolved": false, "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { @@ -7425,39 +7425,39 @@ }, "chownr": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz", + "resolved": false, "integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==", "dev": true, "optional": true }, "code-point-at": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "resolved": false, "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", "dev": true }, "concat-map": { "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "resolved": false, "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, "console-control-strings": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "resolved": false, "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", "dev": true }, "core-util-is": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "resolved": false, "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true, "optional": true }, "debug": { "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "resolved": false, "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", "dev": true, "optional": true, @@ -7467,28 +7467,28 @@ }, "deep-extend": { "version": "0.6.0", - "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "resolved": false, "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", "dev": true, "optional": true }, "delegates": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "resolved": false, "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", "dev": true, "optional": true }, "detect-libc": { "version": "1.0.3", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", + "resolved": false, "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=", "dev": true, "optional": true }, "fs-minipass": { "version": "1.2.5", - "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.5.tgz", + "resolved": false, "integrity": "sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ==", "dev": true, "optional": true, @@ -7498,14 +7498,14 @@ }, "fs.realpath": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "resolved": false, "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true, "optional": true }, "gauge": { "version": "2.7.4", - "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", + "resolved": false, "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", "dev": true, "optional": true, @@ -7522,7 +7522,7 @@ }, "glob": { "version": "7.1.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "resolved": false, "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", "dev": true, "optional": true, @@ -7537,14 +7537,14 @@ }, "has-unicode": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "resolved": false, "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", "dev": true, "optional": true }, "iconv-lite": { "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "resolved": false, "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", "dev": true, "optional": true, @@ -7554,7 +7554,7 @@ }, "ignore-walk": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.1.tgz", + "resolved": false, "integrity": "sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ==", "dev": true, "optional": true, @@ -7564,7 +7564,7 @@ }, "inflight": { "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "resolved": false, "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, "optional": true, @@ -7575,20 +7575,20 @@ }, "inherits": { "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "resolved": false, "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, "ini": { "version": "1.3.5", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", + "resolved": false, "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true, "optional": true }, "is-fullwidth-code-point": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "resolved": false, "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, "requires": { @@ -7597,14 +7597,14 @@ }, "isarray": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "resolved": false, "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "dev": true, "optional": true }, "minimatch": { "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "resolved": false, "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { @@ -7613,13 +7613,13 @@ }, "minimist": { "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "resolved": false, "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "dev": true }, "minipass": { "version": "2.3.5", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", + "resolved": false, "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", "dev": true, "requires": { @@ -7629,7 +7629,7 @@ }, "minizlib": { "version": "1.2.1", - "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.1.tgz", + "resolved": false, "integrity": "sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==", "dev": true, "optional": true, @@ -7639,7 +7639,7 @@ }, "mkdirp": { "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "resolved": false, "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, "requires": { @@ -7648,14 +7648,14 @@ }, "ms": { "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "resolved": false, "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", "dev": true, "optional": true }, "needle": { "version": "2.3.0", - "resolved": "https://registry.npmjs.org/needle/-/needle-2.3.0.tgz", + "resolved": false, "integrity": "sha512-QBZu7aAFR0522EyaXZM0FZ9GLpq6lvQ3uq8gteiDUp7wKdy0lSd2hPlgFwVuW1CBkfEs9PfDQsQzZghLs/psdg==", "dev": true, "optional": true, @@ -7667,7 +7667,7 @@ }, "node-pre-gyp": { "version": "0.12.0", - "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.12.0.tgz", + "resolved": false, "integrity": "sha512-4KghwV8vH5k+g2ylT+sLTjy5wmUOb9vPhnM8NHvRf9dHmnW/CndrFXy2aRPaPST6dugXSdHXfeaHQm77PIz/1A==", "dev": true, "optional": true, @@ -7686,7 +7686,7 @@ }, "nopt": { "version": "4.0.1", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", + "resolved": false, "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", "dev": true, "optional": true, @@ -7697,14 +7697,14 @@ }, "npm-bundled": { "version": "1.0.6", - "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.6.tgz", + "resolved": false, "integrity": "sha512-8/JCaftHwbd//k6y2rEWp6k1wxVfpFzB6t1p825+cUb7Ym2XQfhwIC5KwhrvzZRJu+LtDE585zVaS32+CGtf0g==", "dev": true, "optional": true }, "npm-packlist": { "version": "1.4.1", - "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.4.1.tgz", + "resolved": false, "integrity": "sha512-+TcdO7HJJ8peiiYhvPxsEDhF3PJFGUGRcFsGve3vxvxdcpO2Z4Z7rkosRM0kWj6LfbK/P0gu3dzk5RU1ffvFcw==", "dev": true, "optional": true, @@ -7715,7 +7715,7 @@ }, "npmlog": { "version": "4.1.2", - "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", + "resolved": false, "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", "dev": true, "optional": true, @@ -7728,20 +7728,20 @@ }, "number-is-nan": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "resolved": false, "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", "dev": true }, "object-assign": { "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "resolved": false, "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", "dev": true, "optional": true }, "once": { "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "resolved": false, "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, "requires": { @@ -7750,21 +7750,21 @@ }, "os-homedir": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "resolved": false, "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", "dev": true, "optional": true }, "os-tmpdir": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "resolved": false, "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", "dev": true, "optional": true }, "osenv": { "version": "0.1.5", - "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", + "resolved": false, "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", "dev": true, "optional": true, @@ -7775,21 +7775,21 @@ }, "path-is-absolute": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "resolved": false, "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true, "optional": true }, "process-nextick-args": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "resolved": false, "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true, "optional": true }, "rc": { "version": "1.2.8", - "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "resolved": false, "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", "dev": true, "optional": true, @@ -7802,7 +7802,7 @@ "dependencies": { "minimist": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": false, "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true, "optional": true @@ -7811,7 +7811,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": false, "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "optional": true, @@ -7827,7 +7827,7 @@ }, "rimraf": { "version": "2.6.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "resolved": false, "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", "dev": true, "optional": true, @@ -7837,48 +7837,48 @@ }, "safe-buffer": { "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "resolved": false, "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "dev": true }, "safer-buffer": { "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "resolved": false, "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true, "optional": true }, "sax": { "version": "1.2.4", - "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "resolved": false, "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", "dev": true, "optional": true }, "semver": { "version": "5.7.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", + "resolved": false, "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", "dev": true, "optional": true }, "set-blocking": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "resolved": false, "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", "dev": true, "optional": true }, "signal-exit": { "version": "3.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "resolved": false, "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", "dev": true, "optional": true }, "string-width": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "resolved": false, "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, "requires": { @@ -7889,7 +7889,7 @@ }, "string_decoder": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "resolved": false, "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "optional": true, @@ -7899,7 +7899,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": false, "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { @@ -7908,14 +7908,14 @@ }, "strip-json-comments": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "resolved": false, "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", "dev": true, "optional": true }, "tar": { "version": "4.4.8", - "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.8.tgz", + "resolved": false, "integrity": "sha512-LzHF64s5chPQQS0IYBn9IN5h3i98c12bo4NCO7e0sGM2llXQ3p2FGC5sdENN4cTW48O915Sh+x+EXx7XW96xYQ==", "dev": true, "optional": true, @@ -7931,14 +7931,14 @@ }, "util-deprecate": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "resolved": false, "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true, "optional": true }, "wide-align": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "resolved": false, "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", "dev": true, "optional": true, @@ -7948,13 +7948,13 @@ }, "wrappy": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "resolved": false, "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, "yallist": { "version": "3.0.3", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", + "resolved": false, "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", "dev": true } @@ -11018,9 +11018,9 @@ "dev": true }, "nightwatch": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/nightwatch/-/nightwatch-1.3.2.tgz", - "integrity": "sha512-1Lcte2Su/JrzET62va4oVLbSXwZkZaTmxTdjShylio3U+woY6U250iNuQz/bOkL+Qvuw+9Vfp+5T13yT0YfsKg==", + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/nightwatch/-/nightwatch-1.3.4.tgz", + "integrity": "sha512-27zWPjmBsHu3IDKc6QTQdRKbTWx4WuTUXbCOT1Wa8Ovxbv+3TZ7GCd9Dt9wm14ElO9Db9/PKVk8JIWThkqGRZA==", "dev": true, "requires": { "assertion-error": "^1.1.0", @@ -11631,9 +11631,9 @@ "dev": true }, "ansi-styles": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.0.tgz", - "integrity": "sha512-7kFQgnEaMdRtwf6uSfUnVr9gSGC7faurn+J/Mv90/W+iTtN0405/nLdopfMWwchyxhbGYl6TC4Sccn9TUkGAgg==", + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", "dev": true, "requires": { "@types/color-name": "^1.1.1", diff --git a/package.json b/package.json index 3fc722a2..63b6f1d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cyberchef", - "version": "9.12.0", + "version": "9.13.1", "description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.", "author": "n1474335 ", "homepage": "https://gchq.github.io/CyberChef", @@ -65,7 +65,7 @@ "html-webpack-plugin": "^3.2.0", "imports-loader": "^0.8.0", "mini-css-extract-plugin": "^0.8.0", - "nightwatch": "^1.3.2", + "nightwatch": "^1.3.4", "node-sass": "^4.13.0", "postcss-css-variables": "^0.14.0", "postcss-import": "^12.0.1", diff --git a/src/core/Ingredient.mjs b/src/core/Ingredient.mjs index f74b42d6..d64bf763 100755 --- a/src/core/Ingredient.mjs +++ b/src/core/Ingredient.mjs @@ -113,6 +113,7 @@ class Ingredient { return data; } case "number": + if (data === null) return data; number = parseFloat(data); if (isNaN(number)) { const sample = Utils.truncate(data.toString(), 10); diff --git a/src/core/config/Categories.json b/src/core/config/Categories.json index ba4bb49d..0d68efe8 100755 --- a/src/core/config/Categories.json +++ b/src/core/config/Categories.json @@ -95,6 +95,8 @@ "Affine Cipher Decode", "A1Z26 Cipher Encode", "A1Z26 Cipher Decode", + "Rail Fence Cipher Encode", + "Rail Fence Cipher Decode", "Atbash Cipher", "Substitute", "Derive PBKDF2 key", @@ -111,7 +113,7 @@ "Bombe", "Multiple Bombe", "Typex", - "Lorenz Encode" + "Lorenz" ] }, { diff --git a/src/core/lib/FileSignatures.mjs b/src/core/lib/FileSignatures.mjs index cc48550f..8d57797e 100644 --- a/src/core/lib/FileSignatures.mjs +++ b/src/core/lib/FileSignatures.mjs @@ -1741,6 +1741,38 @@ export const FILE_SIGNATURES = { }, extractor: null }, + { + name: "Linux deb", + extension: "deb", + mime: "application/vnd.debian.binary-package", + description: "", + signature: { + 0: 0x21, + 1: 0x3C, + 2: 0x61, + 3: 0x72, + 4: 0x63, + 5: 0x68, + 6: 0x3e + }, + extractor: null + }, + { + name: "Apple Disk Image", + extension: "dmg", + mime: "application/x-apple-diskimage", + description: "", + signature: { + 0: 0x78, + 1: 0x01, + 2: 0x73, + 3: 0x0d, + 4: 0x62, + 5: 0x62, + 6: 0x60 + }, + extractor: null + } ], "Miscellaneous": [ { @@ -2470,6 +2502,44 @@ export const FILE_SIGNATURES = { 4: 0x70, }, extractor: null + }, + { + name: "Smile", + extension: "sml", + mime: " application/x-jackson-smile", + description: "", + signature: { + 0: 0x3a, + 1: 0x29, + 2: 0xa + }, + extractor: null + }, + { + name: "Lua Bytecode", + extension: "luac", + mime: "application/x-lua", + description: "", + signature: { + 0: 0x1b, + 1: 0x4c, + 2: 0x75, + 3: 0x61 + }, + extractor: null + }, + { + name: "WebAssembly binary", + extension: "wasm", + mime: "application/octet-stream", + description: "", + signature: { + 0: 0x00, + 1: 0x61, + 2: 0x73, + 3: 0x6d + }, + extractor: null } ] }; @@ -2977,6 +3047,52 @@ export function extractWAV(bytes, offset) { } +/** + * ICO extractor. + * + * @param {Uint8Array} bytes + * @param {number} offset + */ +export function extractICO(bytes, offset) { + const stream = new Stream(bytes.slice(offset)); + + // Move to number of files there are. + stream.moveTo(4); + + // Read the number of files stored in the ICO + const numberFiles = stream.readInt(2, "le"); + + // Move forward to the last file header. + stream.moveForwardsBy(8 + ((numberFiles-1) * 16)); + const fileSize = stream.readInt(4, "le"); + const fileOffset = stream.readInt(4, "le"); + + // Move to the end of the last file. + stream.moveTo(fileOffset + fileSize); + return stream.carve(); +} + + +/** + * WAV extractor. + * + * @param {Uint8Array} bytes + * @param {Number} offset + * @returns {Uint8Array} + */ +export function extractWAV(bytes, offset) { + const stream = new Stream(bytes.slice(offset)); + + // Move to file size field. + stream.moveTo(4); + + // Move to file size. + stream.moveTo(stream.readInt(4, "le")); + + return stream.carve(); +} + + /** * FLV extractor. * @@ -3074,14 +3190,12 @@ export function extractRTF(bytes, offset) { export function extractSQLITE(bytes, offset) { const stream = new Stream(bytes.slice(offset)); - stream.moveTo(16); - // Extract the size of the page. + stream.moveTo(16); const pageSize = stream.readInt(2); - stream.moveTo(28); - // Extract the number of pages. + stream.moveTo(28); const numPages = stream.readInt(4); // Move to the end of all the pages. @@ -3314,10 +3428,6 @@ export function extractBZIP2(bytes, offset) { ]; for (let i = 0; i < lookingfor.length; i++) { -<<<<<<< HEAD - -======= ->>>>>>> Tidied up GIF and BZIP2 extractors // Continue until an EOF. stream.continueUntil(lookingfor[i]); if (stream.getBytes(5).join("") === lookingfor[i].join("")) @@ -3644,13 +3754,13 @@ function readHuffmanCode(stream, table) { */ export function extractEVTX(bytes, offset) { const stream = new Stream(bytes.slice(offset)); - stream.moveTo(0x28); // Move to first ELFCHNK. + stream.moveTo(0x28); const total = stream.readInt(4, "le") - 0x2c; stream.moveForwardsBy(total); - while (stream.hasMore()) { + while (stream.hasMore()) { // Loop through ELFCHNKs. if (stream.getBytes(7).join("") !== [0x45, 0x6c, 0x66, 0x43, 0x68, 0x6e, 0x6b].join("")) break; @@ -3671,16 +3781,15 @@ export function extractEVTX(bytes, offset) { export function extractEVT(bytes, offset) { const stream = new Stream(bytes.slice(offset)); - stream.moveTo(0x14); - // Extract offset of EOF. - const eofoffset = stream.readInt(4, "le"); - stream.moveTo(eofoffset); + stream.moveTo(0x14); + const eofOffset = stream.readInt(4, "le"); + stream.moveTo(eofOffset); // Extract the size of the EOF. - const eofsize = stream.readInt(4, "le"); + const eofSize = stream.readInt(4, "le"); // Move past EOF. - stream.moveForwardsBy(eofsize-4); + stream.moveForwardsBy(eofSize-4); return stream.carve(); } diff --git a/src/core/lib/Hex.mjs b/src/core/lib/Hex.mjs index 5ae06a7e..9c70e91c 100644 --- a/src/core/lib/Hex.mjs +++ b/src/core/lib/Hex.mjs @@ -23,25 +23,39 @@ import Utils from "../Utils.mjs"; * * // returns "0a:14:1e" * toHex([10,20,30], ":"); + * + * // returns "0x0a,0x14,0x1e" + * toHex([10,20,30], "0x", 2, ",") */ -export function toHex(data, delim=" ", padding=2) { +export function toHex(data, delim=" ", padding=2, extraDelim="", lineSize=0) { if (!data) return ""; if (data instanceof ArrayBuffer) data = new Uint8Array(data); let output = ""; + const prepend = (delim === "0x" || delim === "\\x"); for (let i = 0; i < data.length; i++) { - output += data[i].toString(16).padStart(padding, "0") + delim; + const hex = data[i].toString(16).padStart(padding, "0"); + output += prepend ? delim + hex : hex + delim; + + if (extraDelim) { + output += extraDelim; + } + // Add LF after each lineSize amount of bytes but not at the end + if ((i !== data.length - 1) && ((i + 1) % lineSize === 0)) { + output += "\n"; + } } - // Add \x or 0x to beginning - if (delim === "0x") output = "0x" + output; - if (delim === "\\x") output = "\\x" + output; - - if (delim.length) - return output.slice(0, -delim.length); - else + // Remove the extraDelim at the end (if there is one) + // and remove the delim at the end, but if it's prepended there's nothing to remove + const rTruncLen = extraDelim.length + (prepend ? 0 : delim.length); + if (rTruncLen) { + // If rTruncLen === 0 then output.slice(0,0) will be returned, which is nothing + return output.slice(0, -rTruncLen); + } else { return output; + } } @@ -87,7 +101,7 @@ export function toHexFast(data) { */ export function fromHex(data, delim="Auto", byteLen=2) { if (delim !== "None") { - const delimRegex = delim === "Auto" ? /[^a-f\d]/gi : Utils.regexRep(delim); + const delimRegex = delim === "Auto" ? /[^a-f\d]|(0x)/gi : Utils.regexRep(delim); data = data.replace(delimRegex, ""); } @@ -102,7 +116,7 @@ export function fromHex(data, delim="Auto", byteLen=2) { /** * To Hexadecimal delimiters. */ -export const TO_HEX_DELIM_OPTIONS = ["Space", "Percent", "Comma", "Semi-colon", "Colon", "Line feed", "CRLF", "0x", "\\x", "None"]; +export const TO_HEX_DELIM_OPTIONS = ["Space", "Percent", "Comma", "Semi-colon", "Colon", "Line feed", "CRLF", "0x", "0x with comma", "\\x", "None"]; /** diff --git a/src/core/operations/RailFenceCipherDecode.mjs b/src/core/operations/RailFenceCipherDecode.mjs new file mode 100644 index 00000000..d98742b8 --- /dev/null +++ b/src/core/operations/RailFenceCipherDecode.mjs @@ -0,0 +1,88 @@ +/** + * @author Flavio Diez [flaviofdiez+cyberchef@gmail.com] + * @copyright Crown Copyright 2020 + * @license Apache-2.0 + */ + +import Operation from "../Operation.mjs"; +import OperationError from "../errors/OperationError.mjs"; + +/** + * Rail Fence Cipher Decode operation + */ +class RailFenceCipherDecode extends Operation { + + /** + * RailFenceCipherDecode constructor + */ + constructor() { + super(); + + this.name = "Rail Fence Cipher Decode"; + this.module = "Ciphers"; + this.description = "Decodes Strings that were created using the Rail fence Cipher provided a key and an offset"; + this.infoURL = "https://wikipedia.org/wiki/Rail_fence_cipher"; + this.inputType = "string"; + this.outputType = "string"; + this.args = [ + { + name: "Key", + type: "number", + value: 2 + }, + { + name: "Offset", + type: "number", + value: 0 + } + ]; + } + + /** + * @param {string} input + * @param {Object[]} args + * @returns {string} + */ + run(input, args) { + const [key, offset] = args; + + let cipher = input; + + if (key < 2) { + throw new OperationError("Key has to be bigger than 2"); + } else if (key > cipher.length) { + throw new OperationError("Key should be smaller than the cipher's length"); + } + + if (offset < 0) { + throw new OperationError("Offset has to be a positive integer"); + } + + const cycle = (key - 1) * 2; + + const rest = cipher.length % key; + + if (rest !== 0) { + cipher = cipher + (" ".repeat(key - rest)); + } + + const plaintext = new Array(cipher.length); + + let j = 0; + let x, y; + + for (y = 0; y < key; y++) { + for (x = 0; x < cipher.length; x++) { + if ((y + x + offset) % cycle === 0 || (y - x - offset) % cycle === 0) { + plaintext[x] = cipher[j++]; + } + } + } + + return plaintext.join("").trim(); + } + +} + + +export default RailFenceCipherDecode; diff --git a/src/core/operations/RailFenceCipherEncode.mjs b/src/core/operations/RailFenceCipherEncode.mjs new file mode 100644 index 00000000..03651f85 --- /dev/null +++ b/src/core/operations/RailFenceCipherEncode.mjs @@ -0,0 +1,74 @@ +/** + * @author Flavio Diez [flaviofdiez+cyberchef@gmail.com] + * @copyright Crown Copyright 2020 + * @license Apache-2.0 + */ + +import Operation from "../Operation.mjs"; +import OperationError from "../errors/OperationError.mjs"; + +/** + * Rail Fence Cipher Encode operation + */ +class RailFenceCipherEncode extends Operation { + + /** + * RailFenceCipherEncode constructor + */ + constructor() { + super(); + + this.name = "Rail Fence Cipher Encode"; + this.module = "Ciphers"; + this.description = "Encodes Strings using the Rail fence Cipher provided a key and an offset"; + this.infoURL = "https://wikipedia.org/wiki/Rail_fence_cipher"; + this.inputType = "string"; + this.outputType = "string"; + this.args = [ + { + name: "Key", + type: "number", + value: 2 + }, + { + name: "Offset", + type: "number", + value: 0 + } + ]; + } + + /** + * @param {string} input + * @param {Object[]} args + * @returns {string} + */ + run(input, args) { + const [key, offset] = args; + + const plaintext = input; + if (key < 2) { + throw new OperationError("Key has to be bigger than 2"); + } else if (key > plaintext.length) { + throw new OperationError("Key should be smaller than the plain text's length"); + } + + if (offset < 0) { + throw new OperationError("Offset has to be a positive integer"); + } + + const cycle = (key - 1) * 2; + const rows = new Array(key).fill(""); + + for (let pos = 0; pos < plaintext.length; pos++) { + const rowIdx = key - 1 - Math.abs(cycle / 2 - (pos + offset) % cycle); + + rows[rowIdx] += plaintext[pos]; + } + + return rows.join("").trim(); + } + +} + +export default RailFenceCipherEncode; diff --git a/src/core/operations/ToHex.mjs b/src/core/operations/ToHex.mjs index 6ae48da9..2e97de8f 100644 --- a/src/core/operations/ToHex.mjs +++ b/src/core/operations/ToHex.mjs @@ -30,6 +30,11 @@ class ToHex extends Operation { name: "Delimiter", type: "option", value: TO_HEX_DELIM_OPTIONS + }, + { + name: "Bytes per line", + type: "number", + value: 0 } ]; } @@ -40,8 +45,16 @@ class ToHex extends Operation { * @returns {string} */ run(input, args) { - const delim = Utils.charRep(args[0] || "Space"); - return toHex(new Uint8Array(input), delim, 2); + let delim, comma; + if (args[0] === "0x with comma") { + delim = "0x"; + comma = ","; + } else { + delim = Utils.charRep(args[0] || "Space"); + } + const lineSize = args[1]; + + return toHex(new Uint8Array(input), delim, 2, comma, lineSize); } /** @@ -54,17 +67,31 @@ class ToHex extends Operation { * @returns {Object[]} pos */ highlight(pos, args) { - const delim = Utils.charRep(args[0] || "Space"), - len = delim === "\r\n" ? 1 : delim.length; - - pos[0].start = pos[0].start * (2 + len); - pos[0].end = pos[0].end * (2 + len) - len; - - // 0x and \x are added to the beginning if they are selected, so increment the positions accordingly - if (delim === "0x" || delim === "\\x") { - pos[0].start += 2; - pos[0].end += 2; + let delim, commaLen; + if (args[0] === "0x with comma") { + delim = "0x"; + commaLen = 1; + } else { + delim = Utils.charRep(args[0] || "Space"); } + + const lineSize = args[1], + len = (delim === "\r\n" ? 1 : delim.length) + commaLen; + + const countLF = function(p) { + // Count the number of LFs from 0 upto p + return (p / lineSize | 0) - (p >= lineSize && p % lineSize === 0); + }; + + pos[0].start = pos[0].start * (2 + len) + countLF(pos[0].start); + pos[0].end = pos[0].end * (2 + len) + countLF(pos[0].end); + + // if the deliminators are not prepended, trim the trailing deliminator + if (!(delim === "0x" || delim === "\\x")) { + pos[0].end -= delim.length; + } + // if there is comma, trim the trailing comma + pos[0].end -= commaLen; return pos; } @@ -78,20 +105,26 @@ class ToHex extends Operation { * @returns {Object[]} pos */ highlightReverse(pos, args) { - const delim = Utils.charRep(args[0] || "Space"), - len = delim === "\r\n" ? 1 : delim.length, - width = len + 2; - - // 0x and \x are added to the beginning if they are selected, so increment the positions accordingly - if (delim === "0x" || delim === "\\x") { - if (pos[0].start > 1) pos[0].start -= 2; - else pos[0].start = 0; - if (pos[0].end > 1) pos[0].end -= 2; - else pos[0].end = 0; + let delim, commaLen; + if (args[0] === "0x with comma") { + delim = "0x"; + commaLen = 1; + } else { + delim = Utils.charRep(args[0] || "Space"); } - pos[0].start = pos[0].start === 0 ? 0 : Math.round(pos[0].start / width); - pos[0].end = pos[0].end === 0 ? 0 : Math.ceil(pos[0].end / width); + const lineSize = args[1], + len = (delim === "\r\n" ? 1 : delim.length) + commaLen, + width = len + 2; + + const countLF = function(p) { + // Count the number of LFs from 0 up to p + const lineLength = width * lineSize; + return (p / lineLength | 0) - (p >= lineLength && p % lineLength === 0); + }; + + pos[0].start = pos[0].start === 0 ? 0 : Math.round((pos[0].start - countLF(pos[0].start)) / width); + pos[0].end = pos[0].end === 0 ? 0 : Math.ceil((pos[0].end - countLF(pos[0].end)) / width); return pos; } } diff --git a/src/core/vendor/gost/gostEngine.mjs b/src/core/vendor/gost/gostEngine.mjs index fb68a791..b54819c6 100755 --- a/src/core/vendor/gost/gostEngine.mjs +++ b/src/core/vendor/gost/gostEngine.mjs @@ -383,7 +383,7 @@ if (root.importScripts) { * method with data parameter: algorithm, method and arg.
* Call method execute and postMessage() results to onmessage event handler * in the main process.
- * If error occured onerror event handler executed in main process. + * If error occurred onerror event handler executed in main process. * * @memberOf gostEngine * @name onmessage diff --git a/tests/operations/index.mjs b/tests/operations/index.mjs index 0debbdcc..b46c9c1b 100644 --- a/tests/operations/index.mjs +++ b/tests/operations/index.mjs @@ -45,6 +45,7 @@ import "./tests/Gzip.mjs"; import "./tests/Gunzip.mjs"; import "./tests/Hash.mjs"; import "./tests/HaversineDistance.mjs"; +import "./tests/Hex.mjs"; import "./tests/Hexdump.mjs"; import "./tests/Image.mjs"; import "./tests/IndexOfCoincidence.mjs"; diff --git a/tests/operations/tests/Ciphers.mjs b/tests/operations/tests/Ciphers.mjs index 62cbaa54..47453cf7 100644 --- a/tests/operations/tests/Ciphers.mjs +++ b/tests/operations/tests/Ciphers.mjs @@ -418,4 +418,114 @@ TestRegister.addTests([ } ], }, + { + name: "Rail Fence Cipher Decode: normal", + input: "Cytgah sTEAto rtn rsligcdsrporpyi H r fWiigo ovn oe", + expectedOutput: "Cryptography is THE Art of Writing or solving codes", + recipeConfig: [ + { + "op": "Rail Fence Cipher Decode", + "args": [2, 0] + } + ], + }, + { + name: "Rail Fence Cipher Decode: key has to be bigger than 2", + input: "Cytgah sTEAto rtn rsligcdsrporpyi H r fWiigo ovn oe", + expectedOutput: "Key has to be bigger than 2", + recipeConfig: [ + { + "op": "Rail Fence Cipher Decode", + "args": [1, 0] + } + ], + }, + { + name: "Rail Fence Cipher Decode: key has to be smaller than input's length", + input: "shortinput", + expectedOutput: "Key should be smaller than the cipher's length", + recipeConfig: [ + { + "op": "Rail Fence Cipher Decode", + "args": [22, 0] + } + ], + }, + { + name: "Rail Fence Cipher Decode: offset should be positive", + input: "shortinput", + expectedOutput: "Offset has to be a positive integer", + recipeConfig: [ + { + "op": "Rail Fence Cipher Decode", + "args": [2, -1] + } + ], + }, + { + name: "Rail Fence Cipher Decode: Normal with Offset non-null", + input: "51746026813793592840", + expectedOutput: "12345678901234567890", + recipeConfig: [ + { + "op": "Rail Fence Cipher Decode", + "args": [4, 2] + } + ], + }, + { + name: "Rail Fence Cipher Encode: normal", + input: "Cryptography is THE Art of Writing or solving codes", + expectedOutput: "Cytgah sTEAto rtn rsligcdsrporpyi H r fWiigo ovn oe", + recipeConfig: [ + { + "op": "Rail Fence Cipher Encode", + "args": [2, 0] + } + ], + }, + { + name: "Rail Fence Cipher Encode: key has to be bigger than 2", + input: "Cryptography is THE Art of Writing or solving codes", + expectedOutput: "Key has to be bigger than 2", + recipeConfig: [ + { + "op": "Rail Fence Cipher Encode", + "args": [1, 0] + } + ], + }, + { + name: "Rail Fence Cipher Encode: key has to be smaller than input's length", + input: "shortinput", + expectedOutput: "Key should be smaller than the plain text's length", + recipeConfig: [ + { + "op": "Rail Fence Cipher Encode", + "args": [22, 0] + } + ], + }, + { + name: "Rail Fence Cipher Encode: offset should be positive", + input: "shortinput", + expectedOutput: "Offset has to be a positive integer", + recipeConfig: [ + { + "op": "Rail Fence Cipher Encode", + "args": [2, -1] + } + ], + }, + { + name: "Rail Fence Cipher Encode: Normal with Offset non-null", + input: "12345678901234567890", + expectedOutput: "51746026813793592840", + recipeConfig: [ + { + "op": "Rail Fence Cipher Encode", + "args": [4, 2] + } + ], + }, ]); diff --git a/tests/operations/tests/Hex.mjs b/tests/operations/tests/Hex.mjs new file mode 100644 index 00000000..91520d88 --- /dev/null +++ b/tests/operations/tests/Hex.mjs @@ -0,0 +1,97 @@ +import TestRegister from "../../lib/TestRegister.mjs"; + +TestRegister.addTests([ + { + name: "ASCII to Hex stream", + input: "aberystwyth", + expectedOutput: "6162657279737477797468", + recipeConfig: [ + { + "op": "To Hex", + "args": [ + "None", + 0 + ] + }, + ] + }, + { + name: "ASCII to Hex with colon deliminator ", + input: "aberystwyth", + expectedOutput: "61:62:65:72:79:73:74:77:79:74:68", + recipeConfig: [ + { + "op": "To Hex", + "args": [ + "Colon", + 0 + ] + } + ] + }, + { + name: "ASCII to 0x Hex with comma", + input: "aberystwyth", + expectedOutput: "0x61,0x62,0x65,0x72,0x79,0x73,0x74,0x77,0x79,0x74,0x68", + recipeConfig: [ + { + "op": "To Hex", + "args": [ + "0x with comma", + 0 + ] + } + ] + }, + { + name: "ASCII to 0x Hex with comma and line breaks", + input: "aberystwyth", + expectedOutput: "0x61,0x62,0x65,0x72,\n0x79,0x73,0x74,0x77,\n0x79,0x74,0x68", + recipeConfig: [ + { + "op": "To Hex", + "args": [ + "0x with comma", + 4 + ] + } + ] + }, + { + name: "Hex stream to UTF-8", + input: "e69591e69591e5ada9e5ad90", + expectedOutput: "救救孩子", + recipeConfig: [ + { + "op": "From Hex", + "args": [ + "Auto" + ] + } + ] + + }, + { + name: "Multiline 0x hex to ASCII", + input: "0x49,0x20,0x73,0x61,0x77,0x20,0x6d,0x79,0x73,0x65,0x6c,0x66,0x20,0x73,0x69,\ +0x74,0x74,0x69,0x6e,0x67,0x20,0x69,0x6e,0x20,0x74,0x68,0x65,0x20,0x63,0x72,\ +0x6f,0x74,0x63,0x68,0x20,0x6f,0x66,0x20,0x74,0x68,0x65,0x20,0x74,0x68,0x69,\ +0x73,0x20,0x66,0x69,0x67,0x20,0x74,0x72,0x65,0x65,0x2c,0x20,0x73,0x74,0x61,\ +0x72,0x76,0x69,0x6e,0x67,0x20,0x74,0x6f,0x20,0x64,0x65,0x61,0x74,0x68,0x2c,\ +0x20,0x6a,0x75,0x73,0x74,0x20,0x62,0x65,0x63,0x61,0x75,0x73,0x65,0x20,0x49,\ +0x20,0x63,0x6f,0x75,0x6c,0x64,0x6e,0x27,0x74,0x20,0x6d,0x61,0x6b,0x65,0x20,\ +0x75,0x70,0x20,0x6d,0x79,0x20,0x6d,0x69,0x6e,0x64,0x20,0x77,0x68,0x69,0x63,\ +0x68,0x20,0x6f,0x66,0x20,0x74,0x68,0x65,0x20,0x66,0x69,0x67,0x73,0x20,0x49,\ +0x20,0x77,0x6f,0x75,0x6c,0x64,0x20,0x63,0x68,0x6f,0x6f,0x73,0x65,0x2e", + expectedOutput: "I saw myself sitting in the crotch of the this fig tree, starving to death, just because I couldn't make up my mind which of the figs I would choose.", + recipeConfig: [ + { + "op": "From Hex", + "args": [ + "Auto" + ] + } + ] + + } +]);