Skip to content

Instantly share code, notes, and snippets.

@struppigel
Created September 6, 2026 05:49
Show Gist options
  • Select an option

  • Save struppigel/4dd16df7c382f6b50a2fba169b8eac0b to your computer and use it in GitHub Desktop.

Select an option

Save struppigel/4dd16df7c382f6b50a2fba169b8eac0b to your computer and use it in GitHub Desktop.
JS hook script stub
module.paths.unshift(
"modulepathes"
);
const originalLog = console.log.bind(console)
function log(message){
originalLog(message);
}
// hook on require
const originalRequire = module.constructor.prototype.require;
// modify original with logging
module.constructor.prototype.require = function (id) {
if (this.filename.includes("app.protected.jsc") ){
log("REQUIRE caller:" + this.filename + " id:" + id);
}
// call original thing in modified function
return originalRequire.apply(this, arguments);
}
const cp = require("child_process");
const origExec = cp.exec;
cp.exec = function (cmd, ...args) {
log("EXEC " + String(cmd));
return origExec.apply(this, arguments);
};
const ax = require("axios");
["get", "post", "put"].forEach((m) => {
const originalAx = ax[m];
ax[m] = function(url) {
log(m.toUpperCase()+ " " + url );
return originalAx.apply(this, arguments);
}
})
require("bytenode");
require("path-to-app.protected.jsc");
log("done");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment