From 7b335661d794400078e17c589fe6ba76b483a4fd Mon Sep 17 00:00:00 2001 From: reddn Date: Wed, 1 Jun 2022 03:58:30 -0400 Subject: [PATCH 1/4] add more detail on no language set for translation also made default langauge 'en_us' instead of 'en' --- agents/meshinstall-linux.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/agents/meshinstall-linux.js b/agents/meshinstall-linux.js index 723fb6fd..1e61c04f 100644 --- a/agents/meshinstall-linux.js +++ b/agents/meshinstall-linux.js @@ -45,7 +45,7 @@ var msh = {}; var translation = JSON.parse(msh.translation); var lang = require('util-language').current; -if (lang == null) { lang = 'en'; } +if (lang == null) { lang = 'en_us'; } if (process.argv.getParameter('lang', lang) == null) { console.log('\nCurrent Language: ' + lang + '\n'); @@ -60,6 +60,7 @@ else if (translation[lang.split('-')[0]] == null) { console.log('Language: ' + lang + ' is not translated.'); + console.log("try: './meshcentral -lang=en_us'" process.exit(); } else @@ -352,4 +353,4 @@ if (!skip) console.log(e); process.exit(); }); -} \ No newline at end of file +} From f8cb33d5bfb1bd80368aab10ff6eb4aa387daf8e Mon Sep 17 00:00:00 2001 From: reddn Date: Fri, 3 Jun 2022 17:13:42 -0400 Subject: [PATCH 2/4] added fix to process.env.LANG = "C" --- agents/meshinstall-linux.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/agents/meshinstall-linux.js b/agents/meshinstall-linux.js index 1e61c04f..1ea54368 100644 --- a/agents/meshinstall-linux.js +++ b/agents/meshinstall-linux.js @@ -45,7 +45,11 @@ var msh = {}; var translation = JSON.parse(msh.translation); var lang = require('util-language').current; -if (lang == null) { lang = 'en_us'; } +if (lang == null) { lang = 'en'; } +if (lang == "C"){ + lang = 'en'; + console.log("Langauge envronment variable was not set (process.env.LANG). Defaulting to English ('en').\nSee the agent-translations.json file for a list of current languages that are implemented\nUsage: meshcentral -lang=en\n"); +} if (process.argv.getParameter('lang', lang) == null) { console.log('\nCurrent Language: ' + lang + '\n'); @@ -60,7 +64,8 @@ else if (translation[lang.split('-')[0]] == null) { console.log('Language: ' + lang + ' is not translated.'); - console.log("try: './meshcentral -lang=en_us'" + console.log("try: './meshcentral -lang=en' for English"); + console.log("See the agent-translations.json file for a list of current languages that are implemented.") process.exit(); } else From 3c856765ce634eb34b29d92a3a19b4104ea3b236 Mon Sep 17 00:00:00 2001 From: Bryan Roe Date: Sat, 4 Jun 2022 09:35:31 -0700 Subject: [PATCH 3/4] Updated error message, to show correct binary name --- agents/meshinstall-linux.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agents/meshinstall-linux.js b/agents/meshinstall-linux.js index 1ea54368..cbc5dca3 100644 --- a/agents/meshinstall-linux.js +++ b/agents/meshinstall-linux.js @@ -64,7 +64,7 @@ else if (translation[lang.split('-')[0]] == null) { console.log('Language: ' + lang + ' is not translated.'); - console.log("try: './meshcentral -lang=en' for English"); + console.log("try: './"+ process.execPath.split('/').pop() + " -lang=en' for English"); console.log("See the agent-translations.json file for a list of current languages that are implemented.") process.exit(); } From b167f2a7b73b35cfb2c790081ef9c8d9dfc56d75 Mon Sep 17 00:00:00 2001 From: Bryan Roe Date: Sun, 5 Jun 2022 16:50:39 -0700 Subject: [PATCH 4/4] added domaininfo console command for windows --- agents/meshcore.js | 122 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 121 insertions(+), 1 deletion(-) diff --git a/agents/meshcore.js b/agents/meshcore.js index 00a62268..e8d3b723 100644 --- a/agents/meshcore.js +++ b/agents/meshcore.js @@ -56,6 +56,73 @@ function bcdOK() } return (true); } +function getDomainInfo() +{ + var hostname = require('os').hostname(); + var ret = { Name: hostname, Domain: "" }; + + switch (process.platform) + { + case 'win32': + try + { + ret = require('win-wmi').query('ROOT\\CIMV2', 'SELECT * FROM Win32_ComputerSystem', ['Name', 'Domain'])[0]; + } + catch (x) + { + } + break; + case 'linux': + var hasrealm = false; + + try + { + hasrealm = require('lib-finder').hasBinary('realm'); + } + catch(x) + { + } + if (hasrealm) + { + var child = require('child_process').execFile('/bin/sh', ['sh']); + child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); }); + child.stdin.write("realm list | grep domain-name: | tr '\\n' '`' | "); + child.stdin.write("awk -F'`' '{ "); + child.stdin.write(' printf("[");'); + child.stdin.write(' ST="";'); + child.stdin.write(' for(i=1;i0) + { + if(hostname.endsWith('.' + names.peek())) + { + ret = { Name: hostname.substring(0, hostname.length - names.peek().length - 1), Domain: names.peek() }; + break; + } + names.pop(); + } + } + break; + } + return (ret); +} + try { @@ -3268,7 +3335,7 @@ function processConsoleCommand(cmd, args, rights, sessionid) { var response = null; switch (cmd) { case 'help': { // Displays available commands - var fin = '', f = '', availcommands = 'translations,agentupdate,errorlog,msh,timerinfo,coreinfo,coredump,service,fdsnapshot,fdcount,startupoptions,alert,agentsize,versions,help,info,osinfo,args,print,type,dbkeys,dbget,dbset,dbcompact,eval,parseuri,httpget,wslist,plugin,wsconnect,wssend,wsclose,notify,ls,ps,kill,netinfo,location,power,wakeonlan,setdebug,smbios,rawsmbios,toast,lock,users,openurl,getscript,getclip,setclip,log,av,cpuinfo,sysinfo,apf,scanwifi,wallpaper,agentmsg,task'; + var fin = '', f = '', availcommands = 'domain,translations,agentupdate,errorlog,msh,timerinfo,coreinfo,coredump,service,fdsnapshot,fdcount,startupoptions,alert,agentsize,versions,help,info,osinfo,args,print,type,dbkeys,dbget,dbset,dbcompact,eval,parseuri,httpget,wslist,plugin,wsconnect,wssend,wsclose,notify,ls,ps,kill,netinfo,location,power,wakeonlan,setdebug,smbios,rawsmbios,toast,lock,users,openurl,getscript,getclip,setclip,log,av,cpuinfo,sysinfo,apf,scanwifi,wallpaper,agentmsg,task'; if (require('os').dns != null) { availcommands += ',dnsinfo'; } try { require('linux-dhcp'); availcommands += ',dhcp'; } catch (ex) { } if (process.platform == 'win32') @@ -3290,6 +3357,59 @@ function processConsoleCommand(cmd, args, rights, sessionid) { response = "Available commands: \r\n" + fin + "."; break; } + case 'domain': + response = getDomainInfo(); + break; + case 'domaininfo': + { + if(process.platform != 'win32') + { + response = 'Unknown command "cs", type "help" for list of avaialble commands.'; + break; + } + if(global._domainQuery != null) + { + response = "There is already an outstanding Domain Controller Query... Please try again later..."; + break; + } + + sendConsoleText('Querying Domain Controller... This can take up to 60 seconds. Please wait...', sessionid); + global._domainQuery = require('win-wmi').queryAsync('ROOT\\CIMV2', 'SELECT * FROM Win32_NTDomain'); + global._domainQuery.session = sessionid; + global._domainQuery.then(function (v) + { + var results = []; + if (Array.isArray(v)) + { + var i; + var r; + for (i = 0; i < v.length; ++i) + { + r = {}; + if (v[i].DomainControllerAddress != null) { r.DomainControllerAddress = v[i].DomainControllerAddress.split('\\').pop(); } + if (r.DomainControllerName != null) { r.DomainControllerName = v[i].DomainControllerName.split('\\').pop(); } + r.DomainGuid = v[i].DomainGuid; + r.DomainName = v[i].DomainName; + if (r.DomainGuid != null) + { + results.push(r); + } + } + } + if (results.length > 0) + { + sendConsoleText('Domain Controller Results:', this.session); + sendConsoleText(JSON.stringify(results, null, 1), this.session); + sendConsoleText('End of results...', this.session); + } + else + { + sendConsoleText('Domain Controller: No results returned. Is the domain controller reachable?', this.session); + } + global._domainQuery = null; + }); + break; + } case 'translations': { response = JSON.stringify(coretranslations, null, 2); break;