Added UAC console command for windows

Bryan Roe committed May 17, 2020 at 00:22 UTC a23b8d047cab63b638a901645a0899d03b52dc1d
1 file changed +47 -1
agents/meshcore.js
+47 -1
@@ -2117,7 +2117,7 @@ function createMeshCore(agent) {
2117 switch (cmd) {
2118 case 'help': { // Displays available commands
2119 var fin = '', f = '', availcommands = 'startupoptions,alert,agentsize,versions,help,info,osinfo,args,print,type,dbkeys,dbget,dbset,dbcompact,eval,parseuri,httpget,nwslist,plugin,wsconnect,wssend,wsclose,notify,ls,ps,kill,amt,netinfo,location,power,wakeonlan,setdebug,smbios,rawsmbios,toast,lock,users,sendcaps,openurl,amtreset,amtccm,amtacm,amtdeactivate,amtpolicy,getscript,getclip,setclip,log,av,cpuinfo,sysinfo,apf,scanwifi,scanamt,wallpaper';
2120 - if (process.platform == 'win32') { availcommands += ',safemode,wpfhwacceleration'; }
2120 + if (process.platform == 'win32') { availcommands += ',safemode,wpfhwacceleration,uac'; }
2121 if (process.platform != 'freebsd') { availcommands += ',vm';}
2122 if (require('MeshAgent').maxKvmTileSize != null) { availcommands += ',kvmmode'; }
2123
@@ -2130,6 +2130,52 @@ function createMeshCore(agent) {
2130 response = "Available commands: \r\n" + fin + ".";
2131 break;
2132 }
2133 + case 'uac':
2134 + if (process.platform != 'win32')
2135 + {
2136 + response = 'Unknown command "uac", type "help" for list of avaialble commands.';
2137 + break;
2138 + }
2139 + if (args['_'].length != 1)
2140 + {
2141 + response = 'Proper usage: uac [get|interactive|secure]';
2142 + }
2143 + else
2144 + {
2145 + switch(args['_'][0].toUpperCase())
2146 + {
2147 + case 'GET':
2148 + var secd = require('win-registry').QueryKey(require('win-registry').HKEY.LocalMachine, 'Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System', 'PromptOnSecureDesktop');
2149 + response = "UAC mode: " + (secd == 0 ? "Interactive Desktop" : "Secure Desktop");
2150 + break;
2151 + case 'INTERACTIVE':
2152 + try
2153 + {
2154 + require('win-registry').WriteKey(require('win-registry').HKEY.LocalMachine, 'Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System', 'PromptOnSecureDesktop', 0);
2155 + response = 'UAC mode changed to: Interactive Desktop';
2156 + }
2157 + catch (e)
2158 + {
2159 + response = "Unable to change UAC Mode";
2160 + }
2161 + break;
2162 + case 'SECURE':
2163 + try
2164 + {
2165 + require('win-registry').WriteKey(require('win-registry').HKEY.LocalMachine, 'Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System', 'PromptOnSecureDesktop', 1);
2166 + response = 'UAC mode changed to: Secure Desktop';
2167 + }
2168 + catch(e)
2169 + {
2170 + response = "Unable to change UAC Mode";
2171 + }
2172 + break;
2173 + default:
2174 + response = 'Proper usage: uac [get|interactive|secure]';
2175 + break;
2176 + }
2177 + }
2178 + break;
2179 case 'vm':
2180 response = 'Virtual Machine = ' + require('identifiers').isVM();
2181 break;