enterprise module

binaryninja.enterprise.LicenseCheckout([...])

class LicenseCheckout(duration=900, _cache=True, release=True)[source]

Bases: object

Helper class for scripts to make use of a license checkout in a scope.

Parameters:
  • duration – Duration between refreshes

  • _cache – Deprecated but left in for compatibility

  • release – If the license should be released at the end of scope. If False, you can either manually release it later or it will expire after duration.

Example:
>>> enterprise.connect()
>>> enterprise.authenticate_with_credentials("username", "password")
>>> with enterprise.LicenseCheckout():
...     # Do some operation
...     with load("/bin/ls") as bv: # e.g.
...             print(hex(bv.start))
# License is released at end of scope
acquire()[source]
release()[source]
acquire_license(duration, _cache=True)[source]

Function deprecated. Use update_license instead.

Check out and activate a license from the Enterprise Server.

Note

You must authenticate with the Enterprise Server before calling this.

Parameters:
  • duration (int) – Desired length of license checkout, in seconds.

  • _cache (bool) – Deprecated but left in for compatibility

Deprecated since version 3.4.4137: Use .update_license instead.

authenticate_with_credentials(username: str, password: str, remember: bool = True)[source]

Authenticate to the Enterprise Server with username/password credentials.

Parameters:
  • username (str) – Username to use.

  • password (str) – Password to use.

  • remember (bool) – Remember token in keychain

authenticate_with_method(method: str, remember: bool = True)[source]

Authenticate to the Enterprise Server with a non-password method. Note that many of these will open a URL for a browser-based login prompt, which may not be usable on headless installations. See authentication_methods for a list of accepted methods.

Parameters:
  • method (str) – Name of method to use.

  • remember (bool) – Remember token in keychain

authentication_methods() List[Tuple[str, str]][source]

Get a list of authentication methods accepted by the Enterprise Server.

Returns:

List of (<method name>, <method display name>) tuples

Return type:

List[Tuple[str, str]]

cancel_authentication()[source]

Cancel a call to authenticate_with_credentials or authenticate_with_method. Note those functions are blocking, so this must be called on a separate thread.

connect()[source]

Connect to the Enterprise Server.

deauthenticate()[source]

Deauthenticate from the Enterprise server, clearing any cached credentials.

initialize()[source]

Initialize the Enterprise Client

is_authenticated() bool[source]

Determine if you have authenticated to the Enterprise Server.

Returns:

True if you are authenticated

Return type:

bool

is_connected() bool[source]

Determine if the Enterprise Server is currently connected.

Returns:

True if connected

Return type:

bool

is_floating_license() bool[source]

Determine if a floating license is currently active

Returns:

True if a floating license is active

Return type:

bool

is_initialized() bool[source]

Determine if the Enterprise Client has been initialized yet.

Returns:

True if initialize has been called

Return type:

bool

is_license_still_activated() bool[source]

Determine if your current license checkout is still valid.

Returns:

True if your current checkout is still valid.

Return type:

bool

last_error() str[source]

Get a text representation the last error encountered by the Enterprise Client

Returns:

Last error message, or empty string if there is none.

Return type:

str

license_duration() int[source]

Get the duration of the current license checkout.

Returns:

Duration, in seconds, of the total time of the current checkout.

Return type:

int

license_expiration_time() int[source]

Get the expiry time of the current license checkout.

Returns:

Expiry time as a Unix epoch, or 0 if no license is checked out.

Return type:

int

release_license()[source]

Release the currently checked out license back to the Enterprise Server.

Note

You must authenticate with the Enterprise Server before calling this.

Note

This will deactivate the Binary Ninja Enterprise client. You must call acquire_license again to continue using Binary Ninja Enterprise in the current process.

reservation_time_limit() int[source]

Get the maximum checkout duration allowed by the Enterprise Server.

Note

You must authenticate with the Enterprise Server before calling this.

Returns:

Duration, in seconds, of the maximum time you are allowed to checkout a license.

Return type:

int

server_build_id() str[source]

Get the build id string of the server

Returns:

Build id of the server

Return type:

str

server_id() str[source]

Get the internal id of the server

Returns:

Id of the server

Return type:

str

server_name() str[source]

Get the display name of the server

Returns:

Display name of the server

Return type:

str

server_url() str[source]

Get the url of the Enterprise Server.

Returns:

The current url

Return type:

str

server_version() int[source]

Get the version number of the server

Returns:

Version of the server

Return type:

int

set_server_url(url: str)[source]

Set the url of the Enterprise Server.

Note

This will raise an Exception if the server is already initialized

Parameters:

url (str) – New Enterprise Server url

token() str | None[source]

Get the token of the currently authenticated user to the Enterprise Server.

Returns:

Token, if authenticated. None, otherwise.

Return type:

str | None

update_license(duration, _cache=True)[source]

Acquire or refresh a floating license from the Enterprise server.

Note

You must authenticate with the Enterprise server before calling this.

Parameters:
  • duration (int) – Desired length of license checkout, in seconds.

  • _cache (bool) – Deprecated but left in for compatibility

username() str | None[source]

Get the username of the currently authenticated user to the Enterprise Server.

Returns:

Username, if authenticated. None, otherwise.

Return type:

str | None