add agent psinfo (#5476)
Signed-off-by: si458 <simonsmith5521@gmail.com>
Simon Smith committed
Oct 28, 2023 at 19:29 UTC
e0d73b2fcdbbc8deb1508aaaf09ede343d326f81
3 files changed
+35
-1
agents/meshcore.js
+3
@@ -1262,6 +1262,9 @@ function handleServerCommand(data) {
1262
// Requestion details information about a process
1263
if (data.pid) {
1264
var info = {}; // TODO: Replace with real data. Feel free not to give all values if not available.
1265
+ try {
1266
+ info = processManager.getProcessInfo(data.pid);
1267
+ }catch(e){ }
1268
/*
1269
info.processUser = "User"; // String
1270
info.processDomain = "Domain"; // String
public/scripts/common-0.0.1.js
+27
-1
@@ -150,4 +150,30 @@ function check_webp_feature(feature, callback) {
150
callback(feature, false);
151
};
152
img.src = 'data:image/webp;base64,' + kTestImages[feature];
153
-}
\ No newline at end of file
153
+}
154
+
155
+// camelCase converter for JSON
156
+function jsonToCamel(o) {
157
+ var newO, origKey, newKey, value
158
+ if (o instanceof Array) {
159
+ return o.map(function(value) {
160
+ if (typeof value === "object") {
161
+ value = jsonToCamel(value)
162
+ }
163
+ return value
164
+ })
165
+ } else {
166
+ newO = {}
167
+ for (origKey in o) {
168
+ if (o.hasOwnProperty(origKey)) {
169
+ newKey = (origKey.charAt(0).toLowerCase() + origKey.slice(1) || origKey).toString()
170
+ value = o[origKey]
171
+ if (value instanceof Array || (value !== null && value.constructor === Object)) {
172
+ value = jsonToCamel(value)
173
+ }
174
+ newO[newKey] = value
175
+ }
176
+ }
177
+ }
178
+ return newO
179
+ }
\ No newline at end of file
views/default.handlebars
+5
@@ -2627,6 +2627,11 @@
2627
var x = '<div style=max-height:200px;overflow-y:auto>';
2628
//x += addHtmlValue4("Process ID", message.pid);
2629
if ((typeof message.value == 'object') && (Object.keys(message.value).length > 0)) {
2630
+ // lets fix agent psinfo not being camelcase
2631
+ message.value = jsonToCamel(message.value);
2632
+ if(!message.value.cmd && message.value.path){ message.value.cmd = message.value.path }
2633
+ if(!message.value.processUser && message.value.userName){ message.value.processUser = message.value.userName.split("\\")[1]; }
2634
+ if(!message.value.processDomain && message.value.userName){ message.value.processDomain = message.value.userName.split("\\")[0]; }
2635
if (message.value.processName) { x += '<div style=padding:4px><div style=padding-bottom:4px>' + "Process Name" + '</div><div style=word-wrap:break-word;padding-left:6px><b>' + message.value.processName + '</b></div></div>'; }
2636
if (message.value.machineName) { x += addHtmlValue5("Machine Name", message.value.machineName); }
2637
if (message.value.cmd) { x += '<div style=padding:4px><div style=padding-bottom:4px>' + "Command Line" + '</div><div style=word-wrap:break-word;padding-left:6px><b>' + message.value.cmd + '</b></div></div>'; }