From 86b5e4a85d160fe385489029ba36046028c548ce Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Tue, 5 Feb 2019 20:01:01 -0800 Subject: [PATCH] Fixed the OTP random generator to be even. --- meshuser.js | 15 +++++++++------ package.json | 2 +- views/default-min.handlebars | 2 +- views/default-mobile-min.handlebars | 2 +- views/default-mobile.handlebars | 4 ++++ views/default.handlebars | 4 ++++ views/login-min.handlebars | 2 +- views/login-mobile-min.handlebars | 2 +- 8 files changed, 22 insertions(+), 11 deletions(-) diff --git a/meshuser.js b/meshuser.js index 8b246474..57c260c7 100644 --- a/meshuser.js +++ b/meshuser.js @@ -1429,12 +1429,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use // Perform a sub-action var actionTaken = false; if (command.subaction == 1) { // Generate a new set of tokens - var randomNumbers = []; - for (var i = 0; i < 10; i++) { - var v; // TODO: This random generation does not produce equal changes for all values. FIX IT! - do { v = (obj.parent.crypto.randomBytes(4).readUInt32BE(0) % 100000000); } while (randomNumbers.indexOf(v) >= 0); - randomNumbers.push(v); - } + var randomNumbers = [], v; + for (var i = 0; i < 10; i++) { do { v = getRandomEightDigitInteger(); } while (randomNumbers.indexOf(v) >= 0); randomNumbers.push(v); } user.otpkeys = { keys: [] }; for (var i = 0; i < 10; i++) { user.otpkeys.keys[i] = { p: randomNumbers[i], u: true } } actionTaken = true; @@ -1605,6 +1601,13 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use return obj; } + // Generate a 8 digit integer with even random probability for each value. + function getRandomEightDigitInteger() { + var bigInt; + do { bigInt = obj.parent.crypto.randomBytes(4).readUInt32BE(0); } while (bigInt > 4200000000); + return bigInt % 100000000; + } + // Parse arguments string array into an object function parseArgs(argv) { var results = { '_': [] }, current = null; diff --git a/package.json b/package.json index 722fec1f..6a26399f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.2.7-i", + "version": "0.2.7-j", "keywords": [ "Remote Management", "Intel AMT", diff --git a/views/default-min.handlebars b/views/default-min.handlebars index 3e8bd402..5eba2814 100644 --- a/views/default-min.handlebars +++ b/views/default-min.handlebars @@ -1 +1 @@ - MeshCentral
{{{title}}}
{{{title2}}}

{{{logoutControl}}}

 

\ No newline at end of file + MeshCentral
{{{title}}}
{{{title2}}}

{{{logoutControl}}}

 

\ No newline at end of file diff --git a/views/default-mobile-min.handlebars b/views/default-mobile-min.handlebars index 1a94d0e8..c8872377 100644 --- a/views/default-mobile-min.handlebars +++ b/views/default-mobile-min.handlebars @@ -1 +1 @@ - MeshCentral
{{{title}}}
{{{title2}}}
\ No newline at end of file + MeshCentral
{{{title}}}
{{{title2}}}
\ No newline at end of file diff --git a/views/default-mobile.handlebars b/views/default-mobile.handlebars index 4dc621b2..f8de00a1 100644 --- a/views/default-mobile.handlebars +++ b/views/default-mobile.handlebars @@ -971,6 +971,10 @@ //addNotification(n); break; } + case 'stopped': { // Server is stopping. + // TODO: Disconnect + break; + } default: console.log('Unknown message.event.action', message.event.action); break; diff --git a/views/default.handlebars b/views/default.handlebars index bb22e0ae..b62701ef 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -1685,6 +1685,10 @@ addNotification(n); break; } + case 'stopped': { // Server is stopping. + // TODO: Disconnect + break; + } default: //console.log('Unknown message.event.action', message.event.action); break; diff --git a/views/login-min.handlebars b/views/login-min.handlebars index de99f6f4..1f728d20 100644 --- a/views/login-min.handlebars +++ b/views/login-min.handlebars @@ -1 +1 @@ - MeshCentral - Login
{{{title}}}
{{{title2}}}

Welcome

Connect to your home or office devices from anywhere in the world using MeshCentral, the real time, open source remote monitoring and management web site. You will need to download and install a management agent on your computers. Once installed, computers will show up in the "My Devices" section of this web site and you will be able to monitor them and take control of them.


\ No newline at end of file + MeshCentral - Login
{{{title}}}
{{{title2}}}

Welcome

Connect to your home or office devices from anywhere in the world using MeshCentral, the real time, open source remote monitoring and management web site. You will need to download and install a management agent on your computers. Once installed, computers will show up in the "My Devices" section of this web site and you will be able to monitor them and take control of them.


\ No newline at end of file diff --git a/views/login-mobile-min.handlebars b/views/login-mobile-min.handlebars index e3ed5c10..0b320f18 100644 --- a/views/login-mobile-min.handlebars +++ b/views/login-mobile-min.handlebars @@ -1 +1 @@ - MeshCentral - Login
{{{title}}}
{{{title2}}}
\ No newline at end of file + MeshCentral - Login
{{{title}}}
{{{title2}}}
\ No newline at end of file