Skip to content

Commit

Permalink
Update roblox test
Browse files Browse the repository at this point in the history
  • Loading branch information
noahcoolboy committed Nov 2, 2023
1 parent f4c096b commit 1c7e112
Showing 1 changed file with 44 additions and 5 deletions.
49 changes: 44 additions & 5 deletions test/roblox.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,37 @@
// Optional test for roblox detection
const USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"
const USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"

const undici = require("undici")
const funcaptcha = require("../lib")

function continueToken(tracker, challengeId, captchaId, token) {
undici.request("https://apis.roblox.com/challenge/v1/continue", {
headers: {
"user-agent": USER_AGENT,
"content-type": "application/json",
"cookie": tracker
},
method: "POST",
body: JSON.stringify({
challengeId,
challengeMetadata: JSON.stringify({
unifiedCaptchaId: captchaId,
captchaToken: token,
actionType: "Login"
}),
challengeType: "captcha"
})
}).then(async res => {
console.log(res.statusCode, await res.body.text())
if(res.statusCode == 200) {
console.log("Token accepted by roblox :D")
} else {
console.log("Token rejected by roblox :(")
console.log("Response:", await res.body.text())
}
})
}

undici.request("https://auth.roblox.com/v2/login", {
method: "POST",
}).then(async res => {
Expand All @@ -22,10 +50,13 @@ undici.request("https://auth.roblox.com/v2/login", {
"password": "Test",
})
})

const fieldData = JSON.parse(Buffer.from(res2.headers["rblx-challenge-metadata"], "base64"))
const tracker = (Array.isArray(res2.headers["set-cookie"]) ? res2.headers["set-cookie"].find(v => v.startsWith("RBXEventTrackerV2")) : response.headers["set-cookie"])?.split(";")[0] ?? undefined;
const challengeId = res2.headers["rblx-challenge-id"]
const captchaId = fieldData.unifiedCaptchaId

setTimeout(async () => {
const fieldData = JSON.parse(Buffer.from(res2.headers["rblx-challenge-metadata"], "base64"))

const token = await funcaptcha.getToken({
pkey: "476068BF-9607-4799-B53D-966BE98E2B81",
surl: "https://roblox-api.arkoselabs.com",
Expand All @@ -38,8 +69,10 @@ undici.request("https://auth.roblox.com/v2/login", {
site: "https://www.roblox.com/login",
})

if(token.token.includes("sup=1"))
return console.log("Suppressed captcha!")
if(token.token.includes("sup=1")) {
console.log("Suppressed captcha!")
return continueToken(tracker, challengeId, captchaId, token.token)
}

let session = new funcaptcha.Session(token, {
userAgent: USER_AGENT,
Expand Down Expand Up @@ -68,6 +101,12 @@ undici.request("https://auth.roblox.com/v2/login", {
} else {
console.log("Login", "Test passed!")
}

if(challenge.variant == "colour") {
console.log("Colour challenge")
await challenge.answer(0)
return continueToken(tracker, challengeId, captchaId, token.token)
}
}, 2500);
})

Expand Down

0 comments on commit 1c7e112

Please sign in to comment.