Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Ylianst/MeshCentral
Browse files Browse the repository at this point in the history
  • Loading branch information
Ylianst committed Mar 3, 2024
2 parents e8c4f32 + fb62df3 commit c937764
Show file tree
Hide file tree
Showing 14 changed files with 3,045 additions and 2,476 deletions.
49 changes: 49 additions & 0 deletions SECURITY.md
@@ -0,0 +1,49 @@
# Security Policy

## Supported Versions

Any version of MeshCentral 1.x.x is supported.

| Version | Supported |
| ------- | ------------------ |
| 1.x.x | :white_check_mark: |
| < 1.0 | :x: |

## Reporting a Vulnerability

Please report any concerns or security issue to Ylian Saint-Hilaire (ylianst@gmail.com). If needed, use my PGP key below.

```
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: BCPG v1.56
mQMuBF2gC4sRCAClFNvMCCVW3ego3UHBQ6LhSenJfaZYhvn8gaGuemSQxqTI6bla
BTAv3aMtQnvqlSuadMMegb+FO6hnaQMlGvpVA1qpkSzgrPS5HrBD3H33J2Nj3i93
ZpDPpxdI0ehCj6IJPnl0GxGbpKIN8YpJUFl44wv1lMRFI1lgyb+dCoO60irYdNQB
PV85BI+DwPfOBFHunwR78nqMvpvsk9HaeHjEP7oXr952/7EazUowZsMlEfkYnw5S
+tLfpCoY3QWkektpJP40nMJSKQdV2NEuED99doA0X+7P1vsvFFFyMH69dnU2uSay
XCHpkAbntBy0BGmtF1RnTcOMv2V/LPXnlMdvAQCbmLQzNra3r163tcdRY0jSs+pZ
1L3w5tHNj2dzhfpa7wf/SIuds6QTr2LCN6miLoSVCRMMpT7d771b16GwQqWEXzN2
+h7dYqrssHPOa8FSUrPerz0+0eFcbMSm5/L/4KXWXoQthURv8aMP9E0iVoUYaaKB
7U+5vFEZbpoOZyZmTAjXQMSNZCft0azA82Q+G85euyicWtMv48yNVzUhkdh+M2ud
ohkXX2Aor1TqpBJoIeWke7j9D+Bo+lu61zPRx5ed9teUeLJCwqNEjlE+6gre5kxF
PoreAtn59QYcBIpzQEWVMbNFlDAR4jMyqIoK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apk
Binary file not shown.
33 changes: 28 additions & 5 deletions agents/meshcore.js
Expand Up @@ -3438,6 +3438,24 @@ function onTunnelData(data)
this.zip.on('progress', require('events').moderated(function (name, p) { this.xws.write(Buffer.from(JSON.stringify({ action: 'dialogmessage', msg: 'zippingFile', file: ((process.platform == 'win32') ? (name.split('/').join('\\')) : name), progress: p }))); }, 1000));
this.zip.pipe(out);
break;
case 'unzip':
if (this.unzip != null) return; // Unzip operating is currently running, exit now.
this.unzip = require('zip-reader').read(cmd.input);
this.unzip._dest = cmd.dest;
this.unzip.xws = this;
this.unzip.then(function (zipped) {
this.xws.write(Buffer.from(JSON.stringify({ action: 'dialogmessage', msg: 'unzipping' })));
zipped.xws = this.xws;
zipped.extractAll(this._dest).then(function () { // finished extracting
zipped.xws.write(Buffer.from(JSON.stringify({ action: 'dialogmessage', msg: null })));
zipped.xws.write(Buffer.from(JSON.stringify({ action: 'refresh' })));
delete zipped.xws.unzip;
}, function (e) { // error extracting
zipped.xws.write(Buffer.from(JSON.stringify({ action: 'dialogmessage', msg: 'unziperror', error: e })));
delete zipped.xws.unzip;
});
}, function (e) { this.xws.write(Buffer.from(JSON.stringify({ action: 'dialogmessage', msg: 'unziperror', error: e }))); delete this.xws.unzip });
break;
case 'cancel':
// Cancel zip operation if present
try { this.zipcancel = true; this.zip.cancel(function () { }); } catch (ex) { }
Expand Down Expand Up @@ -4247,12 +4265,12 @@ function processConsoleCommand(cmd, args, rights, sessionid) {
break;
case 'unzip':
if (args['_'].length == 0) {
response = "Proper usage: unzip input, destination"; // Display usage
response = "Proper usage: unzip input,destination"; // Display usage
} else {
var p = args['_'].join(' ').split(',');
if (p.length != 2) { response = "Proper usage: unzip input, destination"; break; } // Display usage
var prom = require('zip-reader').read(p[0]);
prom._dest = p[1];
if (p.length != 2) { response = "Proper usage: unzip input,destination"; break; } // Display usage
var prom = require('zip-reader').read(p[0].trim());
prom._dest = p[1].trim();
prom.self = this;
prom.sessionid = sessionid;
prom.then(function (zipped) {
Expand Down Expand Up @@ -4733,8 +4751,11 @@ function processConsoleCommand(cmd, args, rights, sessionid) {
}
case 'sysinfo': { // Return system information
getSystemInformation(function (results, err) {
if (results == null) { sendConsoleText(err, this.sessionid); } else {
if (results == null) {
sendConsoleText(err, this.sessionid);
} else {
sendConsoleText(JSON.stringify(results, null, 1), this.sessionid);
mesh.SendCommand({ action: 'sysinfo', sessionid: this.sessionid, data: results });
}
});
break;
Expand Down Expand Up @@ -5723,9 +5744,11 @@ function cleanGetBitLockerVolumeInfo(volumes) {
for (var i in volumes) {
const v = volumes[i];
if (typeof v.size == 'string') { v.size = parseInt(v.size); }
if (typeof v.sizeremaining == 'string') { v.sizeremaining = parseInt(v.sizeremaining); }
if (v.identifier == '') { delete v.identifier; }
if (v.name == '') { delete v.name; }
if (v.removable != true) { delete v.removable; }
if (v.cdrom != true) { delete v.cdrom; }
if (v.protectionStatus == 'On') { v.protectionStatus = true; } else { delete v.protectionStatus; }
if (v.volumeStatus == 'FullyDecrypted') { delete v.volumeStatus; }
if (v.recoveryPassword == '') { delete v.recoveryPassword; }
Expand Down
105 changes: 99 additions & 6 deletions agents/modules_meshcore/computer-identifiers.js
Expand Up @@ -390,7 +390,7 @@ function windows_volumes()
p1.child = child;
child.promise = p1;
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdin.write('Get-Volume | Select-Object -Property DriveLetter,FileSystemLabel,FileSystemType,Size,DriveType | ConvertTo-Csv -NoTypeInformation\nexit\n');
child.stdin.write('Get-Volume | Select-Object -Property DriveLetter,FileSystemLabel,FileSystemType,Size,SizeRemaining,DriveType | ConvertTo-Csv -NoTypeInformation\nexit\n');
child.on('exit', function (c)
{
var a, i, tokens, key;
Expand All @@ -407,7 +407,9 @@ function windows_volumes()
name: tokens[1].split('"')[1],
type: tokens[2].split('"')[1],
size: tokens[3].split('"')[1],
removable: tokens[4].split('"')[1] == 'Removable'
sizeremaining: tokens[4].split('"')[1],
removable: tokens[5].split('"')[1] == 'Removable',
cdrom: tokens[5].split('"')[1] == 'CD-ROM'
};
}
}
Expand Down Expand Up @@ -447,12 +449,14 @@ function windows_volumes()
var abc = lines[x].trim();
var englishidpass = (abc !== '' && abc.includes('Numerical Password:')); // English ID
var germanidpass = (abc !== '' && abc.includes('Numerisches Kennwort:')); // German ID
var frenchidpass = (abc !== '' && abc.includes('Mot de passe num')); // French ID
var englishpass = (abc !== '' && abc.includes('Password:') && !abc.includes('Numerical Password:')); // English Password
var germanpass = (abc !== '' && abc.includes('Kennwort:') && !abc.includes('Numerisches Kennwort:')); // German Password
if (englishidpass || germanidpass || englishpass || germanpass) {
var frenchpass = (abc !== '' && abc.includes('Mot de passe :') && !abc.includes('Mot de passe num')); // French Password
if (englishidpass || germanidpass || frenchidpass|| englishpass || germanpass || frenchpass) {
var nextline = lines[x + 1].trim();
if (x + 1 < lines.length && (nextline !== '' && nextline.startsWith('ID:'))) {
identifier = nextline.replace('ID:','').trim();
if (x + 1 < lines.length && (nextline !== '' && (nextline.startsWith('ID:') || nextline.startsWith('ID :')) )) {
identifier = nextline.replace('ID:','').replace('ID :', '').trim();
foundIDMarkedLine = true;
}else if (x + 1 < lines.length && nextline !== '') {
password = nextline;
Expand Down Expand Up @@ -559,7 +563,7 @@ function windows_identifiers()
}
function macos_identifiers()
{
var ret = { identifiers: {} };
var ret = { identifiers: {}, darwin: {} };
var child;

child = require('child_process').execFile('/bin/sh', ['sh']);
Expand Down Expand Up @@ -598,6 +602,84 @@ function macos_identifiers()
child.waitExit();
ret.identifiers.cpu_name = child.stdout.str.trim();

child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdin.write('system_profiler SPMemoryDataType\nexit\n');
child.waitExit();
var lines = child.stdout.str.trim().split('\n');
if(lines.length > 0) {
const memorySlots = [];
if(lines[2].trim().includes('Memory Slots:')) { // OLD MACS WITH SLOTS
const Memory = [];
const bankMatches = child.stdout.str.trim().match(/BANK \d+\/DIMM\d+:[\s\S]*?(?=(BANK|$))/g);
bankMatches.forEach(function(match, index) {
const bankInfo = match.match(/BANK (\d+)\/DIMM(\d+):[\s\S]*?Size: (\d+ \w+)[\s\S]*?Type: (\w+)[\s\S]*?Speed: (\d+ \w+)[\s\S]*?Status: (\w+)[\s\S]*?Manufacturer: (0x[0-9A-Fa-f]+)[\s\S]*?Part Number: (0x[0-9A-Fa-f]+)[\s\S]*?Serial Number: (.+)/);
if (bankInfo) {
const bankIndex = bankInfo[1].trim();
const dimmIndex = bankInfo[2].trim();
const size = bankInfo[3].trim();
const type = bankInfo[4].trim();
const speed = bankInfo[5].trim();
const status = bankInfo[6].trim();
const manufacturer = bankInfo[7].trim();
const partNumber = bankInfo[8].trim();
const serialNumber = bankInfo[9].trim();
Memory.push({
DeviceLocator: "BANK " + bankIndex + "/DIMM" + dimmIndex,
Size: size,
Type: type,
Speed: speed,
Status: status,
Manufacturer: hexToAscii(manufacturer),
PartNumber: hexToAscii(partNumber),
SerialNumber: serialNumber,
});
}
});
memorySlots = Memory;
} else { // NEW MACS WITHOUT SLOTS
memorySlots.push({ DeviceLocator: "Onboard Memory", Size: lines[2].split(":")[1].trim(), PartNumber: lines[3].split(":")[1].trim(), Manufacturer: lines[4].split(":")[1].trim() })
}
ret.darwin.memory = memorySlots;
}

child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdin.write('diskutil info -all\nexit\n');
child.waitExit();
var sections = child.stdout.str.split('**********\n');
if(sections.length > 0){
var devices = [];
for (var i = 0; i < sections.length; i++) {
var lines = sections[i].split('\n');
var deviceInfo = {};
var wholeYes = false;
var physicalYes = false;
var oldmac = false;
for (var j = 0; j < lines.length; j++) {
var keyValue = lines[j].split(':');
var key = keyValue[0].trim();
var value = keyValue[1] ? keyValue[1].trim() : '';
if (key === 'Virtual') oldmac = true;
if (key === 'Whole' && value === 'Yes') wholeYes = true;
if (key === 'Virtual' && value === 'No') physicalYes = true;
if(value && key === 'Device / Media Name'){
deviceInfo['Caption'] = value;
}
if(value && key === 'Disk Size'){
deviceInfo['Size'] = value.split(' ')[0] + ' ' + value.split(' ')[1];
}
}
if (wholeYes) {
if (oldmac) {
if (physicalYes) devices.push(deviceInfo);
} else {
devices.push(deviceInfo);
}
}
}
ret.identifiers.storage_devices = devices;
}

trimIdentifiers(ret.identifiers);

Expand All @@ -606,6 +688,17 @@ function macos_identifiers()
return (ret);
}

function hexToAscii(hexString) {
hexString = hexString.startsWith('0x') ? hexString.slice(2) : hexString;
var str = '';
for (var i = 0; i < hexString.length; i += 2) {
var hexPair = hexString.substr(i, 2);
str += String.fromCharCode(parseInt(hexPair, 16));
}
str = str.replace(/[\u007F-\uFFFF]/g, ''); // Remove characters from 0x0080 to 0xFFFF
return str.trim();
}

function win_chassisType()
{
var child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', 'SystemEnclosure', 'get', 'ChassisTypes']);
Expand Down

0 comments on commit c937764

Please sign in to comment.