BeyondTrust Password Safe
Unified password and session management for seamless accountability and control over privileged accounts.
Authentication & Identity Management · BeyondTrust Password Safe
Details
| ID | BeyondTrust Password Safe |
|---|---|
| Provider | BeyondTrust |
| Category | Authentication & Identity Management |
| From Version | 5.0.0 |
| Docker Image | demisto/python3:3.12.13.10116658 |
| Supported Modules | Agentix XSIAM |
README
Unified password and session management for seamless accountability and control over privileged accounts.
Each command is assigned a role. Users will not be able to run commands for which they are not assigned to the specific role for a command.
Fetch Credentials
For the fetch credentials function to work properly, you need to create a new asset, managed system, and managed account in BeyondTrust.
- In the BeyondTrust platform, create a new asset.
- Create a managed system.
The name of the system should be the name of the integration (service/platform) you want to use, which will make it easier to filter credentials. - In the managed system, create a managed account.
The name of the managed account will be the username/email (depending on how the instance is configured) and the password will be the password of the integration (when creating an instance).
Create a BeyondTrust API Key
To configure an integration instance, you need your BeyondTrust API key. The API key is generated after you configure an API Registration. For detailed instructions, see the BeyondTrust Password Safe Admin Guide.
Configure BeyondTrust Password Safe on Cortex XSOAR
- Navigate to Settings > Integrations > Servers & Services.
- Search for BeyondTrust Password Safe.
- Click Add instance to create and configure a new integration instance.
- Name: a textual name for the integration instance.
- Server URL (e.g., https://192.168.0.1)
- Username
- API Key
- Trust any certificate (not secure)
- Use system proxy settings
- Fetch credentials
- System Name (optional for fetch credentials)
- Click Test to validate the URLs, token, and connection.
Commands
You can execute these commands from the Cortex XSOAR CLI, as part of an automation, or in a playbook. After you successfully execute a command, a DBot message appears in the War Room with the command details.
Each command is assigned a role. Users will not be able to run commands for which they are not assigned to the specific role for a command.
- Get a list of managed accounts for the current user: beyondtrust-get-managed-accounts
- Get a list of managed systems: beyondtrust-get-managed-systems
- Create a new credentials release request: beyondtrust-create-release-request
- Check in or release a request: beyondtrust-check-in-credentials
- Get credential for an approved credentials release request: beyondtrust-get-credentials
- Update credentials for a managed account: beyondtrust-change-credentials
1. Get a list of managed accounts for the current user
Returns a list of managed accounts that the current user has permissions to request.
Base Command
beyondtrust-get-managed-accounts
Input
There are no inputs for this command.
Context Output
| Path | Type | Description |
|---|---|---|
| BeyondTrust.Account.PlatformID | Number | ID of the managed system platform. |
| BeyondTrust.Account.SystemID | Number | ID of the managed system. |
| BeyondTrust.Account.SystemName | String | Name of the managed system. |
| BeyondTrust.Account.DomainName | Number | ID of the managed account. |
| BeyondTrust.Account.AccountName | String | Name of the managed account. |
| BeyondTrust.Account.InstanceName | String | Database instance name of a database-type managed system. |
| BeyondTrust.Account.DefualtReleaseDuration | Number | Default release duration. |
| BeyondTrust.Account.MaximumReleaseDuration | Number | Maximum release duration. |
| BeyondTrust.Account.LastChangeDate | Date | The date and time of the last password change. |
| BeyondTrust.Account.NexeChangeDate | Date | The date and time of the next scheduled password change. |
| BeyondTrust.Account.IsChanging | Boolean | True if the account credentials are in the process of changing, otherwise false. |
| BeyondTrust.Account.IsISAAccess | Boolean | True if the account is for Information Systems Administrator (ISA) access, otherwise false. |
| BeyondTrust.Account.AccountID | Number | ID of the managed account. |
Command Example
!beyondtrust-get-managed-accounts
Human Readable Output
BeyondTrust Managed Accounts
| AccountName | AccountID | AssetName | AssetID | LastChangeDate | NextChangeDate |
|---|---|---|---|---|---|
| demisto | 1 | Demisto-lab-server | 1 | 2019-05-30T07:30:48.16 | 2019-07-01T21:00:00, |
| Test | 2 | Demisto-lab-server | 1 | 2019-05-30T12:05:06.683 | 2019-07-01T21:00:00, |
| shelly | 3 | shelly-test | 2 | 2019-05-30T12:59:12.313 |
2. Get a list of managed systems
Returns a list of managed systems.
Base Command
beyondtrust-get-managed-systems
Input
There are no inputs for this command.
Context Output
| Path | Type | Description |
|---|---|---|
| BeyondTrust.System.Port | Number | The port used to connect to the host. If null and the related Platform.PortFlag is true, Password Safe uses Platform.DefaultPort for communication. |
| BeyondTrust.System.Timeout | String | Connection timeout – Length of time in seconds before a slow or unresponsive connection to the system fails. |
| BeyondTrust.System.ResetPasswordOnMismatchFlag | Boolean | True to queue a password change when scheduled password test fails, otherwise false. |
| BeyondTrust.System.ChangeFrequencyDays | Number | When ChangeFrequencyType is “xdays”, the frequency with which the password changes (between 1-90 days). |
| BeyondTrust.System.ISAReleaseDuration | Number | Default Information Systems Administrator (ISA) release duration. |
| BeyondTrust.System.FunctionalAccountID | Number | ID of the functional account used for local Managed Account password changes. |
| BeyondTrust.System.ChangeFrequencyType | String | The change frequency for scheduled password changes: "first"– Changes are scheduled for the first day of the month; "last"– Changes are scheduled for the last day of the month; "xdays"– Changes are scheduled every "x" days (see ChangeFrequencyDays) |
| BeyondTrust.System.DirectoryID | Number | ID of the directory. Is set if the Managed System is a Directory. |
| BeyondTrust.System.ManagedAssetID | Number | ID of the Managed System. |
| BeyondTrust.System.AssetID | Number | ID of the asset. Is set if the Managed System is an Asset or a Database. |
| BeyondTrust.System.PlatformID | Number | ID of the Managed System Platform. |
| BeyondTrust.System.ElevationCommand | String | Elevation command to use (sudo, pbrun, or pmrun). |
| BeyondTrust.System.CheckPasswordFlag | Boolean | True to enable password testing, otherwise false. |
| BeyondTrust.System.CloudID | Number | ID of the Cloud System. Is set if the Managed System is a Cloud System. |
| BeyondTrust.System.DSSKeyRuleID | Number | ID of the default DSS Key Rule assigned to Managed Accounts that were created under this Managed System. |
| BeyondTrust.System.PasswordRuleID | Number | ID of the default Password Rule assigned to Managed Accounts that were created under this Managed System. |
| BeyondTrust.System.NetBiosName | String | Domain NetBIOS name. Setting this value will allow Password Safe to fall back to the NetBIOS name, if needed. |
| BeyondTrust.System.DatabaseID | Number | ID of the database. Is set if the Managed System is a Database. |
| BeyondTrust.System.MaxReleaseDuration | Number | Default maximum release duration. |
| BeyondTrust.System.ChangePasswordAfterAnyReleaseFlag | Boolean | True to change passwords on release of a request, otherwise false. |
| BeyondTrust.System.SystemName | String | Name of the related entity (Asset, Directory, Database, or Cloud). |
| BeyondTrust.System.ReleaseDuration | Number | Default release duration. |
| BeyondTrust.System.ContactEmail | String | Email address of the user that manages the system. |
| BeyondTrust.System.Description | String | The description of the system. |
| BeyondTrust.System.ChangeTime | String | Time (UTC) that password changes are scheduled to occur. |
| BeyondTrust.System.AutoManagementFlag | Boolean | True if password auto-management is enabled, otherwise false. |
| BeyondTrust.System.LoginAccountID | Number | ID of the Functional Account used for SSH session logins. |
Command Example
!beyondtrust-get-managed-systems
Human Readable Output
BeyondTrust Managed Accounts
| ManagedAssetID | ChangeFrequencyDays | AssetID | AssetName | PlatformID | Port |
|---|---|---|---|---|---|
| 1 | 30 | 2 | Demisto-lab-server | 2 | 22, |
| 2 | 30 | 3 | shelly-test | 2 | 22, |
| 3 | 30 | 4 | integration-test | 2 | 22, |
| 4 | 30 | 5 | Cybereason | 2 | 22 |
3. Create a new credentials release request
Creates a new credentials release request. This command gets the credentials (password) of the account for which the request was made. The outputs will show the credentials that were created for the account requested as plain text in the War Room, so we recommend that after you run this command, you also run the beyondtrust-change-credentials command.
Base Command
beyondtrust-create-release-request
Input
| Argument Name | Description | Required |
|---|---|---|
| access_type | The type of access requested (View, RDP, SSH). Defualt is "View". | Optional |
| system_id | ID of the Managed System to request. Get the ID from get-managed accounts command | Required |
| account_id | ID of the Managed Account to request. Get the ID from get-managed accounts command | Required |
| duration_minutes | The request duration (in minutes). | Required |
| reason | The reason for the request. | Optional |
| conflict_option | The conflict resolution option to use if an existing request is found for the same user, system and account ("reuse" or "renew"). | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| BeyondTrust.Request.Credentials | String | The credentials for the requested ID. |
| BeyondTrust.Request.RequestID | Number | The request ID. |
Command Example
!beyondtrust-create-release-request account_id=8 duration_minutes=2 system_id=3\
Human Readable Output
4. Check in or release a request
Checks-in/releases a request before it expires.
Base Command
beyondtrust-check-in-credentials
Input
| Argument Name | Description | Required |
|---|---|---|
| request_id | ID of the request to release. | Required |
| reason | A reason or comment why the request is being released. | Optional |
Context Output
There is no context output for this command.
Command Example
!beyondtrust-check-in-credentials request_id=295\
Human Readable Output
The release was successfully checked-in/released
5. Get credential for an approved credentials release request
Retrieves the credentials for an approved and active (not expired) credentials release request.
Base Command
beyondtrust-get-credentials
Input
| Argument Name | Description | Required |
|---|---|---|
| request_id | ID of the Request for which to retrieve the credentials | Required |
Context Output
There is no context output for this command.
Command Example
!beyondtrust-get-credentials request_id=294\
Human Readable Output
The credentials for BeyondTrust request: shelly
6. Update credentials for a managed account
Updates the credentials for a Managed Account, optionally applying the change to the Managed System.
Base Command
beyondtrust-change-credentials
Input
| Argument Name | Description | Required |
|---|---|---|
| account_id | ID of the account for which to set the credentials. | Required |
| password | The new password to set. If not given, generates a new, random password. | Optional |
| public_key | The new public key to set on the host. This is required if PrivateKey is given and updateSystem=true. | Optional |
| private_key | The private key to set (provide Passphrase if encrypted). | Optional |
| pass_phrase | The passphrase to use for an encrypted private key. | Optional |
| update_system | Whether to update the credentials on the referenced system. | Optional |
Context Output
There is no context output for this command.
Command Example
!beyondtrust-change-credentials account_id=8
Human Readable Output
The password has been changed
Base Command
beyondtrust-get-credentials
Input
| Argument Name | Description | Required |
|---|---|---|
| request_id | ID of the Request for which to retrieve the credentials | Required |
Context Output
There is no context output for this command.
Command Example
!beyondtrust-get-credentials request_id=294\
Human Readable Output
The credentials for BeyondTrust request: shelly
6. Update credentials for a managed account
Generates a list of active BeyondTrust requests.
Base Command
beyondtrust-list-release-requests
Configuration parameters
url— Server URL (e.g https://192.168.0.1) (required)credentials— Username (required)key— API Keycredentials_key—insecure— Trust any certificate (not secure)proxy— Use system proxy settingsisFetchCredentials— Fetch credentialssystem_name— System Name (optional for fetch credentials)
Commands (7)
-
beyondtrust-change-credentialsUpdates the credentials for a Managed Account, optionally applying the change to the Managed System.
-
beyondtrust-check-in-credentialsChecks-in/releases a request before it expires.
-
beyondtrust-create-release-requestCreates a new credentials release request.
-
beyondtrust-get-credentialsRetrieves the credentials for an approved and active (not expired) credentials release request.
-
beyondtrust-get-managed-accountsReturns a list of managed accounts that the current user has permissions to request.
-
beyondtrust-get-managed-systemsReturns a list of managed systems.
-
beyondtrust-list-release-requestsGenerates a list of active BeyondTrust requests.
import demistomock as demisto # noqa: F401 from CommonServerPython import * # noqa: F401 """ IMPORTS """ import json import requests import urllib3 # Disable insecure warnings urllib3.disable_warnings() """ GLOBALS/PARAMS """ USERNAME = demisto.params().get("credentials", {}).get("identifier") PASSWORD = demisto.params().get("credentials", {}).get("password") API_KEY = demisto.params().get("credentials_key", {}).get("password") or demisto.params().get("key") if not API_KEY or not (USERNAME and PASSWORD): raise DemistoException("The API Key or username and password must be provided") SYSTEM_NAME = demisto.params().get("system_name") # Remove trailing slash to prevent wrong URL path to service SERVER = ( demisto.params()["url"][:-1] if (demisto.params()["url"] and demisto.params()["url"].endswith("/")) else demisto.params()["url"] ) # Should we use SSL USE_SSL = not demisto.params().get("insecure", False) # Service base URL BASE_URL = SERVER + "/BeyondTrust/api/public/v3" # Headers to be sent in requests HEADERS = { "Content-Type": "application/json", "Accept": "application/json", } SESSION = requests.session() ERR_DICT = { "4031": "User does not have permission.", "4034": "Request is not yet approved.", "4091": "Conflicting request exists. This user or another user has already requested a password for the" " specified account.", } """ HELPER FUNCTIONS """ def http_request(method: str, suffix_url: str, data=None): """ A wrapper for requests lib to send our requests and handle requests and responses better Parameters ---------- method : str HTTP method, e.g. 'GET', 'POST' ... etc. suffix_url : str API endpoint. data: str Data to be sent in a 'POST' request. Returns ------- Response from having made the request. """ url = BASE_URL + suffix_url try: res = SESSION.request( method, url, verify=USE_SSL, data=data, # type: ignore headers=HEADERS, ) except requests.exceptions.SSLError as e: ssl_error = f"Could not connect to BeyondTrust, SSL error: {e}" return return_error(ssl_error) except ( requests.exceptions.ConnectionError, requests.exceptions.Timeout, requests.exceptions.TooManyRedirects, requests.exceptions.RequestException, ) as e: connection_error = f"Could not connect to BeyondTrust: {e}" return return_error(connection_error) # Handle error responses gracefully if res.status_code not in {200, 201, 204}: txt = res.text if txt in ERR_DICT: txt = ERR_DICT[txt] elif res.status_code in ERR_DICT: txt = ERR_DICT[txt] elif res.status_code == 401: txt = "Wrong credentials." return_error(f"Error in API call to BeyondTrust Integration [{res.status_code}] - {txt})") try: return res.json() except ValueError: return None def signin(): """ Starts a session in BeyondTrust """ suffix_url = "/Auth/SignAppin" header = {"Authorization": f"PS-Auth key={API_KEY}; runas={USERNAME}; pwd=[{PASSWORD}];"} SESSION.headers.update(header) http_request("POST", suffix_url) def signout(): """ Ends a session """ suffix_url = "/auth/signout" http_request("POST", suffix_url) """ COMMANDS + REQUESTS FUNCTIONS """ def get_managed_accounts_request(): """ Request for all managed accounts """ suffix_url = "/managedaccounts" response = http_request("GET", suffix_url) return response def get_managed_accounts(): """ Returns a list of Managed Accounts that can be requested by the current user. """ data = [] headers = ["AccountName", "AccountID", "AssetName", "AssetID", "DomainName", "LastChangeDate", "NextChangeDate"] managed_accounts = get_managed_accounts_request() for account in managed_accounts: data.append( { "LastChangeDate": account.get("LastChangeDate"), "NextChangeDate": account.get("NextChangeDate"), "AssetID": account.get("SystemId"), "AssetName": account.get("SystemName"), "DomainName": account.get("DomainName"), "AccountID": account.get("AccountId"), "AccountName": account.get("AccountName"), } ) entry_context = {"BeyondTrust.Account(val.AccountId && val.AccountId === obj.AccountId)": managed_accounts} return_outputs( tableToMarkdown("BeyondTrust Managed Accounts", data, headers, removeNull=True), entry_context, managed_accounts ) def get_managed_systems_request() -> list[dict]: """ Request for all managed systems """ suffix_url = "/managedsystems" response = http_request("GET", suffix_url) return response def get_managed_systems(): """ Returns a list of Managed Systems. """ data = [] managed_systems = get_managed_systems_request() for managed_system in managed_systems: data.append( { "ManagedAssetID": managed_system.get("ManagedSystemID"), "ChangeFrequencyDays": managed_system.get("ChangeFrequencyDays"), "AssetID": managed_system.get("AssetID"), "DatabaseID": managed_system.get("DatabaseID"), "DirectoryID": managed_system.get("DirectoryID"), "AssetName": managed_system.get("SystemName"), "PlatformID": managed_system.get("PlatformID"), "Port": managed_system.get("Port"), } ) entry_context = {"BeyondTrust.System(val.ManagedAssetID === obj.ManagedAssetID)": managed_systems} return_outputs(tableToMarkdown("BeyondTrust Managed Systems", data, removeNull=True), entry_context, managed_systems) def create_release_request(data: str): """ Request for credentials release """ suffix_url = "/requests" response = http_request("POST", suffix_url, data=data) return response def list_release_requests(): """ Returns a list of release requests """ suffix_url = "/requests" release_list = http_request("GET", suffix_url) data = [] headers = [ "AccessType", "AccountID", "AccountName", "AliasID", "ApplicationID", "ApprovedDate", "CanceledDate", "DomainName", "ExpiresDate", "Reason", "RequestID", "RequestReleaseDate", "RequestorName", "Status", "SystemID", "SystemName", ] for release in release_list: data.append( { "AccessType": release.get("AccessType"), "AccountID": release.get("AccountID"), "AccountName": release.get("AccountName"), "AliasID": release.get("AliasID"), "ApplicationID": release.get("ApplicationID"), "ApprovedDate": release.get("ApprovedDate"), "DomainName": release.get("DomainName"), "ExpiresDate": release.get("ExpiresDate"), "Reason": release.get("Reason"), "RequestID": release.get("RequestID"), "RequestReleaseDate": release.get("RequestReleaseDate"), "RequestorName": release.get("RequestorName"), "Status": release.get("Status"), "SystemID": release.get("SystemID"), "SystemName": release.get("SystemName"), } ) entry_context = {"BeyondTrust.Request": createContext(release_list)} return_outputs( tableToMarkdown("Current requests are as follows", data, headers, removeNull=True), entry_context, release_list ) def create_release(): """ Creates a new release request. Retrieves the credentials for an approved and active (not expired) credentials release request. demisto parameter: (string) access_type The type of access requested (View, RDP, SSH). Defualt is "View". demisto parameter: (int) system_id ID of the Managed System to request. demisto parameter: (int) account_id ID of the Managed Account to request. demisto parameter: (int) duration_minutes The request duration (in minutes). demisto parameter: (string) reason The reason for the request. demisto parameter: (int) access_policy_schedule_id The Schedule ID of an Access Policy to use for the request. If omitted, automatically selects the best schedule. demisto parameter: (bool) conflict_option The conflict resolution option to use if an existing request is found for the same user, system, and account ("reuse" or "renew"). """ access_type = demisto.args().get("access_type") system_id = demisto.args().get("system_id") account_id = demisto.args().get("account_id") duration_minutes = demisto.args().get("duration_minutes") reason = demisto.args().get("reason") conflict_option = demisto.args().get("conflict_option") data = {"SystemId": system_id, "AccountId": account_id, "DurationMinutes": duration_minutes} if access_type: data["AccessType"] = access_type if reason: data["Reason"] = reason if conflict_option: data["ConflictOption"] = conflict_option request = create_release_request(str(data)) request_id = str(request) credentials = get_credentials_request(request_id) response = {"RequestID": request_id, "Password": credentials} entry_context = {"BeyondTrust.Request(val.AccountID === obj.AccountID)": createContext(response)} return_outputs(tableToMarkdown("The new release was created successfully.", response), entry_context, response) def get_credentials_request(request_id: str): """ Request for specific credentials """ suffix_url = "/credentials/" + request_id response = http_request("GET", suffix_url) return response def get_credentials(): """ Retrieves the credentials for an approved and active (not expired) credentials release request. demisto parameter: (int) request_id ID of the Request for which to retrieve the credentials """ request_id = demisto.args().get("request_id") request = str(request_id) credentials = get_credentials_request(request) response = {"Credentials": credentials} entry_context = {"BeyondTrust.Request": createContext(response)} return_outputs(tableToMarkdown("Passwordsafe Credentials", response), entry_context, response) def check_in_credentials_request(request_id: str, data: dict): """ Request for check-in credentials """ suffix_url = f"/Requests/{request_id}/Checkin" response = http_request("PUT", suffix_url, data=json.dumps(data)) return response def check_in_credentials(): """ Checks-in/releases a request before it has expired. demisto parameter: (int) request_id ID of the request to release. demisto parameter: (string) reason A reason or comment why the request is being released. """ request_id = demisto.args().get("request_id") reason = str(demisto.args().get("reason")) data = {"Reason": reason if reason else ""} check_in_credentials_request(request_id, data) demisto.results("The release was successfully checked-in/released") def change_credentials_request(account_id: str, data: dict): """ Request to change credentials """ suffix_url = f"/ManagedAccounts/{account_id}/Credentials" response = http_request("PUT", suffix_url, data=json.dumps(data)) return response def change_credentials(): """ Updates the credentials for a Managed Account, optionally applying the change to the Managed System. demisto parameter: (int) account_id ID of the account for which to set the credentials. demisto parameter: (string) password The new password to set. If not given, generates a new, random password. demisto parameter: (string) public_key The new public key to set on the host. This is required if PrivateKey is given and updateSystem=true. demisto parameter: (string) private_key The private key to set (provide Passphrase if encrypted). demisto parameter: (string) pass_phrase The passphrase to use for an encrypted private key. demisto parameter: (bool) update_system Whether to update the credentials on the referenced system. """ account_id = demisto.args().get("account_id") password = demisto.args().get("password") public_key = demisto.args().get("public_key") private_key = demisto.args().get("private_key") pass_phrase = demisto.args().get("pass_phrase") update_system = demisto.args().get("update_system") data = {"AccountId": account_id} if password: data["Password"] = password if private_key: if public_key and update_system is True: data["PrivateKey"] = private_key data["PublicKey"] = public_key else: return_error("Missing public key") if pass_phrase: data["Passphrase"] = pass_phrase change_credentials_request(account_id, data) demisto.results("The password has been changed") def fetch_credentials(): """ Returns: Account's credentials """ credentials = [] identifier = demisto.args().get("identifier") duration_minutes = 1 account_info = get_managed_accounts_request() for account in account_info: account_name = account.get("AccountName") system_name = account.get("SystemName") if SYSTEM_NAME and system_name != SYSTEM_NAME: continue item = { "SystemId": account.get("SystemId"), "AccountId": account.get("AccountId"), "DurationMinutes": duration_minutes, "ConflictOption": "reuse", } release_id = create_release_request(str(item)) password = get_credentials_request(str(release_id)) credentials.append({"user": account_name, "password": password, "name": system_name + "_" + account_name}) if identifier: credentials = list(filter(lambda c: c.get("name", "") == identifier, credentials)) demisto.debug(f"Amount of credentials for identifier: {identifier} is {len(credentials)}") demisto.credentials(credentials) """ COMMANDS MANAGER / SWITCH PANEL """ LOG(f"Command being called is {demisto.command()}") try: handle_proxy() signin() if demisto.command() == "test-module": # This is the call made when pressing the integration test button. get_managed_accounts_request() demisto.results("ok") elif demisto.command() == "beyondtrust-get-managed-accounts": get_managed_accounts() elif demisto.command() == "beyondtrust-get-managed-systems": get_managed_systems() elif demisto.command() == "beyondtrust-create-release-request": create_release() elif demisto.command() == "beyondtrust-get-credentials": get_credentials() elif demisto.command() == "beyondtrust-check-in-credentials": check_in_credentials() elif demisto.command() == "beyondtrust-change-credentials": change_credentials() elif demisto.command() == "beyondtrust-list-release-requests": list_release_requests() elif demisto.command() == "fetch-credentials": fetch_credentials() # Log exceptions except Exception as e: LOG(str(e)) LOG.print_log() raise finally: signout()