New commit
- Added ban checking ⚖️ - GUI 🪟 - HWID Checking/Creating module ⚙
This commit is contained in:
parent
3a81447b9c
commit
6c4948d0b2
43
app/assets/css/banned.css
Normal file
43
app/assets/css/banned.css
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
@import url("https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100..900;1,100..900&display=swap");
|
||||||
|
|
||||||
|
* {
|
||||||
|
margin: 0px;
|
||||||
|
padding: 0px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background-color: #262626;
|
||||||
|
}
|
||||||
|
|
||||||
|
main > article > section > img {
|
||||||
|
width: 150px;
|
||||||
|
}
|
||||||
|
|
||||||
|
main > article {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap ;
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
main > article > section.informations {
|
||||||
|
width: 363px;
|
||||||
|
color: #ffffff;
|
||||||
|
padding: 13px 13px 13px 13px;
|
||||||
|
font-weight: bolder;
|
||||||
|
text-align: center;
|
||||||
|
font-family: "Roboto", sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
main > article > section.informations > h2 {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
main > article > section.informations > p {
|
||||||
|
font-weight: lighter;
|
||||||
|
text-align: left;
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
BIN
app/assets/img/Catboat_Logo-04.png
Normal file
BIN
app/assets/img/Catboat_Logo-04.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 420 KiB |
11
app/assets/js/banned.js
Normal file
11
app/assets/js/banned.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
function setBannedBy(banner) {
|
||||||
|
document.querySelector("#bannedBy").innerText = banner
|
||||||
|
}
|
||||||
|
|
||||||
|
function setBannedAt(date) {
|
||||||
|
document.querySelector("#bannedAt").innerText = date
|
||||||
|
}
|
||||||
|
|
||||||
|
function setBannedBecause(reason) {
|
||||||
|
document.querySelector("#bannedBecause").innerText = reason
|
||||||
|
}
|
||||||
49
app/banned.html
Normal file
49
app/banned.html
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link rel="stylesheet" href="./assets/css/banned.css">
|
||||||
|
<title>Launcher banni</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<main>
|
||||||
|
<article>
|
||||||
|
<section class="logo">
|
||||||
|
<img src="./assets/img/Catboat_Logo-04.png" alt="">
|
||||||
|
</section>
|
||||||
|
<section class="informations">
|
||||||
|
<h2>Votre launcher à été bannis.</h2>
|
||||||
|
<p>
|
||||||
|
<b>
|
||||||
|
Par :
|
||||||
|
</b>
|
||||||
|
<span id="bannedBy">
|
||||||
|
Administrateur
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<b>
|
||||||
|
Effectué le :
|
||||||
|
</b>
|
||||||
|
<span id="bannedAt">
|
||||||
|
01/01/1970 00:00
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<b>
|
||||||
|
Raison :
|
||||||
|
</b>
|
||||||
|
<span id="bannedBecause">
|
||||||
|
Launcher non conforme aux CGU
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
</article>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<script src="./assets/js/banned.js"></script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Document</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -2,7 +2,8 @@
|
|||||||
"api": {
|
"api": {
|
||||||
"base": "http://localhost:8535",
|
"base": "http://localhost:8535",
|
||||||
"endpoints": {
|
"endpoints": {
|
||||||
"fileHash": "/api/v1/file/hash/"
|
"fileHash": "/api/v1/file/hash/",
|
||||||
|
"checkBanStatus": "/api/v1/ban/iam"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
34
main.js
34
main.js
@ -1,9 +1,12 @@
|
|||||||
const { BrowserWindow, app, net, dialog } = require("electron")
|
const { BrowserWindow, app, net, dialog } = require("electron")
|
||||||
|
const hwid = require("./modules/hwid")
|
||||||
const path = require("node:path")
|
const path = require("node:path")
|
||||||
|
const config = require("./config.json")
|
||||||
let launcherWindow
|
let launcherWindow
|
||||||
|
|
||||||
async function createLauncherWindow() {
|
async function createLauncherWindow() {
|
||||||
if (net.isOnline()) {
|
if (net.isOnline()) {
|
||||||
|
const isLauncherNotBanned = await checkIfIAmBanned()
|
||||||
launcherWindow = new BrowserWindow({
|
launcherWindow = new BrowserWindow({
|
||||||
frame: false,
|
frame: false,
|
||||||
width: 900,
|
width: 900,
|
||||||
@ -13,12 +16,43 @@ async function createLauncherWindow() {
|
|||||||
titleBarStyle: "hidden",
|
titleBarStyle: "hidden",
|
||||||
autoHideMenuBar: true,
|
autoHideMenuBar: true,
|
||||||
roundedCorners: false,
|
roundedCorners: false,
|
||||||
|
resizable: false,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: false,
|
nodeIntegration: false,
|
||||||
contextIsolation: true,
|
contextIsolation: true,
|
||||||
preload: path.join(__dirname, "app", "index.html")
|
preload: path.join(__dirname, "app", "index.html")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
if (isLauncherNotBanned.success) {
|
||||||
|
launcherWindow.loadFile(path.join(__dirname, "app", "index.html"))
|
||||||
|
} else {
|
||||||
|
launcherWindow.loadFile(path.join(__dirname, "app", "banned.html"))
|
||||||
|
launcherWindow.webContents.executeJavaScript(`
|
||||||
|
setBannedBy("${isLauncherNotBanned.banned_by}")
|
||||||
|
setBannedAt("${isLauncherNotBanned.banned_at}")
|
||||||
|
setBannedBecause("${isLauncherNotBanned.reason}")
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dialog.showErrorBox("Le launcher requiert une connexion internet.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkIfIAmBanned() {
|
||||||
|
if (net.isOnline()) {
|
||||||
|
try {
|
||||||
|
const reponse = await fetch(config, {
|
||||||
|
body: JSON.stringify({
|
||||||
|
hwid: hwid.getHWID()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
const json = await reponse.json()
|
||||||
|
return json
|
||||||
|
} catch (error) {
|
||||||
|
dialog.showErrorBox("Impossible de contacter l'API, fermeture du launcher.")
|
||||||
|
console.error(error)
|
||||||
|
app.exit()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
dialog.showErrorBox("Le launcher requiert une connexion internet.")
|
dialog.showErrorBox("Le launcher requiert une connexion internet.")
|
||||||
}
|
}
|
||||||
|
|||||||
86
modules/hwid.js
Normal file
86
modules/hwid.js
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
const crypto = require("node:crypto")
|
||||||
|
const os = require("node:os")
|
||||||
|
const { readFileSync } = require("fs")
|
||||||
|
const { execSync } = require("child_process")
|
||||||
|
|
||||||
|
function getDiskSerial() {
|
||||||
|
try {
|
||||||
|
let command
|
||||||
|
if (os.platform() === "win32") {
|
||||||
|
command = "wmic diskdrive get serialnumber"
|
||||||
|
const output = execSync(command).toString()
|
||||||
|
const serial = output.split("\n")[1].trim()
|
||||||
|
return serial
|
||||||
|
} else if (os.platform() === "darwin") {
|
||||||
|
command = "system_profiler SPHardwareDataType | grep 'Serial Number'"
|
||||||
|
const output = execSync(command).toString()
|
||||||
|
const serial = output.match(/Serial Number: (.+)/)?.[1]?.trim()
|
||||||
|
return serial
|
||||||
|
} else if (os.platform() === "linux") {
|
||||||
|
const serialPath = "/sys/class/block/sda/device/serial"
|
||||||
|
const serial = readFileSync(serialPath, "utf8").trim()
|
||||||
|
return serial
|
||||||
|
} else {
|
||||||
|
throw new Error("Unsupported OS")
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error retrieving disk serial number:", error)
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getMotherboardSerial() {
|
||||||
|
try {
|
||||||
|
let command
|
||||||
|
if (os.platform() === "win32") {
|
||||||
|
command = "wmic baseboard get serialnumber"
|
||||||
|
const output = execSync(command).toString()
|
||||||
|
const serial = output.split("\n")[1].trim()
|
||||||
|
return serial
|
||||||
|
} else if (os.platform() === "darwin") {
|
||||||
|
command = "ioreg -l | grep IOPlatformSerialNumber"
|
||||||
|
const output = execSync(command).toString()
|
||||||
|
const serial = output.match(/"IOPlatformSerialNumber" = "(.+?)"/)?.[1]?.trim()
|
||||||
|
return serial
|
||||||
|
} else if (os.platform() === "linux") {
|
||||||
|
const serialPath = "/sys/class/dmi/id/board_serial"
|
||||||
|
const serial = readFileSync(serialPath, "utf8").trim()
|
||||||
|
return serial
|
||||||
|
} else {
|
||||||
|
throw new Error("Unsupported OS")
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error retrieving motherboard serial number:", error)
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getMacAddresses() {
|
||||||
|
const networkInterfaces = os.networkInterfaces()
|
||||||
|
const macs = []
|
||||||
|
|
||||||
|
for (const iface of Object.values(networkInterfaces)) {
|
||||||
|
for (const nic of iface) {
|
||||||
|
if (!nic.internal && nic.mac !== "00:00:00:00:00:00") {
|
||||||
|
macs.push(nic.mac)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return macs.join("")
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateHWID() {
|
||||||
|
const diskSerial = getDiskSerial()
|
||||||
|
const motherboardSerial = getMotherboardSerial()
|
||||||
|
const macAddresses = getMacAddresses()
|
||||||
|
const cpuInfo = os.cpus().map(cpu => cpu.model).join("")
|
||||||
|
const user = os.userInfo().username
|
||||||
|
|
||||||
|
const uniqueData = `${diskSerial}-${motherboardSerial}-${macAddresses}-${cpuInfo}-${user}`
|
||||||
|
const hwid = crypto.createHash("sha256").update(uniqueData).digest("hex")
|
||||||
|
|
||||||
|
return hwid
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.getHWID = generateHWID
|
||||||
Loading…
x
Reference in New Issue
Block a user