Exemplo 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.")
Exemplo n.º 2
0
def _init_plugins():
	global _plugin_init
	if not _plugin_init:
		_plugin_init = True
		core.BNInitCorePlugins()
		core.BNInitUserPlugins()
		core.BNInitRepoPlugins()
	if not core.BNIsLicenseValidated():
		raise RuntimeError("License is not valid. Please supply a valid license.")
Exemplo n.º 3
0
def _init_plugins():
	global _plugin_init
	if not _plugin_init:
		core.BNInitCorePlugins()
		if not os.environ.get('BN_DISABLE_USER_PLUGINS'):
			core.BNInitUserPlugins()
		core.BNInitRepoPlugins()
	if core.BNIsLicenseValidated():
		_plugin_init = True
	else:
		raise RuntimeError("License is not valid. Please supply a valid license.")
Exemplo n.º 4
0
def _init_plugins():
	global _enable_default_log
	global _plugin_init
	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.")