Randomized Intel AMT Env Detection.
Ylian Saint-Hilaire committed
Nov 15, 2019 at 14:36 UTC
e91c973823d98a20a83796458e500cfb103952bb
3 files changed
+17
-4
package.json
+1
-1
@@ -1,6 +1,6 @@
1
{
2
"name": "meshcentral",
3
- "version": "0.4.4-b",
3
+ "version": "0.4.4-c",
4
"keywords": [
5
"Remote Management",
6
"Intel AMT",
translate/translate.js
+1
-1
@@ -462,7 +462,7 @@ function InstallModule(modulename, func, tag1, tag2) {
462
if ((__dirname.endsWith('/node_modules/meshcentral')) || (__dirname.endsWith('\\node_modules\\meshcentral')) || (__dirname.endsWith('/node_modules/meshcentral/')) || (__dirname.endsWith('\\node_modules\\meshcentral\\'))) { parentpath = require('path').join(__dirname, '../..'); }
463
464
// Looks like we need to keep a global reference to the child process object for this to work correctly.
465
- InstallModuleChildProcess = child_process.exec('npm install --no-optional --save ' + modulename, { maxBuffer: 512000, timeout: 10000, cwd: parentpath }, function (error, stdout, stderr) {
465
+ InstallModuleChildProcess = child_process.exec('npm install --no-optional --save ' + modulename, { maxBuffer: 512000, timeout: 120000, cwd: parentpath }, function (error, stdout, stderr) {
466
InstallModuleChildProcess = null;
467
if ((error != null) && (error != '')) {
468
console.log('ERROR: Unable to install required module "' + modulename + '". May not have access to npm, or npm may not have suffisent rights to load the new module. Try "npm install ' + modulename + '" to manualy install this module.\r\n');
webserver.js
+15
-2
@@ -1775,8 +1775,14 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
1775
scriptFile.mescript = Buffer.from(scriptEngine.script_compile(runscript), 'binary').toString('base64');
1776
scriptFile.scriptText = runscript;
1777
1778
+ // Randomize the environement detection
1779
+ var randomDnsName;
1780
+ do { randomDnsName = getRandomLowerCase(14); } while (randomDnsName == 'aabbccddeeffgg');
1781
+ var text = JSON.stringify(scriptFile, null, ' ');
1782
+ for (var i = 0; i < 5; i++) { text = text.replace('aabbccddeeffgg', randomDnsName); }
1783
+
1784
// Send the script
1779
- func(Buffer.from(JSON.stringify(scriptFile, null, ' ')));
1785
+ func(Buffer.from(text));
1786
});
1787
} else {
1788
// Server name is a hostname
@@ -1800,8 +1806,14 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
1806
scriptFile.mescript = Buffer.from(scriptEngine.script_compile(runscript), 'binary').toString('base64');
1807
scriptFile.scriptText = runscript;
1808
1809
+ // Randomize the environement detection
1810
+ var randomDnsName;
1811
+ do { randomDnsName = getRandomLowerCase(14); } while (randomDnsName == 'aabbccddeeffgg');
1812
+ var text = JSON.stringify(scriptFile, null, ' ');
1813
+ for (var i = 0; i < 5; i++) { text = text.replace('aabbccddeeffgg', randomDnsName); }
1814
+
1815
// Send the script
1804
- func(Buffer.from(JSON.stringify(scriptFile, null, ' ')));
1816
+ func(Buffer.from(text));
1817
});
1818
}
1819
}
@@ -3970,6 +3982,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
3982
function checkAmtPassword(p) { return (p.length > 7) && (/\d/.test(p)) && (/[a-z]/.test(p)) && (/[A-Z]/.test(p)) && (/\W/.test(p)); }
3983
function getRandomAmtPassword() { var p; do { p = Buffer.from(obj.crypto.randomBytes(9), 'binary').toString('base64').split('/').join('@'); } while (checkAmtPassword(p) == false); return p; }
3984
function getRandomPassword() { return Buffer.from(obj.crypto.randomBytes(9), 'binary').toString('base64').split('/').join('@'); }
3985
+ function getRandomLowerCase(len) { var r = '', random = obj.crypto.randomBytes(len); for (var i = 0; i < len; i++) { r += String.fromCharCode(97 + (random[i] % 26)); } return r; }
3986
3987
// Clean a IPv6 address that encodes a IPv4 address
3988
function cleanRemoteAddr(addr) { if (typeof addr != 'string') { return null; } if (addr.indexOf('::ffff:') == 0) { return addr.substring(7); } else { return addr; } }