vicety
vicety

Reputation: 1

sessionID not found or inactive

I'm currently trying to recreate an proof-of-work captcha solver. While trying to send that sessionID to an api, it gives me this response "{"statusCode":404,"statusText":"Not Found","errors":[{"code":3,"message":"session not found or inactive"}]}"

import json
import requests
from Solver import TimeLockPuzzleSolver
from bs4 import BeautifulSoup
import re

def csrf_al():
    headers = {
        'authority': 'www.roblox.com',
        'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
        'accept-language': 'tr-TR,tr;q=0.9,en-US;q=0.8,en;q=0.7',
        'cache-control': 'no-cache',
        'pragma': 'no-cache',
        'referer': 'https://www.roblox.com/login',
        'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"',
        'sec-ch-ua-mobile': '?1',
        'sec-ch-ua-platform': '"Android"',
        'sec-fetch-dest': 'document',
        'sec-fetch-mode': 'navigate',
        'sec-fetch-site': 'same-origin',
        'sec-fetch-user': '?1',
        'upgrade-insecure-requests': '1',
        'user-agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36',
    }

    response = requests.get('https://www.roblox.com/home', headers=headers).text
    soup = BeautifulSoup(response, "html.parser")
    csrf = soup.find_all("meta", {"name": "csrf-token"})
    csrf_t = re.findall('n="\S+"', str(csrf))
    session_id = str(csrf_t[0]).strip('n=""')
    print(session_id)
    return session_id

sessionID = csrf_al()

req_url = "https://apis.roblox.com/proof-of-work-service/v1/pow-puzzle"
req_params = {"sessionID": sessionID}

response = requests.get(req_url, params=req_params)

if response.status_code != 200:
    raise Exception("Failed to get puzzle " + response.text)

result = response.json()

puzzleType = result["puzzleType"]
artifacts = result["artifacts"]
artifacts = json.loads(artifacts)
artifacts = {
    "N": int(artifacts["N"]),
    "A": int(artifacts["A"]),
    "T": int(artifacts["T"]),
}

solver = TimeLockPuzzleSolver(artifacts)
solution = solver.run()

req_json = {
    "sessionID": sessionID,
    "solution": solution,
}

response = requests.post(req_url, json=req_json)

print(" Response: " + response.text)

I've tried to fetch it with csrf token, but haven't helped me out. Please, let me know about this issue.

Upvotes: 0

Views: 26

Answers (0)

Related Questions