remove wincript(PASSWORD IS PLAIN IN CONFIG FOR NOW!) make linux compatible
This commit is contained in:
parent
37567b5767
commit
67de9b7c16
64
app.js
64
app.js
@ -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,34 +20,44 @@ const run = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setInterval(() => {
|
setInterval(async () => {
|
||||||
osuWindowInfo = windowName.getWindowText("osu!.exe");
|
if (platform == "win32") {
|
||||||
const firstInstance = osuWindowInfo[0];
|
osuWindowInfo = windowName.getWindowText("osu!.exe");
|
||||||
if (firstInstance) {
|
const firstInstance = osuWindowInfo[0];
|
||||||
if (firstInstance.processTitle && firstInstance.processTitle.length > 0) {
|
if (firstInstance) {
|
||||||
const windowTitle = firstInstance.processTitle;
|
if (firstInstance.processTitle && firstInstance.processTitle.length > 0) {
|
||||||
let rpcOsuVersion = "";
|
const windowTitle = firstInstance.processTitle;
|
||||||
let currentMap = undefined;
|
let rpcOsuVersion = "";
|
||||||
if (!windowTitle.includes("-")) {
|
let currentMap = undefined;
|
||||||
rpcOsuVersion = windowTitle;
|
if (!windowTitle.includes("-")) {
|
||||||
rpc.updateState("Idle...");
|
rpcOsuVersion = windowTitle;
|
||||||
} else {
|
rpc.updateState("Idle...");
|
||||||
var string = windowTitle;
|
} else {
|
||||||
var components = string.split(' - ');
|
var string = windowTitle;
|
||||||
const splitArray = [components.shift(), components.join(' - ')];
|
var components = string.split(' - ');
|
||||||
rpcOsuVersion = splitArray[0];
|
const splitArray = [components.shift(), components.join(' - ')];
|
||||||
currentMap = splitArray[1];
|
rpcOsuVersion = splitArray[0];
|
||||||
rpc.updateState("Playing...");
|
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 {
|
} else {
|
||||||
rpc.updateState("Idle in Launcher...");
|
rpc.updateState("Idle in Launcher...");
|
||||||
rpc.updateStatus(undefined, undefined);
|
rpc.updateStatus(undefined, undefined);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rpc.updateState("Idle in Launcher...");
|
if(isIngame){
|
||||||
rpc.updateStatus(undefined, undefined);
|
rpc.updateState("Playing...");
|
||||||
|
rpc.updateStatus("Clicking circles!", "runningunderwine");
|
||||||
|
}else{
|
||||||
|
rpc.updateState("Idle in Launcher...");
|
||||||
|
rpc.updateStatus(undefined, undefined);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, 2000);
|
}, 2000);
|
||||||
|
|
||||||
@ -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', {
|
||||||
|
@ -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/)
|
||||||
|
25
osuUtil.js
25
osuUtil.js
@ -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;
|
||||||
executeUtil.runFile(osuPath, osuExe, ["-devserver", serverDomain], onExit);
|
switch (process.platform) {
|
||||||
return true;
|
case "linux":
|
||||||
}
|
executeUtil.runFile(osuPath, 'osu-stable', ["-devserver", serverDomain], onExit);
|
||||||
|
return true;
|
||||||
async function encryptString(value) {
|
case "win32":
|
||||||
return Buffer.from(await dpapi.protect(Buffer.from(value, 'utf-8'), osuEncryptBuffer, 'CurrentUser'), 'utf-8').toString('base64');
|
executeUtil.runFile(osuPath, osuExe, ["-devserver", serverDomain], onExit);
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
async function decryptString(value) {
|
return false;
|
||||||
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
|
|
||||||
}
|
}
|
@ -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"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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();
|
|
Loading…
Reference in New Issue
Block a user