Planet DesKel

DesKel's official page for CTF write-up, Electronic tutorial, review and etc.

13 September 2020

Webhacking.kr write-up: old-58

2 minutes to read
Link point tag
old-58 150 JavaScript

Howdy there, welcome to another webhacking.kr CTF challenge. Today’s challenge is about JavaScript.

question

This is a JavaScript-based user console, not an actual Linux CLI. We can forget about the command-line injection.

By typing help command we have the following result.

result

There are only 4 options and our main goal is the flag command.

guest

We need to escalate ourselves as an admin. How did we do that as we are assigned as a guest whenever the page is getting refreshed.

Actually, you just need thinker some of the parameters.

Step 1: Thinker the JS code

$(function () {
      var username = "admin";
      var socket = io();
      $('form').submit(function(e){
        e.preventDefault();
        socket.emit('cmd',username+":"+$('#k').val());
        $('#m_').val('');
        return false;
      });
      socket.on('cmd', function(msg){
        $('#messages').append($('<li>').text(msg));
      });
    });

After that, submit the above code to the console

submit

Step 2: Thinker the HTML

Change the input naming from m to k (The alphabet refer to the JS code)

html

That’s it, input the command and capture the flag.

solve

tags: webhacking.kr - javascript

Thanks for reading. Follow my twitter for latest update

If you like this post, consider a small donation. Much appreciated. :)


Vortex


© 2020 DesKel