mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-03-09 15:40:18 +00:00
Updated agents, shift-device click will now open a new browser tab.
This commit is contained in:
parent
659b90e75f
commit
21c218adec
27 changed files with 206 additions and 57 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -92,6 +92,11 @@ function UserSessions()
|
|||
{
|
||||
}
|
||||
|
||||
this._advapi = this._marshal.CreateNativeProxy('Advapi32.dll');
|
||||
this._advapi.CreateMethod('AllocateAndInitializeSid');
|
||||
this._advapi.CreateMethod('CheckTokenMembership');
|
||||
this._advapi.CreateMethod('FreeSid');
|
||||
|
||||
this._user32 = this._marshal.CreateNativeProxy('user32.dll');
|
||||
this._user32.CreateMethod({ method: 'RegisterPowerSettingNotification', threadDispatch: 1});
|
||||
this._user32.CreateMethod('UnregisterPowerSettingNotification');
|
||||
|
@ -150,6 +155,26 @@ function UserSessions()
|
|||
'WTSIsRemoteSession': 29
|
||||
};
|
||||
|
||||
this.isRoot = function isRoot()
|
||||
{
|
||||
var NTAuthority = this._marshal.CreateVariable(6);
|
||||
NTAuthority.toBuffer().writeInt8(5, 5);
|
||||
|
||||
var AdministratorsGroup = this._marshal.CreatePointer();
|
||||
var admin = false;
|
||||
|
||||
if (this._advapi.AllocateAndInitializeSid(NTAuthority, 2, 32, 544, 0, 0, 0, 0, 0, 0, AdministratorsGroup).Val != 0)
|
||||
{
|
||||
var member = this._marshal.CreateInteger();
|
||||
if (this._advapi.CheckTokenMembership(0, AdministratorsGroup.Deref(), member).Val != 0)
|
||||
{
|
||||
if (member.toBuffer().readUInt32LE() != 0) { admin = true; }
|
||||
}
|
||||
this._advapi.FreeSid(AdministratorsGroup.Deref());
|
||||
}
|
||||
return admin;
|
||||
}
|
||||
|
||||
this.getSessionAttribute = function getSessionAttribute(sessionId, attr)
|
||||
{
|
||||
var buffer = this._marshal.CreatePointer();
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -92,6 +92,11 @@ function UserSessions()
|
|||
{
|
||||
}
|
||||
|
||||
this._advapi = this._marshal.CreateNativeProxy('Advapi32.dll');
|
||||
this._advapi.CreateMethod('AllocateAndInitializeSid');
|
||||
this._advapi.CreateMethod('CheckTokenMembership');
|
||||
this._advapi.CreateMethod('FreeSid');
|
||||
|
||||
this._user32 = this._marshal.CreateNativeProxy('user32.dll');
|
||||
this._user32.CreateMethod({ method: 'RegisterPowerSettingNotification', threadDispatch: 1});
|
||||
this._user32.CreateMethod('UnregisterPowerSettingNotification');
|
||||
|
@ -150,6 +155,26 @@ function UserSessions()
|
|||
'WTSIsRemoteSession': 29
|
||||
};
|
||||
|
||||
this.isRoot = function isRoot()
|
||||
{
|
||||
var NTAuthority = this._marshal.CreateVariable(6);
|
||||
NTAuthority.toBuffer().writeInt8(5, 5);
|
||||
|
||||
var AdministratorsGroup = this._marshal.CreatePointer();
|
||||
var admin = false;
|
||||
|
||||
if (this._advapi.AllocateAndInitializeSid(NTAuthority, 2, 32, 544, 0, 0, 0, 0, 0, 0, AdministratorsGroup).Val != 0)
|
||||
{
|
||||
var member = this._marshal.CreateInteger();
|
||||
if (this._advapi.CheckTokenMembership(0, AdministratorsGroup.Deref(), member).Val != 0)
|
||||
{
|
||||
if (member.toBuffer().readUInt32LE() != 0) { admin = true; }
|
||||
}
|
||||
this._advapi.FreeSid(AdministratorsGroup.Deref());
|
||||
}
|
||||
return admin;
|
||||
}
|
||||
|
||||
this.getSessionAttribute = function getSessionAttribute(sessionId, attr)
|
||||
{
|
||||
var buffer = this._marshal.CreatePointer();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright 2018-2019 Intel Corporation
|
||||
Copyright 2018 Intel Corporation
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -15,6 +15,7 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
var KEY_QUERY_VALUE = 0x0001;
|
||||
var KEY_ENUMERATE_SUB_KEYS = 0x0008;
|
||||
var KEY_WRITE = 0x20006;
|
||||
|
||||
var KEY_DATA_TYPES =
|
||||
|
@ -39,7 +40,10 @@ function windows_registry()
|
|||
this._marshal = require('_GenericMarshal');
|
||||
this._AdvApi = this._marshal.CreateNativeProxy('Advapi32.dll');
|
||||
this._AdvApi.CreateMethod('RegCreateKeyExA');
|
||||
this._AdvApi.CreateMethod('RegEnumKeyExA');
|
||||
this._AdvApi.CreateMethod('RegEnumValueA');
|
||||
this._AdvApi.CreateMethod('RegOpenKeyExA');
|
||||
this._AdvApi.CreateMethod('RegQueryInfoKeyA');
|
||||
this._AdvApi.CreateMethod('RegQueryValueExA');
|
||||
this._AdvApi.CreateMethod('RegCloseKey');
|
||||
this._AdvApi.CreateMethod('RegDeleteKeyA');
|
||||
|
@ -49,18 +53,65 @@ function windows_registry()
|
|||
|
||||
this.QueryKey = function QueryKey(hkey, path, key)
|
||||
{
|
||||
var err;
|
||||
var h = this._marshal.CreatePointer();
|
||||
var len = this._marshal.CreateVariable(4);
|
||||
var valType = this._marshal.CreateVariable(4);
|
||||
key = this._marshal.CreateVariable(key);
|
||||
var HK = this._marshal.CreatePointer(hkey);
|
||||
var retVal = null;
|
||||
if (key) { key = this._marshal.CreateVariable(key); }
|
||||
if (!path) { path = ''; }
|
||||
|
||||
if (this._AdvApi.RegOpenKeyExA(HK, this._marshal.CreateVariable(path), 0, KEY_QUERY_VALUE, h).Val != 0)
|
||||
|
||||
if ((err = this._AdvApi.RegOpenKeyExA(HK, this._marshal.CreateVariable(path), 0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, h).Val) != 0)
|
||||
{
|
||||
throw ('Error Opening Registry Key: ' + path);
|
||||
throw ('Opening Registry Key: ' + path + ' => Returned Error: ' + err);
|
||||
}
|
||||
|
||||
if ((path == '' && !key) || !key)
|
||||
{
|
||||
var result = { subkeys: [], values: [] };
|
||||
|
||||
// Enumerate keys
|
||||
var achClass = this._marshal.CreateVariable(1024);
|
||||
var achKey = this._marshal.CreateVariable(1024);
|
||||
var achValue = this._marshal.CreateVariable(32768);
|
||||
var achValueSize = this._marshal.CreateVariable(4);
|
||||
var nameSize = this._marshal.CreateVariable(4);
|
||||
var achClassSize = this._marshal.CreateVariable(4); achClassSize.toBuffer().writeUInt32LE(1024);
|
||||
var numSubKeys = this._marshal.CreateVariable(4);
|
||||
var numValues = this._marshal.CreateVariable(4);
|
||||
var longestSubkeySize = this._marshal.CreateVariable(4);
|
||||
var longestClassString = this._marshal.CreateVariable(4);
|
||||
var longestValueName = this._marshal.CreateVariable(4);
|
||||
var longestValueData = this._marshal.CreateVariable(4);
|
||||
var securityDescriptor = this._marshal.CreateVariable(4);
|
||||
var lastWriteTime = this._marshal.CreateVariable(8);
|
||||
|
||||
retVal = this._AdvApi.RegQueryInfoKeyA(h.Deref(), achClass, achClassSize, 0,
|
||||
numSubKeys, longestSubkeySize, longestClassString, numValues,
|
||||
longestValueName, longestValueData, securityDescriptor, lastWriteTime);
|
||||
if (retVal.Val != 0) { throw ('RegQueryInfoKeyA() returned error: ' + retVal.Val); }
|
||||
for(var i = 0; i < numSubKeys.toBuffer().readUInt32LE(); ++i)
|
||||
{
|
||||
nameSize.toBuffer().writeUInt32LE(1024);
|
||||
retVal = this._AdvApi.RegEnumKeyExA(h.Deref(), i, achKey, nameSize, 0, 0, 0, lastWriteTime);
|
||||
if(retVal.Val == 0)
|
||||
{
|
||||
result.subkeys.push(achKey.String);
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < numValues.toBuffer().readUInt32LE() ; ++i)
|
||||
{
|
||||
achValueSize.toBuffer().writeUInt32LE(32768);
|
||||
if(this._AdvApi.RegEnumValueA(h.Deref(), i, achValue, achValueSize, 0, 0, 0, 0).Val == 0)
|
||||
{
|
||||
result.values.push(achValue.String);
|
||||
}
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
if(this._AdvApi.RegQueryValueExA(h.Deref(), key, 0, 0, 0, len).Val == 0)
|
||||
{
|
||||
var data = this._marshal.CreateVariable(len.toBuffer().readUInt32LE());
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
|||
var KEY_QUERY_VALUE=1;var KEY_WRITE=131078;var KEY_DATA_TYPES={REG_NONE:0,REG_SZ:1,REG_EXPAND_SZ:2,REG_BINARY:3,REG_DWORD:4,REG_DWORD_BIG_ENDIAN:5,REG_LINK:6,REG_MULTI_SZ:7,REG_RESOURCE_LIST:8,REG_FULL_RESOURCE_DESCRIPTOR:9,REG_RESOURCE_REQUIREMENTS_LIST:10,REG_QWORD:11};function windows_registry(){this._ObjectId="win-registry";this._marshal=require("_GenericMarshal");this._AdvApi=this._marshal.CreateNativeProxy("Advapi32.dll");this._AdvApi.CreateMethod("RegCreateKeyExA");this._AdvApi.CreateMethod("RegOpenKeyExA");this._AdvApi.CreateMethod("RegQueryValueExA");this._AdvApi.CreateMethod("RegCloseKey");this._AdvApi.CreateMethod("RegDeleteKeyA");this._AdvApi.CreateMethod("RegDeleteValueA");this._AdvApi.CreateMethod("RegSetValueExA");this.HKEY={Root:Buffer.from("80000000","hex").swap32(),CurrentUser:Buffer.from("80000001","hex").swap32(),LocalMachine:Buffer.from("80000002","hex").swap32(),Users:Buffer.from("80000003","hex").swap32()};this.QueryKey=function b(g,k,i){var e=this._marshal.CreatePointer();var j=this._marshal.CreateVariable(4);var m=this._marshal.CreateVariable(4);i=this._marshal.CreateVariable(i);var f=this._marshal.CreatePointer(g);var l=null;if(this._AdvApi.RegOpenKeyExA(f,this._marshal.CreateVariable(k),0,KEY_QUERY_VALUE,e).Val!=0){throw ("Error Opening Registry Key: "+k)}if(this._AdvApi.RegQueryValueExA(e.Deref(),i,0,0,0,j).Val==0){var d=this._marshal.CreateVariable(j.toBuffer().readUInt32LE());if(this._AdvApi.RegQueryValueExA(e.Deref(),i,0,m,d,j).Val==0){switch(m.toBuffer().readUInt32LE()){case KEY_DATA_TYPES.REG_DWORD:l=d.toBuffer().readUInt32LE();break;case KEY_DATA_TYPES.REG_DWORD_BIG_ENDIAN:l=d.toBuffer().readUInt32BE();break;case KEY_DATA_TYPES.REG_SZ:l=d.String;break;case KEY_DATA_TYPES.REG_BINARY:default:l=d.toBuffer();l._data=d;break}}}else{this._AdvApi.RegCloseKey(e.Deref());throw ("Not Found")}this._AdvApi.RegCloseKey(e.Deref());return(l)};this.WriteKey=function c(g,j,i,l){var k;var f=this._marshal.CreatePointer();if(this._AdvApi.RegCreateKeyExA(this._marshal.CreatePointer(g),this._marshal.CreateVariable(j),0,0,0,KEY_WRITE,0,f,0).Val!=0){throw ("Error Opening Registry Key: "+j)}var d;var e;switch(typeof(l)){case"boolean":e=KEY_DATA_TYPES.REG_DWORD;d=this._marshal.CreateVariable(4);d.toBuffer().writeUInt32LE(l?1:0);break;case"number":e=KEY_DATA_TYPES.REG_DWORD;d=this._marshal.CreateVariable(4);d.toBuffer().writeUInt32LE(l);break;case"string":e=KEY_DATA_TYPES.REG_SZ;d=this._marshal.CreateVariable(l);break;default:e=KEY_DATA_TYPES.REG_BINARY;d=this._marshal.CreateVariable(l.length);l.copy(d.toBuffer());break}if(this._AdvApi.RegSetValueExA(f.Deref(),this._marshal.CreateVariable(i),0,e,d,d._size).Val!=0){this._AdvApi.RegCloseKey(f.Deref());throw ("Error writing reg key: "+i)}this._AdvApi.RegCloseKey(f.Deref())};this.DeleteKey=function a(e,g,f){if(!f){if(this._AdvApi.RegDeleteKeyA(this._marshal.CreatePointer(e),this._marshal.CreateVariable(g)).Val!=0){throw ("Error Deleting Key: "+g)}}else{var d=this._marshal.CreatePointer();var i;if(this._AdvApi.RegOpenKeyExA(this._marshal.CreatePointer(e),this._marshal.CreateVariable(g),0,KEY_QUERY_VALUE|KEY_WRITE,d).Val!=0){throw ("Error Opening Registry Key: "+g)}if((i=this._AdvApi.RegDeleteValueA(d.Deref(),this._marshal.CreateVariable(f)).Val)!=0){this._AdvApi.RegCloseKey(d.Deref());throw ("Error["+i+"] Deleting Key: "+g+"."+f)}this._AdvApi.RegCloseKey(d.Deref())}}}module.exports=new windows_registry();
|
||||
var KEY_QUERY_VALUE=1;var KEY_ENUMERATE_SUB_KEYS=8;var KEY_WRITE=131078;var KEY_DATA_TYPES={REG_NONE:0,REG_SZ:1,REG_EXPAND_SZ:2,REG_BINARY:3,REG_DWORD:4,REG_DWORD_BIG_ENDIAN:5,REG_LINK:6,REG_MULTI_SZ:7,REG_RESOURCE_LIST:8,REG_FULL_RESOURCE_DESCRIPTOR:9,REG_RESOURCE_REQUIREMENTS_LIST:10,REG_QWORD:11};function windows_registry(){this._ObjectId="win-registry";this._marshal=require("_GenericMarshal");this._AdvApi=this._marshal.CreateNativeProxy("Advapi32.dll");this._AdvApi.CreateMethod("RegCreateKeyExA");this._AdvApi.CreateMethod("RegEnumKeyExA");this._AdvApi.CreateMethod("RegEnumValueA");this._AdvApi.CreateMethod("RegOpenKeyExA");this._AdvApi.CreateMethod("RegQueryInfoKeyA");this._AdvApi.CreateMethod("RegQueryValueExA");this._AdvApi.CreateMethod("RegCloseKey");this._AdvApi.CreateMethod("RegDeleteKeyA");this._AdvApi.CreateMethod("RegDeleteValueA");this._AdvApi.CreateMethod("RegSetValueExA");this.HKEY={Root:Buffer.from("80000000","hex").swap32(),CurrentUser:Buffer.from("80000001","hex").swap32(),LocalMachine:Buffer.from("80000002","hex").swap32(),Users:Buffer.from("80000003","hex").swap32()};this.QueryKey=function b(o,A,q){var l;var m=this._marshal.CreatePointer();var s=this._marshal.CreateVariable(4);var E=this._marshal.CreateVariable(4);var n=this._marshal.CreatePointer(o);var C=null;if(q){q=this._marshal.CreateVariable(q)}if(!A){A=""}if((l=this._AdvApi.RegOpenKeyExA(n,this._marshal.CreateVariable(A),0,KEY_QUERY_VALUE|KEY_ENUMERATE_SUB_KEYS,m).Val)!=0){throw ("Opening Registry Key: "+A+" => Returned Error: "+l)}if((A==""&&!q)||!q){var B={subkeys:[],values:[]};var d=this._marshal.CreateVariable(1024);var f=this._marshal.CreateVariable(1024);var g=this._marshal.CreateVariable(32768);var j=this._marshal.CreateVariable(4);var x=this._marshal.CreateVariable(4);var e=this._marshal.CreateVariable(4);e.toBuffer().writeUInt32LE(1024);var y=this._marshal.CreateVariable(4);var z=this._marshal.CreateVariable(4);var u=this._marshal.CreateVariable(4);var t=this._marshal.CreateVariable(4);var w=this._marshal.CreateVariable(4);var v=this._marshal.CreateVariable(4);var D=this._marshal.CreateVariable(4);var r=this._marshal.CreateVariable(8);C=this._AdvApi.RegQueryInfoKeyA(m.Deref(),d,e,0,y,u,t,z,w,v,D,r);if(C.Val!=0){throw ("RegQueryInfoKeyA() returned error: "+C.Val)}for(var p=0;p<y.toBuffer().readUInt32LE();++p){x.toBuffer().writeUInt32LE(1024);C=this._AdvApi.RegEnumKeyExA(m.Deref(),p,f,x,0,0,0,r);if(C.Val==0){B.subkeys.push(f.String)}}for(var p=0;p<z.toBuffer().readUInt32LE();++p){j.toBuffer().writeUInt32LE(32768);if(this._AdvApi.RegEnumValueA(m.Deref(),p,g,j,0,0,0,0).Val==0){B.values.push(g.String)}}return(B)}if(this._AdvApi.RegQueryValueExA(m.Deref(),q,0,0,0,s).Val==0){var k=this._marshal.CreateVariable(s.toBuffer().readUInt32LE());if(this._AdvApi.RegQueryValueExA(m.Deref(),q,0,E,k,s).Val==0){switch(E.toBuffer().readUInt32LE()){case KEY_DATA_TYPES.REG_DWORD:C=k.toBuffer().readUInt32LE();break;case KEY_DATA_TYPES.REG_DWORD_BIG_ENDIAN:C=k.toBuffer().readUInt32BE();break;case KEY_DATA_TYPES.REG_SZ:C=k.String;break;case KEY_DATA_TYPES.REG_BINARY:default:C=k.toBuffer();C._data=k;break}}}else{this._AdvApi.RegCloseKey(m.Deref());throw ("Not Found")}this._AdvApi.RegCloseKey(m.Deref());return(C)};this.WriteKey=function c(g,j,i,l){var k;var f=this._marshal.CreatePointer();if(this._AdvApi.RegCreateKeyExA(this._marshal.CreatePointer(g),this._marshal.CreateVariable(j),0,0,0,KEY_WRITE,0,f,0).Val!=0){throw ("Error Opening Registry Key: "+j)}var d;var e;switch(typeof(l)){case"boolean":e=KEY_DATA_TYPES.REG_DWORD;d=this._marshal.CreateVariable(4);d.toBuffer().writeUInt32LE(l?1:0);break;case"number":e=KEY_DATA_TYPES.REG_DWORD;d=this._marshal.CreateVariable(4);d.toBuffer().writeUInt32LE(l);break;case"string":e=KEY_DATA_TYPES.REG_SZ;d=this._marshal.CreateVariable(l);break;default:e=KEY_DATA_TYPES.REG_BINARY;d=this._marshal.CreateVariable(l.length);l.copy(d.toBuffer());break}if(this._AdvApi.RegSetValueExA(f.Deref(),this._marshal.CreateVariable(i),0,e,d,d._size).Val!=0){this._AdvApi.RegCloseKey(f.Deref());throw ("Error writing reg key: "+i)}this._AdvApi.RegCloseKey(f.Deref())};this.DeleteKey=function a(e,g,f){if(!f){if(this._AdvApi.RegDeleteKeyA(this._marshal.CreatePointer(e),this._marshal.CreateVariable(g)).Val!=0){throw ("Error Deleting Key: "+g)}}else{var d=this._marshal.CreatePointer();var i;if(this._AdvApi.RegOpenKeyExA(this._marshal.CreatePointer(e),this._marshal.CreateVariable(g),0,KEY_QUERY_VALUE|KEY_WRITE,d).Val!=0){throw ("Error Opening Registry Key: "+g)}if((i=this._AdvApi.RegDeleteValueA(d.Deref(),this._marshal.CreateVariable(f)).Val)!=0){this._AdvApi.RegCloseKey(d.Deref());throw ("Error["+i+"] Deleting Key: "+g+"."+f)}this._AdvApi.RegCloseKey(d.Deref())}}}module.exports=new windows_registry();
|
Loading…
Add table
Add a link
Reference in a new issue