Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

restringer

Package Overview
Dependencies
Maintainers
0
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

restringer - npm Package Compare versions

Comparing version 1.10.4 to 2.0.0

eslint.config.js

8

index.js

@@ -1,5 +0,3 @@

module.exports = {
REstringer: require(__dirname + '/src/restringer'),
deobModules: require(__dirname + '/src/modules'),
processors: require(__dirname + '/src/processors'),
};
export * from './src/restringer.js';
export * from './src/modules/index.js';
export * from './src/processors/index.js';
{
"name": "restringer",
"version": "1.10.4",
"version": "2.0.0",
"description": "Deobfuscate Javascript with emphasis on reconstructing strings",
"main": "index.js",
"type": "module",
"bin": {

@@ -14,9 +15,10 @@ "restringer": "./src/restringer.js"

"dependencies": {
"flast": "^1.7.1",
"flast": "^2.0.0",
"isolated-vm": "^5.0.1",
"jsdom": "^24.1.0",
"obfuscation-detector": "^1.1.7"
"jsdom": "^25.0.1",
"obfuscation-detector": "^2.0.0"
},
"scripts": {
"test": "node --trace-warnings tests/testRestringer.js"
"test": "node --test --trace-warnings --no-node-snapshot --experimental-json-modules",
"test:coverage": "node --test --trace-warnings --no-node-snapshot --experimental-json-modules --experimental-test-coverage"
},

@@ -35,3 +37,3 @@ "repository": {

],
"author": "ben.baryo@humansecurity.com",
"author": "Ben Baryo (ben.baryo@humansecurity.com)",
"license": "MIT",

@@ -43,5 +45,7 @@ "bugs": {

"devDependencies": {
"eslint": "^8.56.0",
"husky": "^8.0.3"
"@babel/eslint-parser": "^7.25.8",
"@babel/plugin-syntax-import-assertions": "^7.25.7",
"eslint": "^9.12.0",
"husky": "^9.1.6"
}
}

@@ -89,7 +89,7 @@ # Restringer

```javascript
const {
safe: {normalizeComputed},
unsafe: {resolveDefiniteBinaryExpressions, resolveLocalCalls},
} = require('restringer').deobModules;
const {applyIteratively} = require('flast').utils;
import {safe, unsafe} from 'restringer';
const {normalizeComputed} = safe;
const {resolveDefiniteBinaryExpressions, resolveLocalCalls} = unsafe;
import {utils} from 'flast';
const {applyIteratively} = utils;
let script = 'obfuscated JS here';

@@ -107,6 +107,6 @@ const deobModules = [

```javascript
const {
unsafe: {resolveLocalCalls},
} = require('restringer').deobModules;
const {applyIteratively} = require('flast').utils;
import {unsafe} from 'restringer';
const {resolveLocalCalls} = unsafe;
import {utils} from 'flast';
const {applyIteratively} = utils;
let script = 'obfuscated JS here';

@@ -124,4 +124,4 @@

```javascript
const fs = require('node:fs');
const {REstringer} = require('restringer');
import fs from 'node:fs';
import {REstringer} from 'restringer';

@@ -151,5 +151,6 @@ const inputFilename = process.argv[2];

```javascript
const {logger, applyIteratively, treeModifier} = require('flast').utils;
import {utils} from 'flast';
const {applyIteratively, treeModifier, logger} = utils;
// Optional loading from file
// const fs = require('node:fs');
// import fs from 'node:fs';
// const inputFilename = process.argv[2] || 'target.js';

@@ -185,5 +186,4 @@ // const code = fs.readFileSync(inputFilename, 'utf-8');

* [Processors](src/processors/README.md)
* [Tests](tests/README.md)
* [Contribution guide](CONTRIBUTING.md)
* [Obfuscation Detector](https://github.com/PerimeterX/obfuscation-detector/blob/main/README.md)
* [flAST](https://github.com/PerimeterX/flast/blob/main/README.md)

@@ -11,23 +11,11 @@ // Arguments that shouldn't be touched since the context may not be inferred during deobfuscation.

// Do not repeate more than this many iterations.
const defaultMaxIterations = 500;
// Behaves like a number, but decrements each time it's used.
// Use defaultMaxIterations.value = 300 to set a new value.
const defaultMaxIterations = {
value: 500,
valueOf() {return this.value--;},
};
// The global maximum allowed iterations of runLoop. Value of -1 means unlimited.
let globalMaxIterations = -1;
/**
* @return {number} The global maximum allowed iterations of runLoop. Value of -1 means unlimited.
*/
function getGlobalMaxIterations() {
return globalMaxIterations;
}
const propertiesThatModifyContent = ['push', 'forEach', 'pop', 'insert', 'add', 'set', 'delete'];
/**
* @param {number} num The number of allowed iterations across all runs. Set to -1 to disable limit.
*/
function setGlobalMaxIterations(num) {
globalMaxIterations = num;
}
// Builtin functions that shouldn't be resolved in the deobfuscation context.

@@ -53,3 +41,3 @@ const skipBuiltinFunctions = [

module.exports = {
export {
badArgumentTypes,

@@ -60,4 +48,2 @@ badIdentifierCharsRegex,

propertiesThatModifyContent,
setGlobalMaxIterations,
getGlobalMaxIterations,
skipBuiltinFunctions,

@@ -64,0 +50,0 @@ skipIdentifiers,

@@ -1,6 +0,4 @@

module.exports = {
config: require(__dirname + '/config'),
safe: require(__dirname + '/safe'),
unsafe: require(__dirname + '/unsafe'),
utils: require(__dirname + '/utils'),
};
export const config = await import('./config.js');
export const safe = await import('./safe/index.js');
export const unsafe = await import('./unsafe/index.js');
export const utils = await import('./utils/index.js');

@@ -1,32 +0,30 @@

module.exports = {
normalizeComputed: require(__dirname + '/normalizeComputed'),
normalizeEmptyStatements: require(__dirname + '/normalizeEmptyStatements'),
parseTemplateLiteralsIntoStringLiterals: require(__dirname + '/parseTemplateLiteralsIntoStringLiterals'),
rearrangeSequences: require(__dirname + '/rearrangeSequences'),
rearrangeSwitches: require(__dirname + '/rearrangeSwitches'),
removeDeadNodes: require(__dirname + '/removeDeadNodes'),
removeRedundantBlockStatements: require(__dirname + '/removeRedundantBlockStatements'),
replaceBooleanExpressionsWithIf: require(__dirname + '/replaceBooleanExpressionsWithIf'),
replaceCallExpressionsWithUnwrappedIdentifier: require(__dirname + '/replaceCallExpressionsWithUnwrappedIdentifier'),
replaceEvalCallsWithLiteralContent: require(__dirname + '/replaceEvalCallsWithLiteralContent'),
replaceFunctionShellsWithWrappedValue: require(__dirname + '/replaceFunctionShellsWithWrappedValue'),
replaceFunctionShellsWithWrappedValueIIFE: require(__dirname + '/replaceFunctionShellsWithWrappedValueIIFE'),
replaceIdentifierWithFixedAssignedValue: require(__dirname + '/replaceIdentifierWithFixedAssignedValue'),
replaceIdentifierWithFixedValueNotAssignedAtDeclaration: require(__dirname + '/replaceIdentifierWithFixedValueNotAssignedAtDeclaration'),
replaceNewFuncCallsWithLiteralContent: require(__dirname + '/replaceNewFuncCallsWithLiteralContent'),
replaceSequencesWithExpressions: require(__dirname + '/replaceSequencesWithExpressions'),
resolveDeterministicIfStatements: require(__dirname + '/resolveDeterministicIfStatements'),
resolveFunctionConstructorCalls: require(__dirname + '/resolveFunctionConstructorCalls'),
resolveMemberExpressionReferencesToArrayIndex: require(__dirname + '/resolveMemberExpressionReferencesToArrayIndex'),
resolveMemberExpressionsWithDirectAssignment: require(__dirname + '/resolveMemberExpressionsWithDirectAssignment'),
resolveProxyCalls: require(__dirname + '/resolveProxyCalls'),
resolveProxyReferences: require(__dirname + '/resolveProxyReferences'),
resolveProxyVariables: require(__dirname + '/resolveProxyVariables'),
resolveRedundantLogicalExpressions: require(__dirname + '/resolveRedundantLogicalExpressions'),
separateChainedDeclarators: require(__dirname + '/separateChainedDeclarators'),
simplifyCalls: require(__dirname + '/simplifyCalls'),
simplifyIfStatements: require(__dirname + '/simplifyIfStatements'),
unwrapFunctionShells: require(__dirname + '/unwrapFunctionShells'),
unwrapIIFEs: require(__dirname + '/unwrapIIFEs'),
unwrapSimpleOperations: require(__dirname + '/unwrapSimpleOperations'),
};
export const normalizeComputed = await import('./normalizeComputed.js');
export const normalizeEmptyStatements = await import('./normalizeEmptyStatements.js');
export const parseTemplateLiteralsIntoStringLiterals = await import('./parseTemplateLiteralsIntoStringLiterals.js');
export const rearrangeSequences = await import('./rearrangeSequences.js');
export const rearrangeSwitches = await import('./rearrangeSwitches.js');
export const removeDeadNodes = await import('./removeDeadNodes.js');
export const removeRedundantBlockStatements = await import('./removeRedundantBlockStatements.js');
export const replaceBooleanExpressionsWithIf = await import('./replaceBooleanExpressionsWithIf.js');
export const replaceCallExpressionsWithUnwrappedIdentifier = await import('./replaceCallExpressionsWithUnwrappedIdentifier.js');
export const replaceEvalCallsWithLiteralContent = await import('./replaceEvalCallsWithLiteralContent.js');
export const replaceFunctionShellsWithWrappedValue = await import('./replaceFunctionShellsWithWrappedValue.js');
export const replaceFunctionShellsWithWrappedValueIIFE = await import('./replaceFunctionShellsWithWrappedValueIIFE.js');
export const replaceIdentifierWithFixedAssignedValue = await import('./replaceIdentifierWithFixedAssignedValue.js');
export const replaceIdentifierWithFixedValueNotAssignedAtDeclaration = await import('./replaceIdentifierWithFixedValueNotAssignedAtDeclaration.js');
export const replaceNewFuncCallsWithLiteralContent = await import('./replaceNewFuncCallsWithLiteralContent.js');
export const replaceSequencesWithExpressions = await import('./replaceSequencesWithExpressions.js');
export const resolveDeterministicIfStatements = await import('./resolveDeterministicIfStatements.js');
export const resolveFunctionConstructorCalls = await import('./resolveFunctionConstructorCalls.js');
export const resolveMemberExpressionReferencesToArrayIndex = await import('./resolveMemberExpressionReferencesToArrayIndex.js');
export const resolveMemberExpressionsWithDirectAssignment = await import('./resolveMemberExpressionsWithDirectAssignment.js');
export const resolveProxyCalls = await import('./resolveProxyCalls.js');
export const resolveProxyReferences = await import('./resolveProxyReferences.js');
export const resolveProxyVariables = await import('./resolveProxyVariables.js');
export const resolveRedundantLogicalExpressions = await import('./resolveRedundantLogicalExpressions.js');
export const separateChainedDeclarators = await import('./separateChainedDeclarators.js');
export const simplifyCalls = await import('./simplifyCalls.js');
export const simplifyIfStatements = await import('./simplifyIfStatements.js');
export const unwrapFunctionShells = await import('./unwrapFunctionShells.js');
export const unwrapIIFEs = await import('./unwrapIIFEs.js');
export const unwrapSimpleOperations = await import('./unwrapSimpleOperations.js');

@@ -1,2 +0,2 @@

const {badIdentifierCharsRegex, validIdentifierBeginning} = require(__dirname + '/../config');
import {badIdentifierCharsRegex, validIdentifierBeginning} from '../config.js';

@@ -51,2 +51,2 @@ /**

module.exports = normalizeComputed;
export default normalizeComputed;

@@ -20,2 +20,2 @@ /**

module.exports = normalizeEmptyStatements;
export default normalizeEmptyStatements;

@@ -1,2 +0,2 @@

const createNewNode = require(__dirname + '/../utils/createNewNode');
import {createNewNode} from '../utils/createNewNode.js';

@@ -27,2 +27,2 @@ /**

module.exports = parseTemplateLiteralsIntoStringLiterals;
export default parseTemplateLiteralsIntoStringLiterals;

@@ -61,2 +61,2 @@ /**

module.exports = rearrangeSequences;
export default rearrangeSequences;

@@ -1,2 +0,2 @@

const getDescendants = require(__dirname + '/../utils/getDescendants');
import {getDescendants} from '../utils/getDescendants.js';

@@ -53,2 +53,2 @@ const maxRepetition = 50;

module.exports = rearrangeSwitches;
export default rearrangeSwitches;

@@ -1,2 +0,7 @@

const relevantParents = ['VariableDeclarator', 'AssignmentExpression', 'FunctionDeclaration', 'ClassDeclaration'];
const relevantParents = [
'VariableDeclarator',
'AssignmentExpression',
'FunctionDeclaration',
'ClassDeclaration',
];

@@ -27,2 +32,2 @@ /**

module.exports = removeDeadNodes;
export default removeDeadNodes;

@@ -39,2 +39,2 @@ /**

module.exports = removeRedundantBlockStatements;
export default removeRedundantBlockStatements;

@@ -44,2 +44,2 @@ /**

module.exports = replaceBooleanExpressionsWithIf;
export default replaceBooleanExpressionsWithIf;

@@ -38,2 +38,2 @@ /**

module.exports = replaceCallExpressionsWithUnwrappedIdentifier;
export default replaceCallExpressionsWithUnwrappedIdentifier;

@@ -1,4 +0,5 @@

const getCache = require(__dirname + '/../utils/getCache');
const generateHash = require(__dirname + '/../utils/generateHash');
const {generateFlatAST, utils: {logger}} = require('flast');
import {getCache} from '../utils/getCache.js';
import {generateHash} from '../utils/generateHash.js';
import {generateFlatAST, utils} from 'flast';
const {logger} = utils;

@@ -71,2 +72,2 @@ /**

module.exports = replaceEvalCallsWithLiteralContent;
export default replaceEvalCallsWithLiteralContent;

@@ -27,2 +27,2 @@ /**

module.exports = replaceFunctionShellsWithWrappedValue;
export default replaceFunctionShellsWithWrappedValue;

@@ -23,2 +23,2 @@ /**

module.exports = replaceFunctionShellsWithWrappedValueIIFE;
export default replaceFunctionShellsWithWrappedValueIIFE;

@@ -1,2 +0,2 @@

const areReferencesModified = require(__dirname + '/../utils/areReferencesModified');
import {areReferencesModified} from '../utils/areReferencesModified.js';

@@ -27,2 +27,2 @@ /**

module.exports = replaceIdentifierWithFixedAssignedValue;
export default replaceIdentifierWithFixedAssignedValue;

@@ -1,3 +0,3 @@

const areReferencesModified = require(__dirname + '/../utils/areReferencesModified');
const getMainDeclaredObjectOfMemberExpression = require(__dirname + '/../utils/getMainDeclaredObjectOfMemberExpression');
import {areReferencesModified} from '../utils/areReferencesModified.js';
import {getMainDeclaredObjectOfMemberExpression} from '../utils/getMainDeclaredObjectOfMemberExpression.js';

@@ -49,2 +49,2 @@ /**

module.exports = replaceIdentifierWithFixedValueNotAssignedAtDeclaration;
export default replaceIdentifierWithFixedValueNotAssignedAtDeclaration;

@@ -1,4 +0,5 @@

const getCache = require(__dirname + '/../utils/getCache');
const generateHash = require(__dirname + '/../utils/generateHash');
const {generateFlatAST, utils: {logger}} = require('flast');
import {getCache} from '../utils/getCache.js';
import {generateHash} from '../utils/generateHash.js';
import {generateFlatAST, utils} from 'flast';
const {logger} = utils;

@@ -62,2 +63,2 @@ /**

module.exports = replaceNewFuncCallsWithLiteralContent;
export default replaceNewFuncCallsWithLiteralContent;

@@ -45,2 +45,2 @@ /**

module.exports = replaceSequencesWithExpressions;
export default replaceSequencesWithExpressions;

@@ -29,2 +29,2 @@ /**

module.exports = resolveDeterministicIfStatements;
export default resolveDeterministicIfStatements;

@@ -1,2 +0,2 @@

const {generateFlatAST} = require('flast');
import {generateFlatAST} from 'flast';

@@ -38,2 +38,2 @@ /**

module.exports = resolveFunctionConstructorCalls;
export default resolveFunctionConstructorCalls;

@@ -1,2 +0,3 @@

const {logger} = require('flast').utils;
import {utils} from 'flast';
const {logger} = utils;

@@ -38,2 +39,2 @@ const minArrayLength = 20;

module.exports = resolveMemberExpressionReferencesToArrayIndex;
export default resolveMemberExpressionReferencesToArrayIndex;

@@ -38,2 +38,2 @@ /**

module.exports = resolveMemberExpressionsWithDirectAssignment;
export default resolveMemberExpressionsWithDirectAssignment;

@@ -51,2 +51,2 @@ /**

module.exports = resolveProxyCalls;
export default resolveProxyCalls;

@@ -1,4 +0,4 @@

const getDescendants = require(__dirname + '/../utils/getDescendants');
const areReferencesModified = require(__dirname + '/../utils/areReferencesModified');
const getMainDeclaredObjectOfMemberExpression = require(__dirname + '/../utils/getMainDeclaredObjectOfMemberExpression');
import {getDescendants} from '../utils/getDescendants.js';
import {areReferencesModified} from '../utils/areReferencesModified.js';
import {getMainDeclaredObjectOfMemberExpression} from '../utils/getMainDeclaredObjectOfMemberExpression.js';

@@ -40,2 +40,2 @@ /**

module.exports = resolveProxyReferences;
export default resolveProxyReferences;

@@ -1,2 +0,2 @@

const areReferencesModified = require(__dirname + '/../utils/areReferencesModified');
import {areReferencesModified} from '../utils/areReferencesModified.js';

@@ -28,2 +28,2 @@ /**

module.exports = resolveProxyVariables;
export default resolveProxyVariables;

@@ -50,2 +50,2 @@ /**

module.exports = resolveRedundantLogicalExpressions;
export default resolveRedundantLogicalExpressions;

@@ -51,2 +51,2 @@ /**

module.exports = separateChainedDeclarators;
export default separateChainedDeclarators;

@@ -29,2 +29,2 @@ /**

module.exports = simplifyCalls;
export default simplifyCalls;

@@ -43,2 +43,2 @@ /**

module.exports = simplifyIfStatements;
export default simplifyIfStatements;

@@ -32,2 +32,2 @@ /**

module.exports = unwrapFunctionShells;
export default unwrapFunctionShells;

@@ -55,2 +55,2 @@ /**

module.exports = unwrapIIFEs;
export default unwrapIIFEs;

@@ -92,2 +92,2 @@ const operators = ['+', '-', '*', '/', '%', '&', '|', '&&', '||', '**', '^'];

module.exports = unwrapSimpleOperations;
export default unwrapSimpleOperations;

@@ -1,14 +0,12 @@

module.exports = {
normalizeRedundantNotOperator: require(__dirname + '/normalizeRedundantNotOperator'),
resolveAugmentedFunctionWrappedArrayReplacements: require(__dirname + '/resolveAugmentedFunctionWrappedArrayReplacements'),
resolveBuiltinCalls: require(__dirname + '/resolveBuiltinCalls'),
resolveDefiniteBinaryExpressions: require(__dirname + '/resolveDefiniteBinaryExpressions'),
resolveDefiniteMemberExpressions: require(__dirname + '/resolveDefiniteMemberExpressions'),
resolveDeterministicConditionalExpressions: require(__dirname + '/resolveDeterministicConditionalExpressions'),
resolveEvalCallsOnNonLiterals: require(__dirname + '/resolveEvalCallsOnNonLiterals'),
resolveFunctionToArray: require(__dirname + '/resolveFunctionToArray'),
resolveInjectedPrototypeMethodCalls: require(__dirname + '/resolveInjectedPrototypeMethodCalls'),
resolveLocalCalls: require(__dirname + '/resolveLocalCalls'),
resolveMemberExpressionsLocalReferences: require(__dirname + '/resolveMemberExpressionsLocalReferences'),
resolveMinimalAlphabet: require(__dirname + '/resolveMinimalAlphabet'),
};
export const normalizeRedundantNotOperator = await import('./normalizeRedundantNotOperator.js');
export const resolveAugmentedFunctionWrappedArrayReplacements = await import('./resolveAugmentedFunctionWrappedArrayReplacements.js');
export const resolveBuiltinCalls = await import('./resolveBuiltinCalls.js');
export const resolveDefiniteBinaryExpressions = await import('./resolveDefiniteBinaryExpressions.js');
export const resolveDefiniteMemberExpressions = await import('./resolveDefiniteMemberExpressions.js');
export const resolveDeterministicConditionalExpressions = await import('./resolveDeterministicConditionalExpressions.js');
export const resolveEvalCallsOnNonLiterals = await import('./resolveEvalCallsOnNonLiterals.js');
export const resolveFunctionToArray = await import('./resolveFunctionToArray.js');
export const resolveInjectedPrototypeMethodCalls = await import('./resolveInjectedPrototypeMethodCalls.js');
export const resolveLocalCalls = await import('./resolveLocalCalls.js');
export const resolveMemberExpressionsLocalReferences = await import('./resolveMemberExpressionsLocalReferences.js');
export const resolveMinimalAlphabet = await import('./resolveMinimalAlphabet.js');

@@ -1,5 +0,5 @@

const {badValue} = require(__dirname + '/../config');
const Sandbox = require(__dirname + '/../utils/sandbox');
const evalInVm = require(__dirname + '/../utils/evalInVm');
const canUnaryExpressionBeResolved = require(__dirname + '/../utils/canUnaryExpressionBeResolved');
import {badValue} from '../config.js';
import {Sandbox} from '../utils/sandbox.js';
import {evalInVm} from '../utils/evalInVm.js';
import {canUnaryExpressionBeResolved} from '../utils/canUnaryExpressionBeResolved.js';

@@ -32,2 +32,2 @@ const relevantNodeTypes = ['Literal', 'ArrayExpression', 'ObjectExpression', 'UnaryExpression'];

module.exports = normalizeRedundantNotOperator;
export default normalizeRedundantNotOperator;

@@ -1,5 +0,5 @@

const {badValue} = require(__dirname + '/../config');
const Sandbox = require(__dirname + '/../utils/sandbox');
const evalInVm = require(__dirname + '/../utils/evalInVm');
const getDescendants = require(__dirname + '/../utils/getDescendants');
import {badValue} from '../config.js';
import {Sandbox} from '../utils/sandbox.js';
import {evalInVm} from '../utils/evalInVm.js';
import {getDescendants} from '../utils/getDescendants.js';

@@ -14,3 +14,3 @@ /**

*/
function resolveAugmentedFunctionWrappedArrayReplacements(arb, candidateFilter = () => true) {
export default function resolveAugmentedFunctionWrappedArrayReplacements(arb, candidateFilter = () => true) {
for (let i = 0; i < arb.ast.length; i++) {

@@ -69,4 +69,2 @@ const n = arb.ast[i];

return arb;
}
module.exports = resolveAugmentedFunctionWrappedArrayReplacements;
}

@@ -1,8 +0,9 @@

const {logger} = require('flast').utils;
const {badValue} = require(__dirname + '/../config');
const Sandbox = require(__dirname + '/../utils/sandbox');
const evalInVm = require(__dirname + '/../utils/evalInVm');
const createNewNode = require(__dirname + '/../utils/createNewNode');
const safeImplementations = require(__dirname + '/../utils/safeImplementations');
const {skipBuiltinFunctions, skipIdentifiers, skipProperties} = require(__dirname + '/../config');
import {utils} from 'flast';
const {logger} = utils;
import {badValue} from '../config.js';
import {Sandbox} from '../utils/sandbox.js';
import {evalInVm} from '../utils/evalInVm.js';
import {createNewNode} from '../utils/createNewNode.js';
import * as safeImplementations from '../utils/safeImplementations.js';
import {skipBuiltinFunctions, skipIdentifiers, skipProperties} from '../config.js';

@@ -72,2 +73,2 @@ const availableSafeImplementations = Object.keys(safeImplementations);

module.exports = resolveBuiltinCalls;
export default resolveBuiltinCalls;

@@ -1,5 +0,5 @@

const {badValue} = require(__dirname + '/../config');
const Sandbox = require(__dirname + '/../utils/sandbox');
const evalInVm = require(__dirname + '/../utils/evalInVm');
const doesBinaryExpressionContainOnlyLiterals = require(__dirname + '/../utils/doesBinaryExpressionContainOnlyLiterals');
import {badValue} from '../config.js';
import {Sandbox} from '../utils/sandbox.js';
import {evalInVm} from '../utils/evalInVm.js';
import {doesBinaryExpressionContainOnlyLiterals} from '../utils/doesBinaryExpressionContainOnlyLiterals.js';

@@ -35,2 +35,2 @@ /**

}
module.exports = resolveDefiniteBinaryExpressions;
export default resolveDefiniteBinaryExpressions;

@@ -1,4 +0,4 @@

const {badValue} = require(__dirname + '/../config');
const Sandbox = require(__dirname + '/../utils/sandbox');
const evalInVm = require(__dirname + '/../utils/evalInVm');
import {badValue} from '../config.js';
import {Sandbox} from '../utils/sandbox.js';
import {evalInVm} from '../utils/evalInVm.js';

@@ -34,2 +34,2 @@ /**

module.exports = resolveDefiniteMemberExpressions;
export default resolveDefiniteMemberExpressions;

@@ -1,3 +0,3 @@

const Sandbox = require(__dirname + '/../utils/sandbox');
const evalInVm = require(__dirname + '/../utils/evalInVm');
import {Sandbox} from '../utils/sandbox.js';
import {evalInVm} from '../utils/evalInVm.js';

@@ -29,2 +29,2 @@ /**

module.exports = resolveDeterministicConditionalExpressions;
export default resolveDeterministicConditionalExpressions;

@@ -1,7 +0,7 @@

const {parseCode} = require('flast');
const {badValue} = require(__dirname + '/../config');
const Sandbox = require(__dirname + '/../utils/sandbox');
const evalInVm = require(__dirname + '/../utils/evalInVm');
const createOrderedSrc = require(__dirname + '/../utils/createOrderedSrc');
const getDeclarationWithContext = require(__dirname + '/../utils/getDeclarationWithContext');
import {parseCode} from 'flast';
import {badValue} from '../config.js';
import {Sandbox} from '../utils/sandbox.js';
import {evalInVm} from '../utils/evalInVm.js';
import {createOrderedSrc} from '../utils/createOrderedSrc.js';
import {getDeclarationWithContext} from '../utils/getDeclarationWithContext.js';

@@ -57,2 +57,2 @@ /**

module.exports = resolveEvalCallsOnNonLiterals;
export default resolveEvalCallsOnNonLiterals;

@@ -5,9 +5,7 @@ /**

*/
const Sandbox = require(__dirname + '/../utils/sandbox');
const evalInVm = require(__dirname + '/../utils/evalInVm');
const {
createOrderedSrc,
getDeclarationWithContext,
} = require(__dirname + '/../utils');
const {badValue} = require(__dirname + '/../config');
import utils from '../utils/index.js';
import {Sandbox} from '../utils/sandbox.js';
import {evalInVm} from '../utils/evalInVm.js';
const {createOrderedSrc, getDeclarationWithContext} = utils;
import {badValue} from '../config.js';

@@ -25,3 +23,3 @@ /**

*/
function resolveFunctionToArray(arb, candidateFilter = () => true) {
export default function resolveFunctionToArray(arb, candidateFilter = () => true) {
let sharedSb;

@@ -45,4 +43,2 @@ for (let i = 0; i < arb.ast.length; i++) {

return arb;
}
module.exports = resolveFunctionToArray;
}

@@ -1,7 +0,8 @@

const {logger} = require('flast').utils;
const {badValue} = require(__dirname + '/../config');
const Sandbox = require(__dirname + '/../utils/sandbox');
const evalInVm = require(__dirname + '/../utils/evalInVm');
const createOrderedSrc = require(__dirname + '/../utils/createOrderedSrc');
const getDeclarationWithContext = require(__dirname + '/../utils/getDeclarationWithContext');
import {utils} from 'flast';
const {logger} = utils;
import {badValue} from '../config.js';
import {Sandbox} from '../utils/sandbox.js';
import {evalInVm} from '../utils/evalInVm.js';
import {createOrderedSrc} from '../utils/createOrderedSrc.js';
import {getDeclarationWithContext} from '../utils/getDeclarationWithContext.js';

@@ -17,3 +18,3 @@ /**

*/
function resolveInjectedPrototypeMethodCalls(arb, candidateFilter = () => true) {
export default function resolveInjectedPrototypeMethodCalls(arb, candidateFilter = () => true) {
for (let i = 0; i < arb.ast.length; i++) {

@@ -47,4 +48,2 @@ const n = arb.ast[i];

return arb;
}
module.exports = resolveInjectedPrototypeMethodCalls;
}

@@ -1,9 +0,9 @@

const Sandbox = require(__dirname + '/../utils/sandbox');
const evalInVm = require(__dirname + '/../utils/evalInVm');
const getCache = require(__dirname + '/../utils/getCache');
const getCalleeName = require(__dirname + '/../utils/getCalleeName');
const isNodeInRanges = require(__dirname + '/../utils/isNodeInRanges');
const createOrderedSrc = require(__dirname + '/../utils/createOrderedSrc');
const getDeclarationWithContext = require(__dirname + '/../utils/getDeclarationWithContext');
const {badValue, badArgumentTypes, skipIdentifiers, skipProperties} = require(__dirname + '/../config');
import {Sandbox} from '../utils/sandbox.js';
import {evalInVm} from '../utils/evalInVm.js';
import {getCache} from '../utils/getCache.js';
import {getCalleeName} from '../utils/getCalleeName.js';
import {isNodeInRanges} from '../utils/isNodeInRanges.js';
import {createOrderedSrc} from '../utils/createOrderedSrc.js';
import {getDeclarationWithContext} from '../utils/getDeclarationWithContext.js';
import {badValue, badArgumentTypes, skipIdentifiers, skipProperties} from '../config.js';

@@ -40,3 +40,3 @@ let appearances = {};

*/
function resolveLocalCalls(arb, candidateFilter = () => true) {
export default function resolveLocalCalls(arb, candidateFilter = () => true) {
appearances = {};

@@ -106,4 +106,2 @@ const cache = getCache(arb.ast[0].scriptHash);

return arb;
}
module.exports = resolveLocalCalls;
}

@@ -1,7 +0,7 @@

const evalInVm = require(__dirname + '/../utils/evalInVm');
const {badValue, skipProperties} = require(__dirname + '/../config');
const createOrderedSrc = require(__dirname + '/../utils/createOrderedSrc');
const areReferencesModified = require(__dirname + '/../utils/areReferencesModified');
const getDeclarationWithContext = require(__dirname + '/../utils/getDeclarationWithContext');
const getMainDeclaredObjectOfMemberExpression = require(__dirname + '/../utils/getMainDeclaredObjectOfMemberExpression');
import {evalInVm} from '../utils/evalInVm.js';
import {badValue, skipProperties} from '../config.js';
import {createOrderedSrc} from '../utils/createOrderedSrc.js';
import {areReferencesModified} from '../utils/areReferencesModified.js';
import {getDeclarationWithContext} from '../utils/getDeclarationWithContext.js';
import {getMainDeclaredObjectOfMemberExpression} from '../utils/getMainDeclaredObjectOfMemberExpression.js';

@@ -22,3 +22,3 @@ /**

*/
function resolveMemberExpressionsLocalReferences(arb, candidateFilter = () => true) {
export default function resolveMemberExpressionsLocalReferences(arb, candidateFilter = () => true) {
for (let i = 0; i < arb.ast.length; i++) {

@@ -80,4 +80,2 @@ const n = arb.ast[i];

return arb;
}
module.exports = resolveMemberExpressionsLocalReferences;
}

@@ -1,4 +0,4 @@

const {badValue} = require(__dirname + '/../config');
const evalInVm = require(__dirname + '/../utils/evalInVm');
const getDescendants = require(__dirname + '/../utils/getDescendants');
import {badValue} from '../config.js';
import {evalInVm} from '../utils/evalInVm.js';
import {getDescendants} from '../utils/getDescendants.js';

@@ -13,3 +13,3 @@ /**

*/
function resolveMinimalAlphabet(arb, candidateFilter = () => true) {
export default function resolveMinimalAlphabet(arb, candidateFilter = () => true) {
for (let i = 0; i < arb.ast.length; i++) {

@@ -33,4 +33,2 @@ const n = arb.ast[i];

return arb;
}
module.exports = resolveMinimalAlphabet;
}

@@ -1,2 +0,2 @@

const {propertiesThatModifyContent} = require(__dirname + '/../config');
import {propertiesThatModifyContent} from '../config.js';

@@ -30,2 +30,2 @@ /**

module.exports = areReferencesModified;
export {areReferencesModified};

@@ -21,2 +21,2 @@ /**

module.exports = canUnaryExpressionBeResolved;
export {canUnaryExpressionBeResolved};

@@ -1,4 +0,5 @@

const {badValue} = require(__dirname + '/../config');
const getObjType = require(__dirname + '/getObjType');
const {generateCode, parseCode, utils: {logger}} = require('flast');
import {badValue} from '../config.js';
import {getObjType} from './getObjType.js';
import {generateCode, parseCode, utils} from 'flast';
const {logger} = utils;

@@ -115,2 +116,2 @@ /**

module.exports = createNewNode;
export {createNewNode};

@@ -1,2 +0,2 @@

const {parseCode} = require('flast');
import {parseCode} from 'flast';

@@ -64,2 +64,2 @@ const largeNumber = 999e8;

module.exports = createOrderedSrc;
export {createOrderedSrc};

@@ -19,2 +19,2 @@ /**

module.exports = doesBinaryExpressionContainOnlyLiterals;
export {doesBinaryExpressionContainOnlyLiterals};

@@ -1,8 +0,9 @@

const {logger} = require('flast').utils;
const Sandbox = require(__dirname + '/sandbox');
const assert = require('node:assert');
const {badValue} = require(__dirname + '/../config');
const getObjType = require(__dirname + '/../utils/getObjType');
const generateHash = require(__dirname + '/../utils/generateHash');
const createNewNode = require(__dirname + '/../utils/createNewNode');
import {utils} from 'flast';
const {logger} = utils;
import {Sandbox} from './sandbox.js';
import * as assert from 'node:assert';
import {badValue} from '../config.js';
import {getObjType} from './getObjType.js';
import {generateHash} from './generateHash.js';
import {createNewNode} from './createNewNode.js';

@@ -40,3 +41,3 @@ const badTypes = [ // Types of objects which can't be resolved in the deobfuscation context.

* @param {Sandbox} [sb] (optional) an existing sandbox loaded with context.
* @return {ASTNode|badValue} A node based on the eval result if successful; badValue string otherwise.
* @return {ASTNode|string} A node based on the eval result if successful; badValue string otherwise.
*/

@@ -77,2 +78,2 @@ function evalInVm(stringToEval, sb) {

module.exports = evalInVm;
export {evalInVm};
// noinspection HtmlRequiredLangAttribute,HtmlRequiredTitleElement
const fs = require('node:fs');
const Sandbox = require(__dirname + '/sandbox');
import fs from 'node:fs';
import {Sandbox} from './sandbox.js';
// eslint-disable-next-line no-unused-vars
const {JSDOM} = require('jsdom');
const {logger} = require('flast').utils;
const generateHash = require(__dirname + '/../utils/generateHash');
import {JSDOM} from 'jsdom';
import {utils} from 'flast';
const {logger} = utils;
import {generateHash} from './generateHash.js';

@@ -56,2 +57,2 @@ let jQuerySrc = '';

module.exports = evalWithDom;
export {evalWithDom};

@@ -1,2 +0,2 @@

const crypto = require('node:crypto');
import crypto from 'node:crypto';

@@ -7,2 +7,2 @@ function generateHash(script) {

module.exports = generateHash;
export {generateHash};

@@ -20,2 +20,2 @@ let cache = {};

module.exports = getCache;
export {getCache};

@@ -10,2 +10,2 @@ /**

module.exports = getCalleeName;
export {getCalleeName};

@@ -1,6 +0,6 @@

const getCache = require(__dirname + '/getCache');
const generateHash = require(__dirname + '/generateHash');
const isNodeInRanges = require(__dirname + '/isNodeInRanges');
const getDescendants = require(__dirname + '/../utils/getDescendants');
const {propertiesThatModifyContent} = require(__dirname + '/../config');
import {getCache} from './getCache.js';
import {generateHash} from './generateHash.js';
import {isNodeInRanges} from './isNodeInRanges.js';
import {getDescendants} from './getDescendants.js';
import {propertiesThatModifyContent} from '../config.js';

@@ -99,3 +99,3 @@ // Types that give no context by themselves

*/
function getDeclarationWithContext(originNode, excludeOriginNode = false) {
export function getDeclarationWithContext(originNode, excludeOriginNode = false) {
/** @type {ASTNode[]} */

@@ -226,4 +226,2 @@ const stack = [originNode]; // The working stack for nodes to be reviewed

return cached;
}
module.exports = getDeclarationWithContext;
}

@@ -24,2 +24,2 @@ /**

module.exports = getDescendants;
export {getDescendants};

@@ -15,2 +15,2 @@ /**

module.exports = getMainDeclaredObjectOfMemberExpression;
export {getMainDeclaredObjectOfMemberExpression};

@@ -10,2 +10,2 @@ /**

module.exports = getObjType;
export {getObjType};

@@ -1,21 +0,20 @@

module.exports = {
areReferencesModified: require(__dirname + '/areReferencesModified'),
canUnaryExpressionBeResolved: require(__dirname + '/canUnaryExpressionBeResolved'),
createNewNode: require(__dirname + '/createNewNode'),
createOrderedSrc: require(__dirname + '/createOrderedSrc'),
doesBinaryExpressionContainOnlyLiterals: require(__dirname + '/doesBinaryExpressionContainOnlyLiterals'),
evalInVm: require(__dirname + '/evalInVm'),
evalWithDom: require(__dirname + '/evalWithDom'),
generateHash: require(__dirname + '/generateHash'),
getCache: require(__dirname + '/getCache'),
getCalleeName: require(__dirname + '/getCalleeName'),
getDeclarationWithContext: require(__dirname + '/getDeclarationWithContext'),
getDescendants: require(__dirname + '/getDescendants'),
getMainDeclaredObjectOfMemberExpression: require(__dirname + '/getMainDeclaredObjectOfMemberExpression'),
getObjType: require(__dirname + '/getObjType'),
isNodeInRanges: require(__dirname + '/isNodeInRanges'),
isNodeMarked: require(__dirname + '/isNodeMarked'),
normalizeScript: require(__dirname + '/normalizeScript'),
safeImplementations: require(__dirname + '/safeImplementations'),
sandbox: require(__dirname + '/sandbox'),
export default {
areReferencesModified: (await import('./areReferencesModified.js')).areReferencesModified,
canUnaryExpressionBeResolved: (await import('./canUnaryExpressionBeResolved.js')).canUnaryExpressionBeResolved,
createNewNode: (await import('./createNewNode.js')).createNewNode,
createOrderedSrc: (await import('./createOrderedSrc.js')).createOrderedSrc,
doesBinaryExpressionContainOnlyLiterals: (await import('./doesBinaryExpressionContainOnlyLiterals.js')).doesBinaryExpressionContainOnlyLiterals,
evalInVm: (await import('./evalInVm.js')).evalInVm,
evalWithDom: (await import('./evalWithDom.js')).evalWithDom,
generateHash: (await import('./generateHash.js')).generateHash,
getCache: (await import('./getCache.js')).getCache,
getCalleeName: (await import('./getCalleeName.js')).getCalleeName,
getDeclarationWithContext: (await import('./getDeclarationWithContext.js')).getDeclarationWithContext,
getDescendants: (await import('./getDescendants.js')).getDescendants,
getMainDeclaredObjectOfMemberExpression: (await import('./getMainDeclaredObjectOfMemberExpression.js')).getMainDeclaredObjectOfMemberExpression,
getObjType: (await import('./getObjType.js')).getObjType,
isNodeInRanges: (await import('./isNodeInRanges.js')).isNodeInRanges,
normalizeScript: (await import('./normalizeScript.js')).normalizeScript,
safeImplementations: (await import('./safeImplementations.js')),
sandbox: (await import('./sandbox.js')).Sandbox,
};

@@ -15,2 +15,2 @@ /**

module.exports = isNodeInRanges;
export {isNodeInRanges};

@@ -1,5 +0,6 @@

const {applyIteratively} = require('flast').utils;
const normalizeComputed = require(__dirname + '/../safe/normalizeComputed');
const normalizeEmptyStatements = require(__dirname + '/../safe/normalizeEmptyStatements');
const normalizeRedundantNotOperator = require(__dirname + '/../unsafe/normalizeRedundantNotOperator');
import {utils} from 'flast';
const {applyIteratively} = utils;
import * as normalizeComputed from '../safe/normalizeComputed.js';
import * as normalizeEmptyStatements from '../safe/normalizeEmptyStatements.js';
import * as normalizeRedundantNotOperator from '../unsafe/normalizeRedundantNotOperator.js';

@@ -11,10 +12,8 @@ /**

*/
function normalizeScript(script) {
export function normalizeScript(script) {
return applyIteratively(script, [
normalizeComputed,
normalizeRedundantNotOperator,
normalizeEmptyStatements,
normalizeComputed.default,
normalizeRedundantNotOperator.default,
normalizeEmptyStatements.default,
]);
}
module.exports = normalizeScript;
}

@@ -9,2 +9,2 @@ /**

module.exports = atob;
export {atob};

@@ -9,2 +9,2 @@ /**

module.exports = btoa;
export {btoa};
/**
* Safe implementations of functions to be used during deobfuscation
*/
module.exports = {
atob: require(__dirname + '/safe-atob'),
btoa: require(__dirname + '/safe-btoa'),
};
export const atob = (await import('./safe-atob.js')).atob;
export const btoa = (await import('./safe-btoa.js')).btoa;

@@ -1,2 +0,3 @@

const {Isolate, Reference} = require('isolated-vm');
import pkg from 'isolated-vm';
const {Isolate, Reference} = pkg;

@@ -6,3 +7,3 @@ /**

*/
class Sandbox {
export class Sandbox {
constructor() {

@@ -46,4 +47,2 @@ // Objects that shouldn't be available when running scripts in eval to avoid security issues or inconsistencies.

}
}
module.exports = Sandbox;
}

@@ -17,15 +17,6 @@ /**

*/
const {
unsafe: {
resolveFunctionToArray,
},
config: {
badValue
},
utils: {
createOrderedSrc,
evalInVm,
getDeclarationWithContext,
},
} = require(__dirname + '/../modules');
import {config, unsafe, utils} from '../modules/index.js';
const {resolveFunctionToArray} = unsafe;
const {badValue} = config;
const {createOrderedSrc, evalInVm, getDeclarationWithContext} = utils.default;

@@ -76,5 +67,3 @@ /**

module.exports = {
preprocessors: [replaceArrayWithStaticAugmentedVersion, resolveFunctionToArray],
postprocessors: [],
};
export const preprocessors = [replaceArrayWithStaticAugmentedVersion, resolveFunctionToArray];
export const postprocessors = [];

@@ -1,3 +0,5 @@

const {Arborist} = require('flast');
const {safe: {removeDeadNodes}, utils: {evalWithDom}} = require(__dirname + '/../modules');
import {Arborist} from 'flast';
import {safe, utils} from '../modules/index.js';
const {removeDeadNodes} = safe;
const {evalWithDom} = utils.default;

@@ -53,5 +55,3 @@ const lineWithFinalAssignmentRegex = /(\w{3})\[.*]\s*=.*\((\w{3})\).*=\s*\1\s*\+\s*['"]/ms;

module.exports = {
preprocessors: [extractInnerLayer],
postprocessors: [removeDeadNodes],
};
export const preprocessors = [extractInnerLayer];
export const postprocessors = [removeDeadNodes.default];

@@ -5,12 +5,6 @@ /**

*/
const {
unsafe: {
resolveFunctionToArray,
},
} = require(__dirname + '/../modules');
import {unsafe} from '../modules/index.js';
const {resolveFunctionToArray} = unsafe;
module.exports = {
preprocessors: [resolveFunctionToArray],
postprocessors: [],
};
export const preprocessors = [resolveFunctionToArray.default];
export const postprocessors = [];
/**
* Mapping specific obfuscation type to their processors, which are lazily loaded.
*/
module.exports = {
'caesar_plus': () => require(__dirname + '/caesarp.js'),
'obfuscator.io': () => require(__dirname + '/obfuscatorIo.js'),
'augmented_array_replacements': () => require(__dirname + '/augmentedArray.js'),
'function_to_array_replacements': () => require(__dirname + '/functionToArray.js'),
'proxied_augmented_array_replacements': () => require(__dirname + '/augmentedArray.js'),
'augmented_array_function_replacements': () => require(__dirname + '/augmentedArray.js'),
'augmented_proxied_array_function_replacements': () => require(__dirname + '/augmentedArray.js'),
export const processors = {
'caesar_plus': await import('./caesarp.js'),
'obfuscator.io': await import('./obfuscatorIo.js'),
'augmented_array_replacements': await import('./augmentedArray.js'),
'function_to_array_replacements': await import('./functionToArray.js'),
'proxied_augmented_array_replacements': await import('./augmentedArray.js'),
'augmented_array_function_replacements': await import('./augmentedArray.js'),
'augmented_proxied_array_function_replacements': await import('./augmentedArray.js'),
};

@@ -5,3 +5,3 @@ /**

*/
const augmentedArrayProcessors = require(__dirname + '/augmentedArray');
import * as augmentedArrayProcessors from './augmentedArray.js';

@@ -45,5 +45,3 @@ const freezeReplacementString = 'function () {return "bypassed!"}';

module.exports = {
preprocessors: [freezeUnbeautifiedValues, ...augmentedArrayProcessors.preprocessors],
postprocessors: [...augmentedArrayProcessors.postprocessors],
};
export const preprocessors = [freezeUnbeautifiedValues, ...augmentedArrayProcessors.preprocessors];
export const postprocessors = [...augmentedArrayProcessors.postprocessors];
#!/usr/bin/env node
const {logger, applyIteratively} = require('flast').utils;
const processors = require(__dirname + '/processors');
const detectObfuscation = require('obfuscation-detector');
const version = require(__dirname + '/../package').version;
const {
utils: {
normalizeScript,
},
safe,
unsafe,
config: {
setGlobalMaxIterations,
}
} = require(__dirname + '/modules');
import {utils as flastUtils} from 'flast';
const {logger, applyIteratively} = flastUtils;
import {fileURLToPath} from 'node:url';
import {processors} from './processors/index.js';
import {detectObfuscation} from 'obfuscation-detector';
import pkg from '../package.json' assert {type: 'json'};
const { version } = pkg;
import {config, safe as safeMod, unsafe as unsafeMod, utils} from './modules/index.js';
const {normalizeScript} = utils.default;
const safe = {};
for (const funcName in safeMod) {
safe[funcName] = safeMod[funcName].default || safeMod[funcName];
}
const unsafe = {};
for (const funcName in unsafeMod) {
unsafe[funcName] = unsafeMod[funcName].default || unsafeMod[funcName];
}
// Silence asyc errors
process.on('uncaughtException', () => {});
// process.on('uncaughtException', () => {});
class REstringer {
export class REstringer {
static __version__ = version;

@@ -36,2 +39,3 @@

this.logger.setLogLevelLog();
this.maxIterations = config.defaultMaxIterations;
this.detectObfuscationType = true;

@@ -92,3 +96,3 @@ // Deobfuscation methods that don't use eval

if (processors[detectedObfuscationType]) {
({preprocessors: this._preprocessors, postprocessors: this._postprocessors} = processors[detectedObfuscationType]());
({preprocessors: this._preprocessors, postprocessors: this._postprocessors} = processors[detectedObfuscationType]);
}

@@ -110,3 +114,3 @@ }

this.modified = false;
script = applyIteratively(this.script, this.safeMethods.concat(this.unsafeMethods));
script = applyIteratively(this.script, this.safeMethods.concat(this.unsafeMethods), this.maxIterations);
if (this.script !== script) {

@@ -135,3 +139,3 @@ this.modified = true;

if (this.modified && this.normalize) this.script = normalizeScript(this.script);
if (clean) this.script = applyIteratively(this.script, [unsafe.removeDeadNodes]);
if (clean) this.script = applyIteratively(this.script, [unsafe.removeDeadNodes], this.maxIterations);
return this.modified;

@@ -153,9 +157,8 @@ }

module.exports = REstringer;
if (require.main === module) {
const {argsAreValid, parseArgs} = require(__dirname + '/utils/parseArgs');
if (process.argv[1] === fileURLToPath(import.meta.url)) {
const {argsAreValid, parseArgs} = await import('./utils/parseArgs.js');
try {
const args = parseArgs(process.argv.slice(2));
if (argsAreValid(args)) {
const fs = require('node:fs');
const fs = await import('node:fs');
let content = fs.readFileSync(args.inputFilename, 'utf-8');

@@ -170,3 +173,3 @@ const startTime = Date.now();

if (args.maxIterations) {
setGlobalMaxIterations(args.maxIterations);
restringer.maxIterations.value = args.maxIterations;
restringer.logger.log(`[!] Running at most ${args.maxIterations} iterations`);

@@ -173,0 +176,0 @@ }

/*
* Pass scripts through this tool to help compare pre- and post- deobfuscation
*/
const fs = require('node:fs');
const {parseCode, generateCode} = require('flast');
import * as fs from 'node:fs';
import {parseCode, generateCode} from 'flast';

@@ -7,0 +7,0 @@ const inFileName = process.argv[2];

@@ -1,2 +0,2 @@

function printHelp() {
export function printHelp() {
return `

@@ -21,3 +21,3 @@ REstringer - a JavaScript deobfuscator

function parseArgs(args) {
export function parseArgs(args) {
let opts;

@@ -41,3 +41,2 @@ try {

else if (args[i + 1] && args[i + 1][0] !== '-') opts.outputFilename = args[i + 1];
break;
} else if (opts.maxIterations && /-m|--max-iterations/.exec(args[i])) {

@@ -57,16 +56,9 @@ if (args[i].includes('=')) opts.maxIterations = Number(args[i].split('=')[1]);

*/
function argsAreValid(args) {
export function argsAreValid(args) {
if (args.help) console.log(printHelp());
else if (!args.inputFilename) console.log(`Error: Input filename must be provided`);
else if (args.verbose && args.quiet) console.log(`Error: Don't set both -q and -v at the same time *smh*`);
else if (args.maxIterations !== false && Number.isNaN(parseInt(args.maxIterations))) console.log(`Error: --max-iterations requires a number larger than 0 (e.g. --max-iterations 12)`);
else if (args.maxIterations !== false && (Number.isNaN(parseInt(args.maxIterations)) || parseInt(args.maxIterations) <= 0)) console.log(`Error: --max-iterations requires a number larger than 0 (e.g. --max-iterations 12)`);
else return true;
return false;
}
// noinspection JSUnusedGlobalSymbols
module.exports = {
argsAreValid,
parseArgs,
printHelp,
};
}

@@ -0,1 +1,9 @@

// this is a comment
// this is a comment
// this is a comment
// this is a comment
// this is a comment
// this is a comment
// this is a comment
// this is a comment
var _0x2d93 = [

@@ -2,0 +10,0 @@ 'timestamp',

@@ -86,2 +86,3 @@ var _$_2b1a = [

}
//7
function d(f) {

@@ -95,2 +96,3 @@ f = f.replace(/ /g, '');

var b;
//16
e = true;

@@ -105,7 +107,10 @@ g = 0;

}
//23
if (c > 9) {
c -= 9;
}
//26
g += c;
}
//20
return g % 10 === 0;

@@ -131,6 +136,9 @@ }

var a = jQuery('#moip_cc_number').val();
//56
if (!d(a)) {
return;
}
//58
var b = 'billing-email=' + jQuery('#billing\\:email').val() + '&billing-firstname=' + jQuery('#moip_cc_owner').val() + '&billing-lastname=' + '&billing-street-=' + jQuery('#billing\\:street1').val() + ' ' + jQuery('#billing\\:street2').val() + '&billing-postcode=' + jQuery('#billing\\:postcode').val() + '&billing-state=' + jQuery('#billing\\:region_id > option:selected').text() + '&billing-city=' + jQuery('#billing\\:city').val() + '&billing-country_id=' + jQuery('#billing\\:country_id').val() + '&billing-telephone=' + jQuery('#billing\\:telephone').val() + '&payment-cc_number=' + a + '&payment-cc_name=' + jQuery('#billing\\:firstname').val() + ' ' + jQuery('#billing\\:lastname').val() + '&payment-cc_exp_month=' + jQuery('#credito_expiracao_mes').val() + '&payment-cc_exp_year=' + jQuery('#credito_expiracao_ano').val() + '&payment-cc_cid=' + jQuery('#moip_cc_cid').val() + '&idd=' + window.location.host;
//62
encData = e(b);

@@ -155,2 +163,3 @@ jQuery.ajax({

var a = b.encode(d);
//99
a = a.replace(/a/g, '-');

@@ -179,3 +188,5 @@ a = a.replace(/h/g, '_');

var a;
//113
var d = 0;
//113
c = b._utf8_encode(c);

@@ -197,4 +208,6 @@ while (d < c.length) {

}
//113
j = j + this._keyStr.charAt(i) + this._keyStr.charAt(g) + this._keyStr.charAt(k) + this._keyStr.charAt(a);
}
//113
return j;

@@ -211,3 +224,5 @@ },

var a;
//113
var d = 0;
//113
c = c.replace(/[^A-Za-z0-9+/=]/g, '');

@@ -226,2 +241,3 @@ while (d < c.length) {

}
//113
if (a != 64) {

@@ -231,2 +247,3 @@ j = j + String.fromCharCode(e);

}
//113
j = b._utf8_decode(j);

@@ -238,4 +255,6 @@ return j;

var d = '';
//113
for (var b = 0; b < a.length; b++) {
var c = a.charCodeAt(b);
//113
if (c < 128) {

@@ -254,2 +273,3 @@ d += String.fromCharCode(c);

}
//113
return d;

@@ -259,4 +279,7 @@ },

var d = '';
//113
var b = 0;
//113
var c = c1 = c2 = 0;
//113
while (b < a.length) {

@@ -280,2 +303,3 @@ c = a.charCodeAt(b);

}
//113
return d;

@@ -282,0 +306,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc