fix defender and add defender to console command

Signed-off-by: si458 <simonsmith5521@gmail.com>

si458 committed Nov 16, 2025 at 16:09 UTC da73bff99e775ac8e52f06396514fbe72ef8c7ef
2 files changed +14 -3
agents/meshcore.js
+10 -2
@@ -4038,7 +4038,7 @@ function processConsoleCommand(cmd, args, rights, sessionid) {
4038 var response = null;
4039 switch (cmd) {
4040 case 'help': { // Displays available commands
4041 - var fin = '', f = '', availcommands = 'domain,translations,agentupdate,errorlog,msh,timerinfo,coreinfo,coreinfoupdate,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,uninstallagent,display,openfile';
4041 + var fin = '', f = '', availcommands = 'domain,translations,agentupdate,errorlog,msh,timerinfo,coreinfo,coreinfoupdate,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,cpuinfo,sysinfo,apf,scanwifi,wallpaper,agentmsg,task,uninstallagent,display,openfile';
4042 if (require('os').dns != null) { availcommands += ',dnsinfo'; }
4043 try { require('linux-dhcp'); availcommands += ',dhcp'; } catch (ex) { }
4044 if (process.platform == 'win32') {
@@ -4046,7 +4046,7 @@ function processConsoleCommand(cmd, args, rights, sessionid) {
4046 if (bcdOK()) { availcommands += ',safemode'; }
4047 if (require('notifybar-desktop').DefaultPinned != null) { availcommands += ',privacybar'; }
4048 try { require('win-utils'); availcommands += ',taskbar'; } catch (ex) { }
4049 - try { require('win-info'); availcommands += ',installedapps,qfe'; } catch (ex) { }
4049 + try { require('win-info'); availcommands += ',installedapps,qfe,defender,av'; } catch (ex) { }
4050 }
4051 if (amt != null) { availcommands += ',amt,amtconfig,amtevents'; }
4052 if (process.platform != 'freebsd') { availcommands += ',vm'; }
@@ -4884,6 +4884,14 @@ function processConsoleCommand(cmd, args, rights, sessionid) {
4884 response = 'Not supported on the platform';
4885 }
4886 break;
4887 + case 'defender':
4888 + if (process.platform == 'win32') {
4889 + // Windows Command: "wmic /Namespace:\\root\SecurityCenter2 Path AntiVirusProduct get /FORMAT:CSV"
4890 + response = JSON.stringify(require('win-info').defender(), null, 1);
4891 + } else {
4892 + response = 'Not supported on the platform';
4893 + }
4894 + break;
4895 case 'log':
4896 if (args['_'].length != 1) { response = 'Proper usage: log "sample text"'; } else { MeshServerLog(args['_'][0]); response = 'ok'; }
4897 break;
agents/modules_meshcore/win-info.js
+4 -1
@@ -244,7 +244,10 @@ function defender(){
244 try {
245 var tokens = require('win-wmi').query('ROOT\\Microsoft\\Windows\\Defender', 'SELECT * FROM MSFT_MpComputerStatus', ['RealTimeProtectionEnabled','IsTamperProtected','AntivirusSignatureVersion','AntivirusSignatureLastUpdated']);
246 if (tokens[0]){
247 - return ({ RealTimeProtection: tokens[0].RealTimeProtectionEnabled, TamperProtected: tokens[0].IsTamperProtected, AntivirusSignatureVersion: tokens[0].AntivirusSignatureVersion, AntivirusSignatureLastUpdated: tokens[0].AntivirusSignatureLastUpdated });
247 + var info = { RealTimeProtection: tokens[0].RealTimeProtectionEnabled, TamperProtected: tokens[0].IsTamperProtected };
248 + if (tokens[0].AntivirusSignatureVersion) { info.AntivirusSignatureVersion = tokens[0].AntivirusSignatureVersion; }
249 + if (tokens[0].AntivirusSignatureLastUpdated) { info.AntivirusSignatureLastUpdated = tokens[0].AntivirusSignatureLastUpdated; }
250 + return (info);
251 } else {
252 return ({});
253 }