In the top left corner of the Dining Room, Ribb Bonbowford stands next to an arcade game, The Elf Code:
Hello - my name is Ribb Bonbowford. Nice to meet you!
Are you new to programming? It’s a handy skill for anyone in cyber security.
This challenge centers around JavaScript. Take a look at this intro and see how far it gets you!
Ready to move beyond elf commands? Don’t be afraid to mix in native JavaScript.
Trying to extract only numbers from an array? Have you tried to filter?
Maybe you need to enumerate an object’s keys and then filter?
Getting hung up on number of lines? Maybe try to minify your code.
Is there a way to push array items to the beginning of an array? Hmm…
There’s a series of seven JavaScript-based challenges that involve moving my elf around a grid, avoiding obsticles and answering challenges to progress. Each level is solved with a limited number of Javascript lines.
#1
Program the elf to the end goal in no more than 2 lines of code and no more than 2 elf commands.
</picture>
elf.moveLeft(10)elf.moveUp(10)
Completed in 2 elf statements.
#2
Program the elf to the end goal in no more than 5 lines of code and no more than 5 elf command/function execution statements in your code.
</picture>
To turn off the Yeeter, I’ll need to move to the level, call elf.get_lever(0), add two to the returned value, and submit it with elf.pull_lever(result).
Program the elf to the end goal in no more than 15 lines of code and no more than 7 elf command/function execution statements in your code.
</picture>
To solve the munchkin, I’ll need to get a json object from him, and return the name of the key that holds the value “lollipop”.
for (i=0;i<4;i++){elf.moveTo(lollipop[i]);}elf.moveLeft(8);elf.moveUp(2);varfrom_munch=elf.ask_munch(0);constkeys=Object.keys(from_munch);for (keyofkeys){if (from_munch[key]=="lollipop"){elf.tell_munch(key);}}elf.moveUp(2);
Completed in 6 elf statements.
#7 - Bonus
Program the elf to the end goal in no more than 25 lines of code and no more than 10 elf command/function execution statements in your code.
</picture>
This level is full of challenges to disable. To pull the lever, I just need to elf.pull_lever(#) while standing on that lever. The munchkin is much more complex. I need to write a function that takes one argument that is an array of arrays, and returns the sum of all numbers in those arrays.
Ribb suggests I might use my JavaScript skills on the Santavator:
Wow - are you a JavaScript developer? Great work!
Hey, you know, you might use your JavaScript and HTTP manipulation skills to take a crack at bypassing the Santavator’s S4.
No badget hints for this one.
Santavator Floor 3
In objective 4, I looked at the JavaScript for the Santavator and how to bypass the S4 stream to enable the buttons. There’s extra security around Santa’s Office, floor 3. When that button is pushed, instead of going there, a fingerprint sensor is revealed:
Clicking on it as a non-Santa player just makes a buzz noise. As Santa, it works and I’m taken to Santa’s Office.
JavaScript
Previous Work from Obj 4
The Santavator panel is run by script loaded from elevator.kringlecastle.com, specifically app.js:
In Objective 4, I looked at adding the powered class to each button but changing the checks in the renderTraps function:
Just from this I can tell that btn4 is the floor 3 button, as it’s the only one that requires all three S4 streams to turn on. I can just change that in the Chrome dev tools to:
btn4.classList['add']('powered');
And now that button is powered:
Additional RE
Looking around a bit more, I see where the buttons are set to the btn variables, and how clicks are handled:
The handle function for btn4 is different than the others. The handleBtn function gets the floor from the button pushed, and then makes an AJAX web call:
First, it add the class open to the cover object, and it adds an event listener for a click. When the fingerprint reader is clicked, there’s one more if before making the AJAX call that takes the player to Santa’s Office:
if (btn4.classList.contains('powered')&&hasToken('besanta')){
hastoken is a one line function that checks if a string is in the array tokens that is created when the page loads: