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

22
app.js
View File

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

View File

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

View File

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

View File

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

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();