Skip to content

Latest commit

 

History

History
67 lines (53 loc) · 2.89 KB

Hacker_Typer.md

File metadata and controls

67 lines (53 loc) · 2.89 KB

Challenge

Only the most leet hackers can type faster than my bot. Can you beat it?

https://hacker-typer.tuctf.com

Point = 50, Level = Easy

How I got the flag

  • I visited the webpage and there was something like typing speed calculator. I have to write the words correctly as fast as I can and maintain the streak upto 150.

    image

  • I tried to write some words and I figured out that 150 streak is not gonna easy work for me.

  • I opened the network tab to see how it is measuring the speed and streak.

    image

  • As we can see there is a function which sends a POST request to /check_word api with word in payload. It gets three properties in response.

    image image

  • Here the next word is in the response of the submission of the previous word.

  • So, I wrote a recursive function which sends a POST request to /check_word api and the function calls itself again after getting next word in response.

    function getfetch(word) {
          var wordInput = word;
          var xhr = new XMLHttpRequest();
          xhr.open("POST", "/check_word");
          xhr.setRequestHeader(
            "Content-Type",
            "application/x-www-form-urlencoded"
          );
          xhr.onload = function () {
            var wordElement = document.querySelector('strong[name="word-title"]');
            var speedElement = document.querySelector(
              'strong[name="speed-title"]'
            );
            var streakElement = document.querySelector(
              'strong[name="streak-title"]'
            );
            var statusElement = document.querySelector(
              'strong[name="status-title"]'
            );
            var inputElement = document.getElementsByName("word")[0];
            if (xhr.status === 200) {
              var response = JSON.parse(xhr.responseText);
                console.log(response);
              response.next_word && getfetch(response.next_word);
            } else {
              statusElement.textContent = "Session Expired";
              inputElement.focus();
            }
          };
          xhr.send("word=" + encodeURIComponent(wordInput));
    }
  • This function done everything for me. I called this function once in browser console and after awhile the streak became 150 and I found the flag.

    image

    image

Regards

SR Tamim