From 9618dbf1c7d3c5f97d67401c34900c5161a70569 Mon Sep 17 00:00:00 2001 From: Jonathan Barrow Date: Mon, 13 Dec 2021 08:12:42 -0500 Subject: [PATCH] Fixed account.dat generation --- package-lock.json | 16 +++++++++++++++- package.json | 3 ++- src/routers/account.js | 30 +++++++++++++++++++++++------- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8c9d79c..a823a43 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,8 @@ "gray-matter": "^4.0.3", "marked": "^3.0.4", "morgan": "^1.10.0", - "trello": "^0.11.0" + "trello": "^0.11.0", + "uuid": "^8.3.2" }, "devDependencies": { "eslint": "^7.32.0" @@ -2372,6 +2373,14 @@ "node": ">= 0.4.0" } }, + "node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/v8-compile-cache": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", @@ -4244,6 +4253,11 @@ "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" }, + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" + }, "v8-compile-cache": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", diff --git a/package.json b/package.json index cb903f0..7bba52c 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,8 @@ "gray-matter": "^4.0.3", "marked": "^3.0.4", "morgan": "^1.10.0", - "trello": "^0.11.0" + "trello": "^0.11.0", + "uuid": "^8.3.2" }, "devDependencies": { "eslint": "^7.32.0" diff --git a/src/routers/account.js b/src/routers/account.js index 0af5271..c2e603f 100644 --- a/src/routers/account.js +++ b/src/routers/account.js @@ -1,6 +1,7 @@ const { Router } = require('express'); const crypto = require('crypto'); const DiscordOauth2 = require('discord-oauth2'); +const { v4: uuidv4 } = require('uuid'); const AdmZip = require('adm-zip'); const util = require('../util'); const config = require('../../config.json'); @@ -400,11 +401,27 @@ router.get('/online-files', async (request, response) => { let decryptedPasswordHash = decipher.update(Buffer.from(request.cookies.ph, 'hex')); decryptedPasswordHash = Buffer.concat([decryptedPasswordHash, decipher.final()]); + const miiNameBuffer = Buffer.alloc(0x16); + const miiName = Buffer.from(account.mii.name, 'utf16le').swap16(); + miiName.copy(miiNameBuffer); + let accountDat = 'AccountInstance_00000000\n'; - accountDat += `AccountPasswordCache=${decryptedPasswordHash.toString('hex')}\n`; - accountDat += 'IsPasswordCacheEnabled=1\n'; + accountDat += 'PersistentId=80000001\n'; + accountDat += 'TransferableIdBase=0\n'; + accountDat += `Uuid=${uuidv4().replace(/-/g, '')}\n`; + accountDat += `MiiData=${Buffer.from(account.mii.data, 'base64').toString('hex')}\n`; + accountDat += `MiiName=${miiNameBuffer.toString('hex')}\n`; accountDat += `AccountId=${account.username}\n`; - accountDat += 'PersistentId=80000001'; + accountDat += 'BirthYear=0\n'; + accountDat += 'BirthMonth=0\n'; + accountDat += 'BirthDay=0\n'; + accountDat += 'Gender=0\n'; + accountDat += `EmailAddress=${account.email.address}\n`; + accountDat += 'Country=0\n'; + accountDat += 'SimpleAddressId=0\n'; + accountDat += `PrincipalId=${account.pid.toString(16)}\n`; + accountDat += 'IsPasswordCacheEnabled=1\n'; + accountDat += `AccountPasswordCache=${decryptedPasswordHash.toString('hex')}`; const onlineFiles = new AdmZip(); @@ -412,10 +429,9 @@ router.get('/online-files', async (request, response) => { onlineFiles.addFile('otp.bin', Buffer.alloc(0x400)); // nulled OTP onlineFiles.addFile('seeprom.bin', Buffer.alloc(0x200)); // nulled SEEPROM - response.writeHead(200, { - 'Content-Disposition': 'attachment; filename="Online Files.zip"', - 'Content-Type': 'application/zip', - }); + response.status(200); + response.set('Content-Disposition', 'attachment; filename="Online Files.zip'); + response.set('Content-Type', 'application/zip'); response.end(onlineFiles.toBuffer()); });