def init(): """Initializes the backend of PyBox. Checks if a native callback is set up and creates management objects. """ global HOOK_MANAGER, MODULES logging.debug("pybox.init - Starting script inside of process.") logging.debug("pybox.init - DLL CallbackAddr: " + hex(CB_ADDR)) gen_cb_installed = emb.dllAttachPythonCallback(generic_callback_handler) if gen_cb_installed == 0: logging.debug("pybox.init - Python Callback attached.") else: logging.error("pybox.init - Failed: Attach python callback, error "\ "code: " + str(gen_cb_installed)) HOOK_MANAGER = hooking.PyHookManager() MODULES = emodules.ExecModulesInfo() emb.setCleanupFunction(cleanup) logging.debug("pybox.init - exiting.")
import pybox import time from pybox import proctrack def register_hooks(): """Register the required hooks""" logging.debug("Hooking") def cleaner(): logging.debug("cleaning up...") if __name__ == "__main__": logging.basicConfig(format = "%(asctime)s - %(levelname)s - %(message)s", level = logging.INFO) pybox.init() import emb emb.setCleanupFunction(cleaner) logging.info("Start") register_hooks() proctrack.init() logging.info("Let's get ready to rumble") time.sleep(2) logging.info("Done")
def set_cleanup_function(cleanup_function): """Sets the cleanup function, which is called when PyBox terminates. @param cleanup_function: The callback to execute on cleanup @type cleanup_function: function """ emb.setCleanupFunction(cleanup_function)
from pybox import proctrack def register_hooks(): """Register the required hooks""" logging.debug("Hooking") def cleaner(): logging.debug("cleaning up...") if __name__ == "__main__": logging.basicConfig(format="%(asctime)s - %(levelname)s - %(message)s", level=logging.INFO) pybox.init() import emb emb.setCleanupFunction(cleaner) logging.info("Start") register_hooks() proctrack.init() logging.info("Let's get ready to rumble") time.sleep(2) logging.info("Done")