Skip to main content

Threatlocker - Set Learning Mode

Summary

This script retrieves API keys from the client's password tab and uses them securely within the script to assist in enabling learning mode for the machine. Each organization has separate API keys (confirmed by ThreatLocker support).

Note:
Please refer to the instructions/FAQ section for creating a new application or using an existing application policy to get the application ID. Ensure to whitelist the file hash for the corresponding application ID rule.

Sample Run

Sample Run

Dependencies

  • ThreatLocker Authentication keys (must be requested from ThreatLocker support)
    • Maintenance Mode Key
    • Reports Key

Passwords

Password TitleDescription
ThreatLocker Maintenance KeyStores the ThreatLocker maintenance authentication key.
ThreatLocker RepKeyStores the ThreatLocker repository authentication key.

Variables

NameDescription
MaintKeyStores the ThreatLocker maintenance key value from the client's password titled "Maintenance ThreatLocker Key".
RepKeyStores the ThreatLocker RepKey value from the client's password titled "Maintenance RepKey".
ProjectNameSets the name of the PowerShell executable and the directory where the execution record will be stored.
WorkingDirectoryStores the complete path of the directory where the script will be executed.
PS1LogStores the path of the text file where the successful logging results of the script will be stored.
PS1ErrorLogStores the path of the text file where the failure logging results of the script will be stored.
LogContentStores the success result records of the script execution.
ErrorLogStores the failure result records of the script execution.

Global Parameters

NameExampleRequiredDescription
TableNamepvl_threatlocker-disable_auditTrueStores the table name where the script data will be stored.

User Parameters

NameExampleRequiredDescription
learningDuration1FalseThe duration (in hours) for which the learning mode must be set. The default value is 1.
ReasonApplication installationFalseStores the reason for setting ThreatLocker in learning mode. By default, it is set to 'No Reason Provided'.
MethodLearning/InstallationTrueIt is required to set the application control maintenance mode to learning or installation.
TargetComputerNameTestMachineTrueProvide the name of the target computer where you want to set the ThreatLocker learning/installation mode.

Properties

NameRequiredExampleDescription
ThreatLocker_ApplicationIdTrueXXXX0101-0000-XXXX-1111-XXXX1111XX00This ID is required to set maintenance mode using the API instance.
Threatlocker_ComputerIdTrue680This is the ID of the computer where only the script will execute. This script shouldn't be run on all local machines; rather, it should run on only one machine whose ID is set in this property. It could be the Automate server for on-prem, and for a Hosted partner, we can ask the partner for approval.

Output

  • Script log
  • pvl_threatlocker-disable_audit (Table)
  • Local file on the computer
  • Data view

Instructions/FAQ

Q: Will ThreatLocker block this script from setting it to learning mode?
A: Yes, ThreatLocker will block the .ps1 file generated by this script. To allow the script to work, the partner needs to whitelist the file hash "9FA61A436668967C26CB76858275EC17" and deploy the policy for proper script execution.

Q: How do I get the ApplicationId?
A: Log in to https://portal.threatlocker.com/. Navigate to Modules → Application Control → New Application → New Application. A new tab titled "Create Application" will open.

Creating Application

Creating the Application

  • The application name can be set to anything.
    Application Name

  • Set the application file hash as whitelisted.
    Whitelist Application Hash
    Whitelist Application Hash

  • Click "Create Policy."

  • Once the policy is created, launch it and set the application ID to the system property "ThreatLocker_ApplicationId."
    Set Application ID

  • Enter it in System → Dashboard → Config → Configurations → Properties in Automate.
    Enter in Automate

Q: What are the script dependencies, and what errors can it report?
A: Dependencies and errors are as follows:

  • For GET /Reports: Report AuthKey and ReportId are mandatory.
    GET /Reports Dependencies

  • For POST /MaintenanceMode: MaintenanceMode AuthKey, ComputerId, ApplicationId, and Method must be set appropriately.
    POST /MaintenanceMode Dependencies

Attachments

MAINTENANCEMODE_-POST(1)_(1).pdf MAINTENANCEMODEBULK_-POST_1.pdf REPORTS_-GET_DATA(1)_(1).pdf REQUESTS_-GET(1)_(1).pdf