Browse Source

Tidied up Citrix CTX1 operations and updated CHANGELOG

n1474335 6 years ago
parent
commit
79d7a5dd87

+ 5 - 0
CHANGELOG.md

@@ -1,6 +1,9 @@
 # Changelog
 # Changelog
 All notable changes to CyberChef will be documented in this file.
 All notable changes to CyberChef will be documented in this file.
 
 
+### [8.12.0] - 2018-11-21
+- 'Citrix CTX1 Encode' and 'Citrix CTX1 Decode' operations added [@bwhitn] | [#428]
+
 ### [8.11.0] - 2018-11-13
 ### [8.11.0] - 2018-11-13
 - 'CSV to JSON' and 'JSON to CSV' operations added [@n1474335] | [#277]
 - 'CSV to JSON' and 'JSON to CSV' operations added [@n1474335] | [#277]
 
 
@@ -87,6 +90,7 @@ All notable changes to CyberChef will be documented in this file.
 [@PenguinGeorge]: https://github.com/PenguinGeorge
 [@PenguinGeorge]: https://github.com/PenguinGeorge
 [@arnydo]: https://github.com/arnydo
 [@arnydo]: https://github.com/arnydo
 [@klaxon1]: https://github.com/klaxon1
 [@klaxon1]: https://github.com/klaxon1
+[@bwhitn]: https://github.com/bwhitn
 
 
 [#95]: https://github.com/gchq/CyberChef/pull/299
 [#95]: https://github.com/gchq/CyberChef/pull/299
 [#173]: https://github.com/gchq/CyberChef/pull/173
 [#173]: https://github.com/gchq/CyberChef/pull/173
@@ -109,3 +113,4 @@ All notable changes to CyberChef will be documented in this file.
 [#351]: https://github.com/gchq/CyberChef/pull/351
 [#351]: https://github.com/gchq/CyberChef/pull/351
 [#387]: https://github.com/gchq/CyberChef/pull/387
 [#387]: https://github.com/gchq/CyberChef/pull/387
 [#394]: https://github.com/gchq/CyberChef/pull/394
 [#394]: https://github.com/gchq/CyberChef/pull/394
+[#428]: https://github.com/gchq/CyberChef/pull/428

+ 2 - 2
src/core/config/Categories.json

@@ -68,8 +68,6 @@
             "Blowfish Decrypt",
             "Blowfish Decrypt",
             "DES Encrypt",
             "DES Encrypt",
             "DES Decrypt",
             "DES Decrypt",
-            "Citrix CTX1 Encode",
-            "Citrix CTX1 Decode",
             "Triple DES Encrypt",
             "Triple DES Encrypt",
             "Triple DES Decrypt",
             "Triple DES Decrypt",
             "RC2 Encrypt",
             "RC2 Encrypt",
@@ -97,6 +95,8 @@
             "JWT Sign",
             "JWT Sign",
             "JWT Verify",
             "JWT Verify",
             "JWT Decode",
             "JWT Decode",
+            "Citrix CTX1 Encode",
+            "Citrix CTX1 Decode",
             "Pseudo-Random Number Generator"
             "Pseudo-Random Number Generator"
         ]
         ]
     },
     },

+ 10 - 9
src/core/operations/DecodeCitrixCTX1.mjs → src/core/operations/CitrixCTX1Decode.mjs

@@ -1,25 +1,26 @@
 /**
 /**
  * @author bwhitn [brian.m.whitney@gmail.com]
  * @author bwhitn [brian.m.whitney@gmail.com]
- * @copyright Crown Copyright 2017
+ * @copyright Crown Copyright 2018
  * @license Apache-2.0
  * @license Apache-2.0
  */
  */
 
 
 import Operation from "../Operation";
 import Operation from "../Operation";
+import OperationError from "../errors/OperationError";
 import cptable from "../vendor/js-codepage/cptable.js";
 import cptable from "../vendor/js-codepage/cptable.js";
 
 
 /**
 /**
- * Encode Citrix CTX1 class
+ * Citrix CTX1 Decode operation
  */
  */
-class DecodeCitrixCTX1 extends Operation {
+class CitrixCTX1Decode extends Operation {
 
 
     /**
     /**
-     * EncodeCitrixCTX1 constructor
+     * CitrixCTX1Decode constructor
      */
      */
     constructor() {
     constructor() {
         super();
         super();
 
 
         this.name = "Citrix CTX1 Decode";
         this.name = "Citrix CTX1 Decode";
-        this.module = "Ciphers";
+        this.module = "Encodings";
         this.description = "Decodes strings in a Citrix CTX1 password format to plaintext.";
         this.description = "Decodes strings in a Citrix CTX1 password format to plaintext.";
         this.infoURL = "https://www.reddit.com/r/AskNetsec/comments/1s3r6y/citrix_ctx1_hash_decoding/";
         this.infoURL = "https://www.reddit.com/r/AskNetsec/comments/1s3r6y/citrix_ctx1_hash_decoding/";
         this.inputType = "byteArray";
         this.inputType = "byteArray";
@@ -34,13 +35,13 @@ class DecodeCitrixCTX1 extends Operation {
      */
      */
     run(input, args) {
     run(input, args) {
         if (input.length % 4 !== 0) {
         if (input.length % 4 !== 0) {
-            return "";
+            throw new OperationError("Incorrect hash length");
         }
         }
         const revinput = input.reverse();
         const revinput = input.reverse();
         const result = [];
         const result = [];
         let temp = 0;
         let temp = 0;
-        for (let i = 0; i < revinput.length; i+=2) {
-            if (i+2 >= revinput.length) {
+        for (let i = 0; i < revinput.length; i += 2) {
+            if (i + 2 >= revinput.length) {
                 temp = 0;
                 temp = 0;
             } else {
             } else {
                 temp = ((revinput[i + 2] - 0x41) & 0xf) ^ (((revinput[i + 3]- 0x41) << 4) & 0xf0);
                 temp = ((revinput[i + 2] - 0x41) & 0xf) ^ (((revinput[i + 3]- 0x41) << 4) & 0xf0);
@@ -54,4 +55,4 @@ class DecodeCitrixCTX1 extends Operation {
 
 
 }
 }
 
 
-export default DecodeCitrixCTX1;
+export default CitrixCTX1Decode;

+ 7 - 7
src/core/operations/EncodeCitrixCTX1.mjs → src/core/operations/CitrixCTX1Encode.mjs

@@ -1,6 +1,6 @@
 /**
 /**
  * @author bwhitn [brian.m.whitney@gmail.com]
  * @author bwhitn [brian.m.whitney@gmail.com]
- * @copyright Crown Copyright 2017
+ * @copyright Crown Copyright 2018
  * @license Apache-2.0
  * @license Apache-2.0
  */
  */
 
 
@@ -8,18 +8,18 @@ import Operation from "../Operation";
 import cptable from "../vendor/js-codepage/cptable.js";
 import cptable from "../vendor/js-codepage/cptable.js";
 
 
 /**
 /**
- * Encode Citrix CTX1 class
+ * Citrix CTX1 Encode operation
  */
  */
-class EncodeCitrixCTX1 extends Operation {
+class CitrixCTX1Encode extends Operation {
 
 
     /**
     /**
-     * EncodeCitrixCTX1 constructor
+     * CitrixCTX1Encode constructor
      */
      */
     constructor() {
     constructor() {
         super();
         super();
 
 
         this.name = "Citrix CTX1 Encode";
         this.name = "Citrix CTX1 Encode";
-        this.module = "Ciphers";
+        this.module = "Encodings";
         this.description = "Encodes strings to Citrix CTX1 password format.";
         this.description = "Encodes strings to Citrix CTX1 password format.";
         this.infoURL = "https://www.reddit.com/r/AskNetsec/comments/1s3r6y/citrix_ctx1_hash_decoding/";
         this.infoURL = "https://www.reddit.com/r/AskNetsec/comments/1s3r6y/citrix_ctx1_hash_decoding/";
         this.inputType = "string";
         this.inputType = "string";
@@ -33,7 +33,7 @@ class EncodeCitrixCTX1 extends Operation {
      * @returns {byteArray}
      * @returns {byteArray}
      */
      */
     run(input, args) {
     run(input, args) {
-        const utf16pass = Buffer.from(cptable.utils.encode(1200, input));
+        const utf16pass = Array.from(cptable.utils.encode(1200, input));
         const result = [];
         const result = [];
         let temp = 0;
         let temp = 0;
         for (let i = 0; i < utf16pass.length; i++) {
         for (let i = 0; i < utf16pass.length; i++) {
@@ -47,4 +47,4 @@ class EncodeCitrixCTX1 extends Operation {
 
 
 }
 }
 
 
-export default EncodeCitrixCTX1;
+export default CitrixCTX1Encode;

+ 1 - 1
test/tests/operations/Ciphers.mjs

@@ -245,7 +245,7 @@ TestRegister.addTests([
     {
     {
         name: "Citrix CTX1 Decode: invalid length",
         name: "Citrix CTX1 Decode: invalid length",
         input: "PFFAJEDBOHECJEDBODEGIMCJPOFLJKDPKLA",
         input: "PFFAJEDBOHECJEDBODEGIMCJPOFLJKDPKLA",
-        expectedOutput: "",
+        expectedOutput: "Incorrect hash length",
         recipeConfig: [
         recipeConfig: [
             {
             {
                 "op": "Citrix CTX1 Decode",
                 "op": "Citrix CTX1 Decode",