Created
August 8, 2022 20:41
-
-
Save cmcdevitt/e4088c72fe7aee60bfc5c4de7446b978 to your computer and use it in GitHub Desktop.
Generate Tanium API Key via ServiceNow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
How to call the Script Include | |
var util = new sn_vul.TaniumUtilities(); | |
var out = util.login(); | |
This requires a REST Message called "Tanium" | |
HTTP Method: (POST) Login, Endpoint: ${baseURL}/api/v2/session/login, Authentication type: No authentication | |
Note: You may need use select a MID server if this is on Prem (HTTP Method -> HTTP Request: Use MID Server | |
*/ | |
var TaniumUtilities = Class.create(); | |
TaniumUtilities.prototype = { | |
initialize: function() { | |
this.baseUrl = 'https://tanium-xxxx.com';//Your Tanium host | |
}, | |
login: function() { | |
var taniumLogin = new sn_ws.RESTMessageV2("Tanium", "Login"); | |
taniumLogin.setStringParameter('baseURL', this.baseUrl); | |
var body_message = '{"username":"tom.tanium","password":"tan1um4t3hw1n!"}'; | |
taniumLogin.setRequestBody(body_message); | |
var response = taniumLogin.execute(); | |
var status = response.getStatusCode(); | |
gs.info("CCCC: status " + status); | |
var out = response.getBody(); | |
gs.info("CCCC body " + out); | |
var session = JSON.parse(out); | |
var keys = []; | |
for (var key in session) { | |
//keys.push(key); | |
gs.info("CCCC keys: " + key); | |
} | |
gs.info("CCCC " + session.data.session); | |
}, | |
type: 'TaniumUtilities' | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment