reverse-shell-generator/parcel-transformer-obfuscation/src/index.js
2022-03-20 14:24:15 +00:00

23 lines
609 B
JavaScript

const parcel = require('@parcel/plugin');
function base64(value) {
return Buffer.from(value).toString('base64');
}
module.exports = new parcel.Transformer({
loadConfig({ config, options }) {
return config
},
async transform({ asset, config, options, logger}) {
const source = await asset.getCode();
// Replace the asset with the 'obfuscated' script that will be evaluated on page load
const obfuscated_source = base64(source)
asset.setCode(`Function(atob("${obfuscated_source}"))();`);
asset.setMap(null);
return [asset];
}
});