Add From JSFuck operation
This commit is contained in:
parent
ec4f1f5605
commit
afd8717819
@ -501,7 +501,8 @@
|
|||||||
"BSON deserialise",
|
"BSON deserialise",
|
||||||
"To MessagePack",
|
"To MessagePack",
|
||||||
"From MessagePack",
|
"From MessagePack",
|
||||||
"Render Markdown"
|
"Render Markdown",
|
||||||
|
"From JSFuck"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
53
src/core/operations/FromJSFuck.mjs
Normal file
53
src/core/operations/FromJSFuck.mjs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/**
|
||||||
|
* @author Roma476 [friciu.robert09@gmail.com]
|
||||||
|
* @copyright Crown Copyright 2026
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation.mjs";
|
||||||
|
import OperationError from "../errors/OperationError.mjs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* From JSFuck operation
|
||||||
|
*/
|
||||||
|
class FromJSFuck extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FromJSFuck constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = "From JSFuck";
|
||||||
|
this.module = "Default";
|
||||||
|
this.description = "Decodes JSFuck encoded JavaScript. JSFuck uses only 6 characters: <code>[</code>, <code>]</code>, <code>(</code>, <code>)</code>, <code>!</code> and <code>+</code>.<br><br>e.g. <code>[][(![]+[])[+[]]+...]</code> becomes <code>alert(1)</code>";
|
||||||
|
this.infoURL = "https://wikipedia.org/wiki/JSFuck";
|
||||||
|
this.inputType = "string";
|
||||||
|
this.outputType = "string";
|
||||||
|
this.args = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
run(input, args) {
|
||||||
|
// Input Validation
|
||||||
|
for (let i = 0; i < input.length; i++) {
|
||||||
|
const char = input[i];
|
||||||
|
if (!["[", "]", "(", ")", "!", "+"].includes(char)) {
|
||||||
|
throw new OperationError(`Invalid character at position ${i}: ${char}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return String(Function('"use strict"; return (' + input + ')')());
|
||||||
|
} catch (err) {
|
||||||
|
throw new OperationError("Unable to decode JSFuck: " + err.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default FromJSFuck;
|
||||||
0
tests/operations/tests/FromJSFuck.mjs
Normal file
0
tests/operations/tests/FromJSFuck.mjs
Normal file
Loading…
x
Reference in New Issue
Block a user