-
Notifications
You must be signed in to change notification settings - Fork 0
/
prod_sensors.xml
483 lines (430 loc) · 18.2 KB
/
prod_sensors.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
<!-- Exported using version "7_3_314_4103" on Tuesday, November 12, 2019 2:20:23 PM -->
<content>
<sensor>
<name>TanCD Tanium Action Failure</name>
<what_hash>1510220215</what_hash>
<category>TanCD</category>
<description>Provided with an action number as a parameter, this sensor returns True or False based on Exit Code from the action from each client machine that executed the action.</description>
<parameters>
<parameter_text>{"parameters":[{"parameterType":"com.tanium.components.parameters::NumericParameter","model":"com.tanium.components.parameters::NumericParameter","key":"actionNumber","label":"Action ID"}],"model":"com.tanium.components.parameters::ParametersArray","parameterType":"com.tanium.components.parameters::ParametersArray"}</parameter_text>
</parameters>
<result_type>1</result_type>
<qseconds>900</qseconds>
<ignore_case_flag>1</ignore_case_flag>
<exclude_from_parse>1</exclude_from_parse>
<delimiter>,</delimiter>
<hidden_flag>0</hidden_flag>
<queries>
<sensor_query>
<sensor_type>8</sensor_type>
<os>0</os>
<query>#!/usr/bin/python
import os.path
from os import path
import tanium
import tanium.sensor_io.sensor_input
tanium_add_results = tanium.results.add
inputs = tanium.sensor_io.sensor_input.SensorInputs()
inputs.add_param('actionid', '||actionNumber||', None)
actionid = inputs.get_param('actionid')
downloads_dir = tanium.client.common.get_client_dir('Downloads')
#sensorname = "Chuck Norris Fact"
#perf_dir = "/opt/Tanium/TaniumClient/Downloads"
action_log = downloads_dir + "/Action_" + actionid + ".log"
actionfailure="True"
#if path.exists(action_log):
# with open(action_log, 'r') as fin:
# row=fin.readline()
# while row:
# if "Action Exit Code: 0" in row:
# actionfailure="False"
if path.exists(action_log):
with open(action_log) as fp:
for line in fp:
if "Action Exit Code: 0" in line:
actionfailure="False"
else:
actionfailure="False"
tanium_add_results(actionfailure)
</query>
<signature></signature>
</sensor_query>
<sensor_query>
<sensor_type>6</sensor_type>
<os>1</os>
<query>#!/bin/bash
export sensor_name="TanCD Tanium Action Failure"
[ -f /opt/Tanium/TaniumClient/perf/perf.sh ] && . /opt/Tanium/TaniumClient/perf/perf.sh
#@INCLUDE=i18n/UTF8Decode.sh
#@START_INCLUDES_HERE
#------------ INCLUDES START - Do not edit between this line and INCLUDE ENDS -----
#- Begin file: utils/settings/get_client_dir.sh
# To include this file, copy/paste: INCLUDE=utils/settings/get_client_dir.sh
get_client_dir() {
if [ -n "$TANIUM_CLIENT_ROOT" ]; then
echo "$TANIUM_CLIENT_ROOT/"
elif [ -f "./TaniumClient" ] && [ -x "./TaniumClient" ]; then
echo "./"
elif [ -f "../../TaniumClient" ] && [ -x "../../TaniumClient" ]; then
echo "../../"
else
OS=$(uname)
if [ "$OS" = "Darwin" ]; then
BASE=/Library
else
BASE=/opt
fi
if [ -f "$BASE/Tanium/TaniumClient/TaniumClient" ] && [ -x "$BASE/Tanium/TaniumClient/TaniumClient" ]; then
echo "$BASE/Tanium/TaniumClient/"
else
echo "Can not find Tanium Client directory"
exit 1
fi
fi
}
#- End file: utils/settings/get_client_dir.sh
#- Begin file: i18n/UTF8Decode.sh
# To include this file, copy/paste: INCLUDE=i18n/UTF8Decode.sh
utf8decode() {
# if we have the Tanium Python Engine available, then use it to convert the parameter
TPYTHON_PATH="$(get_client_dir)python27/python"
if [ -f "$TPYTHON_PATH" ]; then
$TPYTHON_PATH -c "from tanium import util; print util.unescape('$1').encode('utf-8')"
else
# No python, resort to old style that we know works everywhere, but only decodes a fixed set
# decode everything between 0x20-0x7E except:
#0 1 2 3 4 5 6 7 8 9 (0x30-0x39)
#A B C D E F G H I J K L M N O P Q R S T U V W X Y Z (0x41-0x5A)
#a b c d e f g h i j k l m n o p q r s t u v w x y z (0x61-0x7A)
echo "$1" | sed -e 's/%20/ /g' \
-e 's/%21/!/g' \
-e 's/%22/"/g' \
-e 's/%23/#/g' \
-e 's/%24/$/g' \
-e 's/%25/%/g' \
-e 's/%26/\&/g' \
-e "s/%27/'/g" \
-e 's/%28/(/g' \
-e 's/%29/)/g' \
-e 's/%2[aA]/*/g' \
-e 's/%2[bB]/+/g' \
-e 's/%2[cC]/,/g' \
-e 's/%2[dD]/-/g' \
-e 's/%2[eE]/./g' \
-e 's#%2[fF]#/#g' \
-e 's/%3[aA]/:/g' \
-e 's/%3[bB]/;/g' \
-e 's/%3[cC]/</g' \
-e 's/%3[dD]/=/g' \
-e 's/%3[eE]/>/g' \
-e 's/%3[fF]/?/g' \
-e 's/%40/@/g' \
-e 's/%5[bB]/[/g' \
-e 's/%5[cC]/\\/g' \
-e 's/%5[dD]/]/g' \
-e 's/%5[eE]/^/g' \
-e 's/%5[fF]/_/g' \
-e 's/%60/`/g' \
-e 's/%7[bB]/{/g' \
-e 's/%7[cC]/|/g' \
-e 's/%7[dD]/}/g' \
-e 's/%7[eE]/~/g'
fi
}
#- End file: i18n/UTF8Decode.sh
#------------ INCLUDES END - Do not edit above this line and INCLUDE STARTS -----
ACTIONID=$(utf8decode "||actionNumber||")
if [ -r "Downloads/Action_$ACTIONID.log" ]
then
##
# if the action exit code is not zero, then assume failure...
if [ "$(grep -c "Action Exit Code: 0" "Downloads/Action_$ACTIONID.log")" -eq 0 ]
then
if [ "$(grep -c "Action Exit Code" "Downloads/Action_$ACTIONID.log")" -gt 0 ]
then
echo "True"
else
if [ "$(grep -c "ActionCommandTimedOut" "Downloads/Action_$ACTIONID.log")" -gt 0 ]
then
echo "True"
else
echo "False"
fi
fi
else
echo "False"
fi
fi
</query>
<signature></signature>
</sensor_query>
<sensor_query>
<sensor_type>6</sensor_type>
<os>2</os>
<query>#!/bin/sh
echo "NA on Mac"
</query>
<signature></signature>
</sensor_query>
<sensor_query>
<sensor_type>6</sensor_type>
<os>3</os>
<query>#!/bin/sh
echo "NA on Solaris"
</query>
<signature></signature>
</sensor_query>
<sensor_query>
<sensor_type>6</sensor_type>
<os>4</os>
<query>#!/bin/sh
echo "NA on AIX"
</query>
<signature></signature>
</sensor_query>
</queries>
<columns/>
<meta_data/>
<content_set>
<name>Default</name>
<description></description>
<reserved_name>default</reserved_name>
<meta_data/>
</content_set>
</sensor>
<sensor>
<name>TanCD Tanium Action Output</name>
<what_hash>3255141282</what_hash>
<category>TanCD</category>
<description>Provided with an action number as a parameter, this sensor returns the last 5 lines of output from the action from each client machine that executed the action.</description>
<parameters>
<parameter_text>{"parameters":[{"parameterType":"com.tanium.components.parameters::NumericParameter","model":"com.tanium.components.parameters::NumericParameter","key":"actionNumber","label":"Action ID"}],"model":"com.tanium.components.parameters::ParametersArray","parameterType":"com.tanium.components.parameters::ParametersArray"}</parameter_text>
</parameters>
<result_type>1</result_type>
<qseconds>900</qseconds>
<ignore_case_flag>1</ignore_case_flag>
<exclude_from_parse>1</exclude_from_parse>
<delimiter>|</delimiter>
<hidden_flag>0</hidden_flag>
<queries>
<sensor_query>
<sensor_type>8</sensor_type>
<os>0</os>
<query>#!/usr/bin/python
import os.path
from os import path
import tanium
import tanium.sensor_io.sensor_input
import md5
tanium_add_results = tanium.results.add
inputs = tanium.sensor_io.sensor_input.SensorInputs()
inputs.add_param('actionid', '||actionNumber||', None)
actionid = inputs.get_param('actionid')
downloads_dir = tanium.client.common.get_client_dir('Downloads')
#sensorname = "Chuck Norris Fact"
#perf_dir = "/opt/Tanium/TaniumClient/Downloads"
#inputs = tanium.sensor_io.sensor_input.SensorInputs()
#inputs.add_param('actionid', '||actionNumber||', None)
#actionid = "116333"
#downloads_dir = "/opt/Tanium/TaniumClient/Downloads"
#tanium.client.common.get_client_dir('Downloads')
#sensorname = "Chuck Norris Fact"
#perf_dir = "/opt/Tanium/TaniumClient/Downloads"
action_log = downloads_dir + "/Action_" + actionid + ".log"
cmdout=False
output=[]
if path.exists(action_log):
with open(action_log) as fp:
for line in fp:
#print line
if "CommandLine" in line:
cmdout=True
continue
if cmdout:
if "Action Timing" in line:
cmdout=False
continue
else:
output.append(line.strip())
output = output[-5:]
outstring="\n".join(output)
hash = md5.new(outstring).hexdigest()[0:5]
i = 0
outstring=""
while i < len(output):
outstring+=hash + "|" + str(i) + "|" + output[i] + "\n"
i += 1
tanium_add_results(outstring)
</query>
<signature></signature>
</sensor_query>
<sensor_query>
<sensor_type>6</sensor_type>
<os>1</os>
<query>#!/bin/bash
export sensor_name="TanCD Tanium Action Output"
[ -f /opt/Tanium/TaniumClient/perf/perf.sh ] && . /opt/Tanium/TaniumClient/perf/perf.sh
#@INCLUDE=i18n/UTF8Decode.sh
#@START_INCLUDES_HERE
#------------ INCLUDES START - Do not edit between this line and INCLUDE ENDS -----
#- Begin file: utils/settings/get_client_dir.sh
# To include this file, copy/paste: INCLUDE=utils/settings/get_client_dir.sh
get_client_dir() {
if [ -n "$TANIUM_CLIENT_ROOT" ]; then
echo "$TANIUM_CLIENT_ROOT/"
elif [ -f "./TaniumClient" ] && [ -x "./TaniumClient" ]; then
echo "./"
elif [ -f "../../TaniumClient" ] && [ -x "../../TaniumClient" ]; then
echo "../../"
else
OS=$(uname)
if [ "$OS" = "Darwin" ]; then
BASE=/Library
else
BASE=/opt
fi
if [ -f "$BASE/Tanium/TaniumClient/TaniumClient" ] && [ -x "$BASE/Tanium/TaniumClient/TaniumClient" ]; then
echo "$BASE/Tanium/TaniumClient/"
else
echo "Can not find Tanium Client directory"
exit 1
fi
fi
}
#- End file: utils/settings/get_client_dir.sh
#- Begin file: i18n/UTF8Decode.sh
# To include this file, copy/paste: INCLUDE=i18n/UTF8Decode.sh
utf8decode() {
# if we have the Tanium Python Engine available, then use it to convert the parameter
TPYTHON_PATH="$(get_client_dir)python27/python"
if [ -f "$TPYTHON_PATH" ]; then
$TPYTHON_PATH -c "from tanium import util; print util.unescape('$1').encode('utf-8')"
else
# No python, resort to old style that we know works everywhere, but only decodes a fixed set
# decode everything between 0x20-0x7E except:
#0 1 2 3 4 5 6 7 8 9 (0x30-0x39)
#A B C D E F G H I J K L M N O P Q R S T U V W X Y Z (0x41-0x5A)
#a b c d e f g h i j k l m n o p q r s t u v w x y z (0x61-0x7A)
echo "$1" | sed -e 's/%20/ /g' \
-e 's/%21/!/g' \
-e 's/%22/"/g' \
-e 's/%23/#/g' \
-e 's/%24/$/g' \
-e 's/%25/%/g' \
-e 's/%26/\&/g' \
-e "s/%27/'/g" \
-e 's/%28/(/g' \
-e 's/%29/)/g' \
-e 's/%2[aA]/*/g' \
-e 's/%2[bB]/+/g' \
-e 's/%2[cC]/,/g' \
-e 's/%2[dD]/-/g' \
-e 's/%2[eE]/./g' \
-e 's#%2[fF]#/#g' \
-e 's/%3[aA]/:/g' \
-e 's/%3[bB]/;/g' \
-e 's/%3[cC]/</g' \
-e 's/%3[dD]/=/g' \
-e 's/%3[eE]/>/g' \
-e 's/%3[fF]/?/g' \
-e 's/%40/@/g' \
-e 's/%5[bB]/[/g' \
-e 's/%5[cC]/\\/g' \
-e 's/%5[dD]/]/g' \
-e 's/%5[eE]/^/g' \
-e 's/%5[fF]/_/g' \
-e 's/%60/`/g' \
-e 's/%7[bB]/{/g' \
-e 's/%7[cC]/|/g' \
-e 's/%7[dD]/}/g' \
-e 's/%7[eE]/~/g'
fi
}
#- End file: i18n/UTF8Decode.sh
#------------ INCLUDES END - Do not edit above this line and INCLUDE STARTS -----
ACTIONID=$(utf8decode "||actionNumber||")
if [ -r "Downloads/Action_$ACTIONID.log" ]
then
year="$(date +%Y)"
output="$(grep -v "^${year}-" "Downloads/Action_$ACTIONID.log" | tail -n 5)"
if [ "$output"empty = "empty" ]
then
if [ "$(cat "Downloads/Action_$ACTIONID.log" | grep -c ActionCommandTimedOut)" -gt 0 ]
then
output="Action Command Timed Out"
else
output="No output"
fi
fi
##
# taking only the first 5 characters of an md5sum increases the chances of collision
# but, keeps the output more concice and easier to read.
# TODO: see if there is a way to have the tanium client create an FNV hash for this
hash="$(echo "$output" | md5sum | cut -c1-5)"
##
# add line numbers and output 3 fields
echo "$output" | awk -v hash="$hash" '{print hash "|" NR-1 "|" $0}'
fi
</query>
<signature></signature>
</sensor_query>
<sensor_query>
<sensor_type>6</sensor_type>
<os>2</os>
<query>#!/bin/sh
echo "NA on Mac"
</query>
<signature></signature>
</sensor_query>
<sensor_query>
<sensor_type>6</sensor_type>
<os>3</os>
<query>#!/bin/sh
echo "NA on Solaris"
</query>
<signature></signature>
</sensor_query>
<sensor_query>
<sensor_type>6</sensor_type>
<os>4</os>
<query>#!/bin/sh
echo "NA on AIX"
</query>
<signature></signature>
</sensor_query>
</queries>
<columns>
<column>
<column_index>0</column_index>
<name>hash</name>
<hidden_flag>0</hidden_flag>
<result_type>1</result_type>
<ignore_case_flag>1</ignore_case_flag>
<exclude_from_parse>0</exclude_from_parse>
</column>
<column>
<column_index>1</column_index>
<name>linenum</name>
<hidden_flag>0</hidden_flag>
<result_type>9</result_type>
<ignore_case_flag>1</ignore_case_flag>
<exclude_from_parse>0</exclude_from_parse>
</column>
<column>
<column_index>2</column_index>
<name>output</name>
<hidden_flag>0</hidden_flag>
<result_type>1</result_type>
<ignore_case_flag>1</ignore_case_flag>
<exclude_from_parse>0</exclude_from_parse>
</column>
</columns>
<meta_data/>
<content_set>
<name>Default</name>
<description></description>
<reserved_name>default</reserved_name>
<meta_data/>
</content_set>
</sensor>
</content>