hackergame2022-writeups icon indicating copy to clipboard operation
hackergame2022-writeups copied to clipboard

Solution for Xcaptcha (tampermonkey)

Open Leisurelybear opened this issue 2 years ago • 1 comments

create a tampermonkey script and enable it.


// default settings...
// ...
// @match        http://202.38.93.111:10047/xcaptcha
// ...

(function() {
    'use strict';

    // Your code here...
    let btn = document.getElementById("submit")
    
    // calsulate the first one
    let nums = document.querySelector("body > div > form > div:nth-child(1) > label").innerHTML.split(" ")[0].split("+")
    let sum = (BigInt(nums[0])+BigInt(nums[1])).toString()
    document.querySelector("#captcha1").value=sum

    // second
    nums = document.querySelector("body > div > form > div:nth-child(2) > label").innerHTML.split(" ")[0].split("+")
    sum = (BigInt(nums[0])+BigInt(nums[1])).toString()
    document.querySelector("#captcha2").value=sum

    // third
    nums = document.querySelector("body > div > form > div:nth-child(3) > label").innerHTML.split(" ")[0].split("+")
    sum = (BigInt(nums[0])+BigInt(nums[1])).toString()
    document.querySelector("#captcha3").value=sum

    btn.click()

})();

Leisurelybear avatar Oct 30 '22 07:10 Leisurelybear

A better version:

// ==UserScript==
// @name         Xcaptcha
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       Steven-nagisa-Y
// @match        http://202.38.93.111:10047/xcaptcha
// @icon         https://www.google.com/s2/favicons?sz=64&domain=93.111
// @run-at       document-end
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    window.onload = () => {
        let c = 1;
        for (const i of document.getElementsByTagName("label")) {
            let [_, n1, n2] = /(\d+)\+(\d+)/.exec(i.innerText);
            n1 = BigInt(n1);
            n2 = BigInt(n2);
            let a = n1 + n2;
            document.getElementById(`captcha${c}`).value = a.toString();
            c++;
            if (c == 4) document.getElementById("submit").click();
        }
    };
})();

Steven-nagisa-Y avatar Oct 30 '22 08:10 Steven-nagisa-Y