def run_server(
    server_host=bridge.DEFAULT_HOST,
    server_port=DEFAULT_SERVER_PORT,
    response_timeout=bridge.DEFAULT_RESPONSE_TIMEOUT,
    background=True,
):
    """ Run a jfx_bridge_ida server (forever)
        server_host - what address the server should listen on
        server_port - what port the server should listen on
        response_timeout - default timeout in seconds before a response is treated as "failed"
        background - false to run the server in this thread (will lock up GUI), true for a new thread
    """
    server = bridge.BridgeServer(
        server_host=server_host,
        server_port=server_port,
        loglevel=logging.INFO,
        response_timeout=response_timeout,
        local_call_hook=hook_local_call,
        local_eval_hook=hook_local_eval,
        local_exec_hook=hook_local_exec,
    )

    if background:
        server.start()
        print(
            "Server launching in background - will continue to run after launch script finishes...\n"
        )
    else:
        server.run()
def run_server(server_host=bridge.DEFAULT_HOST,
               server_port=bridge.DEFAULT_SERVER_PORT,
               response_timeout=bridge.DEFAULT_RESPONSE_TIMEOUT):
    """ Run a jfx_bridge server (forever)
        server_host - what address the server should listen on
        server_port - what port the server should listen on
    """
    bridge.BridgeServer(server_host=server_host,
                        server_port=server_port,
                        loglevel=logging.INFO,
                        response_timeout=response_timeout).run()
Beispiel #3
0
def run_script_across_bridge(script_file, ctx, python="python", argstring=""):
    """ Spin up a jfx_bridge_jeb_server and spawn the script in external python to connect back to it.
    
        Need to pass in the JEB ctx from wherever's calling this script, so the other end can access it

        The called script needs to handle the --connect_to_host and --connect_to_port command-line arguments and use them to start
        a jfx_bridge_jeb client to talk back to the server.

        Specify python to control what the script gets run with. Defaults to whatever python is in the shell - if changing, specify a path
        or name the shell can find.
        Specify argstring to pass further arguments to the script when it starts up.
    """
    global CTX

    CTX = ctx

    import_jeb_packages()

    # spawn a jfx_bridge_jeb server - use server port 0 to pick a random port
    server = bridge.BridgeServer(server_host="127.0.0.1",
                                 server_port=0,
                                 loglevel=logging.INFO)
    # start it running in a background thread
    server.start()

    try:
        # work out where we're running the server
        server_host, server_port = server.get_server_info()

        print("Running " + script_file)

        # spawn an external python process to run against it
        try:
            output = subprocess.check_output(
                "{python} {script} --connect_to_host={host} --connect_to_port={port} {argstring}"
                .format(
                    python=python,
                    script=script_file,
                    host=server_host,
                    port=server_port,
                    argstring=argstring,
                ),
                stderr=subprocess.STDOUT,
                shell=True,
            )
            print(output)
        except subprocess.CalledProcessError as exc:
            print("Failed ({}):{}".format(exc.returncode, exc.output))

        print(script_file + " completed")

    finally:
        # when we're done with the script, shut down the server
        server.shutdown()
def run_script_across_bridge(script_file, python="python", argstring=""):
    """ Spin up a jfx_bridge_ida_Server and spawn the script in external python to connect back to it. Useful in scripts being triggered from
        inside an older IDA that's stuck in python2 or 32-bit python.

        The called script needs to handle the --connect_to_host and --connect_to_port command-line arguments and use them to start
        a jfx_bridge_ida client to talk back to the server.

        Specify python to control what the script gets run with. Defaults to whatever python is in the shell - if changing, specify a path
        or name the shell can find.
        Specify argstring to pass further arguments to the script when it starts up.
    """

    # spawn a jfx_bridge_ida server - use server port 0 to pick a random port
    server = bridge.BridgeServer(
        server_host="127.0.0.1",
        server_port=0,
        loglevel=logging.INFO,
        local_call_hook=hook_local_call,
        local_eval_hook=hook_local_eval,
    )
    # start it running in a background thread
    server.start()

    try:
        # work out where we're running the server
        server_host, server_port = server.get_server_info()

        print("Running " + script_file)

        # spawn an external python process to run against it
        try:
            output = subprocess.check_output(
                "{python} {script} --connect_to_host={host} --connect_to_port={port} {argstring}"
                .format(
                    python=python,
                    script=script_file,
                    host=server_host,
                    port=server_port,
                    argstring=argstring,
                ),
                stderr=subprocess.STDOUT,
                shell=True,
            )
            print(output)
        except subprocess.CalledProcessError as exc:
            print("Failed ({}):{}".format(exc.returncode, exc.output))

        print(script_file + " completed")

    finally:
        # when we're done with the script, shut down the server
        server.shutdown()
Beispiel #5
0
def run_server(
    server_host=bridge.DEFAULT_HOST,
    server_port=DEFAULT_SERVER_PORT,
    response_timeout=bridge.DEFAULT_RESPONSE_TIMEOUT,
):
    """ Run a jfx_bridge_jeb server (forever, or until shutdown by remote client)
        server_host - what address the server should listen on
        server_port - what port the server should listen on
        response_timeout - default timeout in seconds before a response is treated as "failed"
    """
    bridge.BridgeServer(
        server_host=server_host,
        server_port=server_port,
        loglevel=logging.INFO,
        response_timeout=response_timeout,
    ).run()
    def run_server(server_host=bridge.DEFAULT_HOST,
                   server_port=DEFAULT_SERVER_PORT,
                   response_timeout=bridge.DEFAULT_RESPONSE_TIMEOUT,
                   background=True):
        """ Run a ghidra_bridge_server (forever)
            server_host - what address the server should listen on
            server_port - what port the server should listen on
            response_timeout - default timeout in seconds before a response is treated as "failed"
            background - false to run the server in this thread (script popup will stay), true for a new thread (script popup disappears)
        """
        server = bridge.BridgeServer(server_host=server_host,
                                     server_port=server_port,
                                     loglevel=logging.INFO,
                                     response_timeout=response_timeout)

        if background:
            server.start()
            server.logger.info(
                "Server launching in background - will continue to run after launch script finishes..."
            )
        else:
            server.run()