remove wincript(PASSWORD IS PLAIN IN CONFIG FOR NOW!) make linux compatible

This commit is contained in:
HorizonCode 2022-10-23 01:08:58 +02:00
parent 37567b5767
commit 67de9b7c16
5 changed files with 51 additions and 70 deletions

64
app.js
View File

@ -10,6 +10,8 @@ const windowName = require('get-window-by-name');
let tempOsuPath;
let osuWindowInfo;
let isIngame;
const platform = process.platform;
const run = () => {
const gotTheLock = app.requestSingleInstanceLock()
@ -18,34 +20,44 @@ const run = () => {
return;
}
setInterval(() => {
osuWindowInfo = windowName.getWindowText("osu!.exe");
const firstInstance = osuWindowInfo[0];
if (firstInstance) {
if (firstInstance.processTitle && firstInstance.processTitle.length > 0) {
const windowTitle = firstInstance.processTitle;
let rpcOsuVersion = "";
let currentMap = undefined;
if (!windowTitle.includes("-")) {
rpcOsuVersion = windowTitle;
rpc.updateState("Idle...");
} else {
var string = windowTitle;
var components = string.split(' - ');
const splitArray = [components.shift(), components.join(' - ')];
rpcOsuVersion = splitArray[0];
currentMap = splitArray[1];
rpc.updateState("Playing...");
}
setInterval(async () => {
if (platform == "win32") {
osuWindowInfo = windowName.getWindowText("osu!.exe");
const firstInstance = osuWindowInfo[0];
if (firstInstance) {
if (firstInstance.processTitle && firstInstance.processTitle.length > 0) {
const windowTitle = firstInstance.processTitle;
let rpcOsuVersion = "";
let currentMap = undefined;
if (!windowTitle.includes("-")) {
rpcOsuVersion = windowTitle;
rpc.updateState("Idle...");
} else {
var string = windowTitle;
var components = string.split(' - ');
const splitArray = [components.shift(), components.join(' - ')];
rpcOsuVersion = splitArray[0];
currentMap = splitArray[1];
rpc.updateState("Playing...");
}
rpc.updateStatus(currentMap, rpcOsuVersion);
rpc.updateStatus(currentMap, rpcOsuVersion);
} else {
rpc.updateState("Idle in Launcher...");
rpc.updateStatus(undefined, undefined);
}
} else {
rpc.updateState("Idle in Launcher...");
rpc.updateStatus(undefined, undefined);
}
} else {
rpc.updateState("Idle in Launcher...");
rpc.updateStatus(undefined, undefined);
if(isIngame){
rpc.updateState("Playing...");
rpc.updateStatus("Clicking circles!", "runningunderwine");
}else{
rpc.updateState("Idle in Launcher...");
rpc.updateStatus(undefined, undefined);
}
}
}, 2000);
@ -77,14 +89,16 @@ const run = () => {
await osuUtil.setConfigValue(osuConfig.path, "SaveUsername", "1");
await osuUtil.setConfigValue(osuConfig.path, "SavePassword", "1");
await osuUtil.setConfigValue(osuConfig.path, "Username", username);
await osuUtil.setConfigValue(osuConfig.path, "Password", await osuUtil.decryptString(password));
await osuUtil.setConfigValue(osuConfig.path, "Password", password);
await osuUtil.setConfigValue(osuConfig.path, "CredentialEndpoint", "ez-pp.farm");
} else {
await osuUtil.setConfigValue(osuConfig.path, "Username", "");
await osuUtil.setConfigValue(osuConfig.path, "Password", "");
}
rpc.updateState("Launching osu!...");
isIngame = true;
const result = await osuUtil.startOsuWithDevServer(tempOsuPath, "ez-pp.farm", async () => {
isIngame = false;
await doUpdateCheck(mainWindow);
});
return result;
@ -151,7 +165,7 @@ const run = () => {
const loginData = await ezppUtil.performLogin(username, password);
if (loginData && loginData.code === 200) {
await config.set("username", username);
await config.set("password", await osuUtil.encryptString(password));
await config.set("password", password);
}
return loginData;
})
@ -173,7 +187,7 @@ async function tryLogin(window) {
const username = await config.get("username", "");
const password = await config.get("password", "");
if ((username && username.length > 0) && (password && password.length > 0)) {
const passwordPlain = await osuUtil.decryptString(password);
const passwordPlain = password;
const loginResponse = await ezppUtil.performLogin(username, passwordPlain);
if (loginResponse && loginResponse.code === 200) {
window.webContents.send('account_update', {

View File

@ -1,14 +1,13 @@
const path = require('path');
const fs = require('fs');
const configFolder = path.join(process.env['LOCALAPPDATA'], 'EZPPLauncher');
const configFolder = path.join(process.platform == "win32" ? process.env['LOCALAPPDATA'] : process.env['HOME'], 'EZPPLauncher');
if (!fs.existsSync(configFolder)) fs.mkdirSync(configFolder);
const configLocation = path.join(configFolder, `ezpplauncher.${path.basename(process.env['USERNAME'])}.cfg`);
if (!fs.existsSync(configLocation)) fs.writeFileSync(configLocation, "");
async function get(key, defaultValue) {
const fileStream = await fs.promises.readFile(configLocation, "utf-8");
const lines = fileStream.split(/\r?\n/)

View File

@ -3,13 +3,11 @@ const fu = require('./fileUtil');
const path = require('path');
const crypto = require('crypto');
const axios = require('axios').default;
const dpapi = require('wincrypt');
const executeUtil = require('./executeUtil');
const { EventEmitter } = require('events');
const { DownloaderHelper } = require('node-downloader-helper');
const checkUpdateURL = "https://osu.ppy.sh/web/check-updates.php?action=check&stream=";
const osuEncryptBuffer = Buffer.from('cu24180ncjeiu0ci1nwui', "utf-8")
const osuEntities = [
'avcodec-51.dll',
'avformat-52.dll',
@ -143,17 +141,15 @@ async function downloadUpdateFiles(osuPath, filesToUpdate) {
async function startWithDevServer(osuPath, serverDomain, onExit) {
const osuExe = path.join(osuPath, "osu!.exe");
if (!await fu.existsAsync(osuExe)) return false;
executeUtil.runFile(osuPath, osuExe, ["-devserver", serverDomain], onExit);
return true;
}
async function encryptString(value) {
return Buffer.from(await dpapi.protect(Buffer.from(value, 'utf-8'), osuEncryptBuffer, 'CurrentUser'), 'utf-8').toString('base64');
}
async function decryptString(value) {
const decrypted = await dpapi.unprotect(Buffer.from(value, 'base64'), osuEncryptBuffer, 'CurrentUser');
return decrypted.toString();
switch (process.platform) {
case "linux":
executeUtil.runFile(osuPath, 'osu-stable', ["-devserver", serverDomain], onExit);
return true;
case "win32":
executeUtil.runFile(osuPath, osuExe, ["-devserver", serverDomain], onExit);
return true;
}
return false;
}
async function setConfigValue(configPath, key, value) {
@ -178,6 +174,5 @@ async function setConfigValue(configPath, key, value) {
module.exports = {
isValidOsuFolder, getLatestConfig, getUpdateFiles, filesThatNeedUpdate,
downloadUpdateFiles, startOsuWithDevServer: startWithDevServer, setConfigValue,
encryptString, decryptString
downloadUpdateFiles, startOsuWithDevServer: startWithDevServer, setConfigValue
}

View File

@ -55,7 +55,6 @@
"get-window-by-name": "^2.0.0",
"jquery": "^3.6.0",
"node-downloader-helper": "^2.1.4",
"sweetalert2": "^11.5.2",
"wincrypt": "^1.5.0"
"sweetalert2": "^11.5.2"
}
}

View File

@ -1,26 +0,0 @@
const dpapi = require('wincrypt');
const entropyBuffer = Buffer.from('cu24180ncjeiu0ci1nwui', 'utf-8');
const run = async () => {
const stringToEncrypt = "Test123456!";
const encrypted = await encryptString(stringToEncrypt)
console.log(encrypted);
const decrypted = await decryptString(encrypted);
console.log(decrypted);
}
async function encryptString(value) {
const encryptedString = await dpapi.protect(Buffer.from(value, 'utf-8'), entropyBuffer, 'CurrentUser');
const encodedBase64 = Buffer.from(encryptedString, 'utf-8').toString('base64');
return encodedBase64;
}
async function decryptString(value) {
const decrypted = await dpapi.unprotect(Buffer.from(value, 'base64'), entropyBuffer, 'CurrentUser');
return decrypted.toString();
}
run();