mirror of
https://github.com/gchq/CyberChef.git
synced 2024-11-02 06:01:02 +01:00
Merge branch 'bwhitn-fixNB'
This commit is contained in:
commit
a7a0cacddb
@ -26,9 +26,14 @@ const NetBIOS = {
|
||||
let output = [],
|
||||
offset = args[0];
|
||||
|
||||
for (let i = 0; i < input.length; i++) {
|
||||
output.push((input[i] >> 4) + offset);
|
||||
output.push((input[i] & 0xf) + offset);
|
||||
if (input.length <= 16) {
|
||||
let len = input.length;
|
||||
input.length = 16;
|
||||
input.fill(32, len, 16);
|
||||
for (let i = 0; i < input.length; i++) {
|
||||
output.push((input[i] >> 4) + offset);
|
||||
output.push((input[i] & 0xf) + offset);
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
@ -46,9 +51,12 @@ const NetBIOS = {
|
||||
let output = [],
|
||||
offset = args[0];
|
||||
|
||||
for (let i = 0; i < input.length; i += 2) {
|
||||
output.push(((input[i] - offset) << 4) |
|
||||
((input[i + 1] - offset) & 0xf));
|
||||
if (input.length <= 32 && (input.length % 2) === 0) {
|
||||
for (let i = 0; i < input.length; i += 2) {
|
||||
output.push((((input[i] & 0xff) - offset) << 4) |
|
||||
(((input[i + 1] & 0xff) - offset) & 0xf));
|
||||
}
|
||||
output = output.filter(x => x !== 32);
|
||||
}
|
||||
|
||||
return output;
|
||||
|
@ -26,6 +26,7 @@ import "./tests/operations/Image.js";
|
||||
import "./tests/operations/MorseCode.js";
|
||||
import "./tests/operations/MS.js";
|
||||
import "./tests/operations/PHP.js";
|
||||
import "./tests/operations/NetBIOS.js";
|
||||
import "./tests/operations/StrUtils.js";
|
||||
import "./tests/operations/SeqUtils.js";
|
||||
|
||||
|
34
test/tests/operations/NetBIOS.js
Normal file
34
test/tests/operations/NetBIOS.js
Normal file
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* NetBIOS tests.
|
||||
*
|
||||
* @author bwhitn [brian.m.whitney@outlook.com]
|
||||
*
|
||||
* @copyright Crown Copyright 2017
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../../TestRegister.js";
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "Encode NetBIOS name",
|
||||
input: "The NetBIOS name",
|
||||
expectedOutput: "FEGIGFCAEOGFHEECEJEPFDCAGOGBGNGF",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Encode NetBIOS Name",
|
||||
args: [65],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Decode NetBIOS Name",
|
||||
input: "FEGIGFCAEOGFHEECEJEPFDCAGOGBGNGF",
|
||||
expectedOutput: "The NetBIOS name",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Decode NetBIOS Name",
|
||||
args: [65],
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
Loading…
Reference in New Issue
Block a user