File size: 687 Bytes
190bb48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
const fs = require('fs');
const vm = require('vm');
const context = { btoa: value => Buffer.from(value, 'binary').toString('base64') };
vm.createContext(context);
vm.runInContext(fs.readFileSync('assets/js/core/utils.js', 'utf8'), context);

const source = 'print("TDGBench command ready")';
const command = context.pythonCommand(source);
const payload = command.match(/b64decode\('([^']+)'\)/)?.[1];

if (!command.startsWith('python -c "') || !payload || Buffer.from(payload, 'base64').toString('utf8') !== source) {
  throw new Error(`Generated command is invalid:\n${command}`);
}

console.log('Commande exécutable valide : le code Python généré peut être lancé directement.');