Esempio n. 1
0
def _init_plugins():
    global _enable_default_log
    global _plugin_init

    if not core_ui_enabled() and core.BNGetProduct(
    ) == "Binary Ninja Enterprise Client":
        # Enterprise client needs to checkout a license reservation or else BNInitPlugins will fail
        if not enterprise.is_license_still_activated():
            try:
                enterprise.authenticate_with_method("Keychain")
            except RuntimeError:
                pass
        if not core.BNIsLicenseValidated(
        ) or not enterprise.is_license_still_activated():
            raise RuntimeError(
                "To use Binary Ninja Enterprise from a headless python script, you must check out a license first.\n"
                "You can either check out a license for an extended time with the UI, or use the binaryninja.enterprise module."
            )

    if not _plugin_init:
        # The first call to BNInitCorePlugins returns True for successful initialization and True in this context indicates headless operation.
        # The result is pulled from BNInitPlugins as that now wraps BNInitCorePlugins.
        is_headless_init_once = core.BNInitPlugins(
            not os.environ.get('BN_DISABLE_USER_PLUGINS'))
        min_level = Settings().get_string("python.log.minLevel")
        if _enable_default_log and is_headless_init_once and min_level in LogLevel.__members__ and not core_ui_enabled(
        ) and sys.stderr.isatty():
            log_to_stderr(LogLevel[min_level])
        core.BNInitRepoPlugins()
    if core.BNIsLicenseValidated():
        _plugin_init = True
    else:
        raise RuntimeError(
            "License is not valid. Please supply a valid license.")
Esempio n. 2
0

_destruct_callbacks = _DestructionCallbackHandler()

bundled_plugin_path = core.BNGetBundledPluginDirectory()
user_plugin_path = core.BNGetUserPluginDirectory()

core_version = core.BNGetVersionString()
'''Core version'''

core_build_id = core.BNGetBuildId()
'''Build ID'''

core_serial = core.BNGetSerialNumber()
'''Serial Number'''

core_expires = gmtime(core.BNGetLicenseExpirationTime())
'''License Expiration'''

core_product = core.BNGetProduct()
'''Product string from the license file'''

core_product_type = core.BNGetProductType()
'''Product type from the license file'''

core_license_count = core.BNGetLicenseCount()
'''License count from the license file'''

core_ui_enabled = core.BNIsUIEnabled()
'''Indicates that a UI exists and the UI has invoked BNInitUI'''
Esempio n. 3
0
def core_product():
	'''Product string from the license file'''
	return core.BNGetProduct()
Esempio n. 4
0
def core_product() -> Optional[str]:
    '''Product string from the license file'''
    return core.BNGetProduct()
Esempio n. 5
0
from .variable import *
from .websocketprovider import *
from .workflow import *
from .commonil import *
from .database import *
from .secretsprovider import *
from .typeparser import *
from .typeprinter import *
# We import each of these by name to prevent conflicts between
# log.py and the function 'log' which we don't import below
from .log import (redirect_output_to_log, is_output_redirected_to_log,
                  log_debug, log_info, log_warn, log_error, log_alert,
                  log_to_stdout, log_to_stderr, log_to_file, close_logs)
from .log import log as log_at_level
# Only load Enterprise Client support on Enterprise builds
if core.BNGetProduct() == "Binary Ninja Enterprise Client":
    from .enterprise import *


def shutdown():
    """
	``shutdown`` cleanly shuts down the core, stopping all workers and closing all log files.
	"""
    core.BNShutdown()


atexit.register(shutdown)


def get_unique_identifier():
    return core.BNGetUniqueIdentifierString()