Skip to content

Instantly share code, notes, and snippets.

@cmcdevitt
Created August 8, 2022 20:41
Show Gist options
  • Save cmcdevitt/e4088c72fe7aee60bfc5c4de7446b978 to your computer and use it in GitHub Desktop.
Save cmcdevitt/e4088c72fe7aee60bfc5c4de7446b978 to your computer and use it in GitHub Desktop.
Generate Tanium API Key via ServiceNow
/*
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