Share cho ae code check đúng sai của garena

truocconuong

Newbie
Joined
Aug 25, 2023
Messages
3
Reactions
3
MR
0.114
Chả là e vừa tập tành làm tool , mới code đc phần auto login của garena nên share cho ae cùng nhau học hỏi tham khảo ạ

const axios = require("axios");
const info = {
username: "chuhuumanh",
password: "chuhuumanh",
};
async function getPrelogin() {
return new Promise((resolve, reject) => {
let config = {
method: "get",
maxBodyLength: Infinity,
url: `https://sso.garena.com/api/prelogin?app_id=10100&account=${
info.username
}&format=json&id=${new Date().getTime()}`,
headers: {
Accept: "application/json, text/plain, */*",
"Accept-Language": "vi,en-US;q=0.9,en;q=0.8",
Connection: "keep-alive",
Cookie:
"_ga=GA1.1.26128831.1691742988; _ga_Y1QNJ6ZLV6=GS1.1.1692620638.1.0.1692620645.0.0.0; _ga_1M7M9L6VPX=GS1.1.1693919088.3.1.1693919245.0.0.0; datadome=6c34MIurz0vTp7mEEAbR88446VmZxLzTjLCZvcwX1ypNT1AagpHyJ-Nq_SCz76e3uIBLnjDCPSG3cFOr1c0hq8SkJWA1SykfI~QgbgyzkhDyiqZxugImyQnVA9U8cpdv",
Referer:
"https://sso.garena.com/universal/lo...count.garena.com/?locale_name=VN&locale=vi-VN",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-origin",
"User-Agent":
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36",
"sec-ch-ua":
'"Chromium";v="116", "Not)A;Brand";v="24", "Google Chrome";v="116"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": '"macOS"',
"x-datadome-clientid":
"6c34MIurz0vTp7mEEAbR88446VmZxLzTjLCZvcwX1ypNT1AagpHyJ-Nq_SCz76e3uIBLnjDCPSG3cFOr1c0hq8SkJWA1SykfI~QgbgyzkhDyiqZxugImyQnVA9U8cpdv",
},
};
axios
.request(config)
.then((response) => {
resolve(response.data);
})
.catch((error) => {
reject(error);
});
});
}
async function getLogin(password) {
return new Promise((resolve, reject) => {
const axios = require("axios");
let config = {
method: "get",
maxBodyLength: Infinity,
url: `https://sso.garena.com/api/login?app_id=10100&account=${
info.username
}&password=${password}&redirect_uri=https%3A%2F%2Faccount.garena.com%2F%3Flocale_name%3DVN&format=json&id=${new Date().getTime()}`,
headers: {
Accept: "application/json, text/plain, */*",
"Accept-Language": "vi,en-US;q=0.9,en;q=0.8",
Connection: "keep-alive",
Cookie:
"_ga=GA1.1.26128831.1691742988; _ga_Y1QNJ6ZLV6=GS1.1.1692620638.1.0.1692620645.0.0.0; _ga_1M7M9L6VPX=GS1.1.1693919088.3.1.1693919558.0.0.0; datadome=2GqV~ROOiaRRpc6bP~fBEAvfPKzjr35a0kMBN0jo3EIsTatuD6G4_9j-ydq9Gvc3IvlRJVKORI_zK6auOrO8klDdNMD7-kdJZT0moINr~JD_RDwVVmxQvrj-KTmKYmSY",
Referer:
"https://sso.garena.com/universal/lo...count.garena.com/?locale_name=VN&locale=vi-VN",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-origin",
"User-Agent":
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36",
"sec-ch-ua":
'"Chromium";v="116", "Not)A;Brand";v="24", "Google Chrome";v="116"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": '"macOS"',
"x-datadome-clientid":
"2GqV~ROOiaRRpc6bP~fBEAvfPKzjr35a0kMBN0jo3EIsTatuD6G4_9j-ydq9Gvc3IvlRJVKORI_zK6auOrO8klDdNMD7-kdJZT0moINr~JD_RDwVVmxQvrj-KTmKYmSY",
},
};
axios
.request(config)
.then((response) => {
resolve(response.data);
})
.catch((error) => {
reject(error);
});
});
}
async function run() {
const g = require("crypto-js");
const o = await getPrelogin();
const s = g.MD5(info.password);
const b = g.SHA256(g.SHA256(s + o.v1) + o.v2);
const M = g.AES.encrypt(s, b, {
mode: g.mode.ECB,
padding: g.pad.NoPadding,
}).toString(g.format.Hex);
const login = await getLogin(M);
console.log(login);
}
run();
 

Announcements

Forum statistics

Threads
419,486
Messages
7,086,593
Members
171,530
Latest member
DuckAnt

Most viewed of week

Most discussed of week

Most viewed of week

Most discussed of week

Back
Top Bottom