2018-11-20 05:48:33 +01:00
|
|
|
/**
|
2018-11-20 17:09:52 +01:00
|
|
|
* @author bwhitn [brian.m.whitney@gmail.com]
|
2018-11-21 13:28:19 +01:00
|
|
|
* @copyright Crown Copyright 2018
|
2018-11-20 05:48:33 +01:00
|
|
|
* @license Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
import Operation from "../Operation";
|
|
|
|
import cptable from "../vendor/js-codepage/cptable.js";
|
|
|
|
|
|
|
|
/**
|
2018-11-21 13:28:19 +01:00
|
|
|
* Citrix CTX1 Encode operation
|
2018-11-20 05:48:33 +01:00
|
|
|
*/
|
2018-11-21 13:28:19 +01:00
|
|
|
class CitrixCTX1Encode extends Operation {
|
2018-11-20 05:48:33 +01:00
|
|
|
|
|
|
|
/**
|
2018-11-21 13:28:19 +01:00
|
|
|
* CitrixCTX1Encode constructor
|
2018-11-20 05:48:33 +01:00
|
|
|
*/
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
|
|
|
this.name = "Citrix CTX1 Encode";
|
2018-11-21 13:28:19 +01:00
|
|
|
this.module = "Encodings";
|
2018-11-20 05:48:33 +01:00
|
|
|
this.description = "Encodes strings to Citrix CTX1 password format.";
|
|
|
|
this.infoURL = "https://www.reddit.com/r/AskNetsec/comments/1s3r6y/citrix_ctx1_hash_decoding/";
|
|
|
|
this.inputType = "string";
|
2018-11-20 17:09:52 +01:00
|
|
|
this.outputType = "byteArray";
|
2018-11-20 05:48:33 +01:00
|
|
|
this.args = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {string} input
|
|
|
|
* @param {Object[]} args
|
2018-11-20 17:09:52 +01:00
|
|
|
* @returns {byteArray}
|
2018-11-20 05:48:33 +01:00
|
|
|
*/
|
|
|
|
run(input, args) {
|
2018-11-21 13:28:19 +01:00
|
|
|
const utf16pass = Array.from(cptable.utils.encode(1200, input));
|
2018-11-20 17:24:50 +01:00
|
|
|
const result = [];
|
2018-11-20 17:09:52 +01:00
|
|
|
let temp = 0;
|
2018-11-20 05:48:33 +01:00
|
|
|
for (let i = 0; i < utf16pass.length; i++) {
|
|
|
|
temp = utf16pass[i] ^ 0xa5 ^ temp;
|
2018-11-20 17:09:52 +01:00
|
|
|
result.push(((temp >>> 4) & 0xf) + 0x41);
|
2018-11-20 05:48:33 +01:00
|
|
|
result.push((temp & 0xf) + 0x41);
|
|
|
|
}
|
|
|
|
|
2018-11-20 17:09:52 +01:00
|
|
|
return result;
|
2018-11-20 05:48:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-11-21 13:28:19 +01:00
|
|
|
export default CitrixCTX1Encode;
|