Improve Account Ticket gen

This commit is contained in:
ibratabian17
2024-10-20 17:04:22 +07:00
parent c57d708198
commit 53b24047e7
2 changed files with 241 additions and 206 deletions

View File

@@ -72,6 +72,22 @@ function addUser(profileId, userProfile) {
const dataFilePath = path.join(getSavefilePath(), `/account/profiles/user.json`);
saveUserData(dataFilePath, decryptedData);
}
// Add a new user
function addUserId(profileId, userId) {
if (decryptedData[profileId]) {
decryptedData[profileId].userId = userId;
const dataFilePath = path.join(getSavefilePath(), `/account/profiles/user.json`);
saveUserData(dataFilePath, decryptedData);
} else {
console.log(`[ACC] User ${profileId} not found`)
}
}
function updateUserTicket(profileId, Ticket) {
decryptedData[profileId.ticket] = Ticket;
const dataFilePath = path.join(getSavefilePath(), `/account/profiles/user.json`);
saveUserData(dataFilePath, decryptedData);
}
// Helper function to read the leaderboard
function readLeaderboard(isDotw = false) {
@@ -150,8 +166,14 @@ if (!decryptedData) {
loadUserData(dataFilePath);
}
// Initialize routes
exports.initroute = (app) => {
module.exports = {
loadUserData,
addUser,
addUserId,
updateUserTicket,
cachedLeaderboard,
cachedDotw,
initroute: (app) => {
// Endpoint to get profiles based on profileIds
app.get("/profile/v2/profiles", async (req, res) => {
@@ -170,6 +192,10 @@ exports.initroute = (app) => {
// If the profile is found in the local data
if (userProfile && userProfile.name) {
console.log(`[ACC] Account Found For: `, profileId);
if (!findUserFromTicket(ticket)) {
decryptedData[profileId].ticket = ticket;
console.log('[ACC] Updated Ticket For ', userProfile.name)
}
return { ...userProfile, ip: req.clientIp, ticket: '', profileId };
} else {
// If the profile is not found locally, fetch from external source
@@ -182,7 +208,7 @@ exports.initroute = (app) => {
'User-Agent': req.headers['user-agent'],
'Accept': req.headers['accept'] || '/',
'Accept-Language': 'en-us,en',
'Authorization': req.headers['authorization'] ,
'Authorization': req.headers['authorization'],
'X-SkuId': req.headers['x-skuid'],
}
});
@@ -216,6 +242,7 @@ exports.initroute = (app) => {
app.post("/profile/v2/profiles", (req, res) => {
try {
const ticket = req.header("Authorization");
const content = req.body;
content.ticket = ticket;
@@ -244,6 +271,7 @@ exports.initroute = (app) => {
// Save updated user profile data
decryptedData[matchedProfileId] = userProfile;
console.error("[ACC] Updated User ", matchedProfileId);
saveUserData(dataFilePath, decryptedData);
// Regenerate Leaderboard List
@@ -255,6 +283,9 @@ exports.initroute = (app) => {
console.error("[ACC] Can't Find UUID: ", matchedProfileId);
res.status(404).send("Profile not found.");
}
} catch (err) {
console.log(err)
}
});
@@ -381,4 +412,5 @@ exports.initroute = (app) => {
app.post("/profile/v2/filter-players", (req, res) => {
res.send(["00000000-0000-0000-0000-000000000000"]);
});
}
}
};

View File

@@ -8,8 +8,9 @@ const core = {
generateCoopCarousel: require('../carousel/carousel').generateCoopCarousel,
updateMostPlayed: require('../carousel/carousel').updateMostPlayed,
signer: require('../lib/signUrl'),
ipResolver: require('../lib/ipResolver')
ipResolver: require('../lib/ipResolver'),
};
const { addUserId, updateUserTicket } = require('./account');
const settings = require('../../settings.json');
const cachedTicket = {};
const ipCache = {}; // Cache untuk menyimpan ticket berdasarkan IP
@@ -41,7 +42,7 @@ const getCountryFromIp = (ip) => 'US';
const generateFalseTicket = () => {
const start = "ew0KIC";
const end = "KfQ==";
const middleLength = 40;
const middleLength = 60;
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let middle = '';
@@ -79,6 +80,8 @@ exports.initroute = (app, express, server) => {
const response = await axios.post(`${prodwsurl}/v3/profiles/sessions`, req.body, { headers });
res.send(response.data);
addUserId(response.data.profileId, response.data.userId)
updateUserTicket(response.data.profileId, `Ubi_v1 ${response.data.ticket}`)
console.log("[ACC] Using Official Ticket");
} catch (error) {
console.log("[ACC] Error fetching from Ubisoft services", error.message);
@@ -114,7 +117,7 @@ exports.initroute = (app, express, server) => {
serverTime: now.toISOString(),
sessionId,
sessionKey: "TqCz5+J0w9e8qpLp/PLr9BCfAc30hKlEJbN0Xr+mbZa=",
rememberMeTicket: null
rememberMeTicket: null,
};
// Cache the session based on the IP