From f3e78ef8dbf6d89999fdfe1a4022ef97c67a7514 Mon Sep 17 00:00:00 2001 From: Minteck <46352972+Minteck@users.noreply.github.com> Date: Wed, 7 Jul 2021 22:21:32 +0200 Subject: 21.07 --- app.js | 27 +++++ package.json | 2 +- signing/sign.js | 23 ++++ views/game.html | 10 ++ views/load.html | 6 ++ views/script/game_debug.js | 261 +++++++++++++++++++++++++++++++++++++++++++++ views/splash.png | Bin 205335 -> 209449 bytes 7 files changed, 328 insertions(+), 1 deletion(-) create mode 100644 signing/sign.js create mode 100644 views/script/game_debug.js diff --git a/app.js b/app.js index 1b9ab13..c82f9bd 100644 --- a/app.js +++ b/app.js @@ -317,6 +317,33 @@ const { app, BrowserWindow } = require('electron'); }) load.loadFile("./views/load.html"); setTimeout(() => { + console.log(" * Checking signatures"); + + sigdb = require("./bin/signatures.json"); + total = Object.keys(sigdb).length; + processed = 0; + for (file in sigdb) { + if (fs.existsSync(file)) { + try { + hash = require('crypto').createHash('sha512').update(fs.readFileSync(file)).digest('base64'); + if (hash !== sigdb[file]) { + require('electron').dialog.showMessageBoxSync( + { + type: "warning", + title: "Source modification detected", + message: "File " + file + " has been flagged as modified. If this is normal, please run the signing process again.\n\nExpected: " + sigdb[file] + "\nGot: " + hash + "\n\nYou are running a modified version of Kartik, do not expect to get support!" + } + ) + } + } catch (e) { + console.warn(" ! Could not compute hash for " + file); + } + } + + processed++; + load.webContents.send('progress', (processed/total)*100); + } + console.log(" * Generating resources pack"); require('./modding/resources'); console.log(" * Starting Kartik Modding Platform"); diff --git a/package.json b/package.json index 234368b..0ac3efe 100644 --- a/package.json +++ b/package.json @@ -1 +1 @@ -{"name":"kartik","version":"ce99cfa","channel":"git","description":"A multiplatform 2D karting game","main":"app.js","dependencies":{"@electron/remote":"^1.0.4","discord-rpc":"^3.2.0","electron":"^12.0.1","ini":"^1.3.8","jquery":"^3.6.0","os-locale":"^5.0.0","systeminformation":"^5.7.7","uuid":"^8.3.2","yaml":"^1.10.2"},"scripts":{"test":"node_modules\\electron\\dist\\electron.exe app.js"},"author":"Minteck Projects","license":"GPL-3.0-or-later","serial":"XXX99999999999"} \ No newline at end of file +{"name":"kartik","version":"adabd5f","channel":"git","description":"A multiplatform 2D karting game","main":"app.js","dependencies":{"@electron/remote":"^1.0.4","discord-rpc":"^3.2.0","electron":"^12.0.1","ini":"^1.3.8","jquery":"^3.6.0","os-locale":"^5.0.0","systeminformation":"^5.7.7","uuid":"^8.3.2","yaml":"^1.10.2"},"scripts":{"test":"node_modules\\electron\\dist\\electron.exe app.js"},"author":"Minteck Projects","license":"GPL-3.0-or-later","serial":"XXX99999999999"} \ No newline at end of file diff --git a/signing/sign.js b/signing/sign.js new file mode 100644 index 0000000..116a6a9 --- /dev/null +++ b/signing/sign.js @@ -0,0 +1,23 @@ +const fs = require('fs'); +const crypto = require('crypto'); +global.sdb = {}; + +function scan(start) { + rt = fs.readdirSync(start); + for (file of rt) { + if (file !== ".git" && file !== "build" && file !== "signatures.json" && file !== "staging" && file !== "node_modules" && !file.endsWith(".staging") && !file.endsWith(".old") && file !== "_translate") { + if (fs.lstatSync(start + "/" + file).isDirectory()) { + scan(start + "/" + file); + } else { + sign = crypto.createHash('sha512').update(fs.readFileSync(start + "/" + file)).digest('base64') + console.log("Signed: " + start + "/" + file + ": " + sign); + sdb[(start + "/" + file).substr(1)] = sign; + } + } + } +} + +scan(".."); +scan("../node_modules/electron"); +scan("../node_modules/@electron"); +fs.writeFileSync("../bin/signatures.json", JSON.stringify(sdb)); \ No newline at end of file diff --git a/views/game.html b/views/game.html index f40b777..ca402a5 100644 --- a/views/game.html +++ b/views/game.html @@ -136,6 +136,15 @@ + + @@ -147,6 +156,7 @@ + diff --git a/views/load.html b/views/load.html index d19b8b7..c6e45bf 100644 --- a/views/load.html +++ b/views/load.html @@ -33,8 +33,14 @@ +