For those wishing to gain programmatic access to Infocyte HUNT or simply to grab data in CSV or JSON formats, the Infocyte HUNT API Powershell Module is a great way to start. This module has functions and cmdlets which interact with the HUNT API to extract data, manage target groups, upload offline scans, or even initiate collection.
Step 1: Install the Module
Open an Administrative Powershell prompt and type:
Install-Module -Name InfocyteHUNTAPI
NOTE: You will be prompted "You are installing the modules from an untrusted repository."
Step 2: Create new API token in HUNT
Before HTTP requests can be run against the HUNT server, an API token must be generated in the admin section of the HUNT UI for use with the HUNT Powershell module.
Click the account icon at the top right hand side of HUNT, then click Admin.
If logged in as an admin user you will see an option for "Users & Tokens" on the left hand menu of the Admin screen. Click the Users & Tokens button and select the tab “API Tokens”, then click "Create new token" at the top right of the API tokens screen.
If logged in as an analyst user the API tokens screen can be accessed from the "My Profile" screen.
Each API token requires a name before it can be generated, input the desired name for the token then click create. After clicking create, the token will be displayed only once so be sure to copy and store it in a secure location for future use. Once the token has been copied, you can click the close button to close the new API token window.
Step 3: After the modules have been imported, set your Infocyte Cloud Instance CNAME (MYCNAME.infocyte.com) and API token
PS > Set-ICToken -Instance MYCNAME -Token <TOKEN>
A message stating that you Auth token is being set for the specified URL should be displayed.
Step 4: Run your commands!