Example #1
0
def main(unused_args):
    # Allow per platform configuration.
    config.CONFIG.AddContext(
        contexts.CLIENT_CONTEXT,
        "Context applied when we run the client process.")

    client_startup.ClientInit()

    if flags.FLAGS.install:
        installer.RunInstaller()

    errors = config.CONFIG.Validate(["Client", "CA", "Logging"])

    if errors and list(iterkeys(errors.keys)) != ["Client.private_key"]:
        raise config_lib.ConfigFormatError(errors)

    if config.CONFIG["Client.fleetspeak_enabled"]:
        raise ValueError(
            "This is not a Fleetspeak client, yet 'Client.fleetspeak_enabled' is "
            "set to 'True'.")

    enrollment_necessary = not config.CONFIG.Get("Client.private_key")
    # Instantiating the client will create a private_key so we need to use a flag.
    client = comms.GRRHTTPClient(ca_cert=config.CONFIG["CA.certificate"],
                                 private_key=config.CONFIG.Get(
                                     "Client.private_key", default=None))

    if enrollment_necessary:
        logging.info("No private key found, starting enrollment.")
        client.InitiateEnrolment()

    if flags.FLAGS.break_on_start:
        pdb.set_trace()
    else:
        client.Run()
Example #2
0
def main(unused_args):
    client_plugins.RegisterPlugins()

    if flags.FLAGS.remote_debugging_port:
        _start_remote_debugging(flags.FLAGS.remote_debugging_port)
    elif flags.FLAGS.break_on_start:
        pdb.set_trace()

    if (flags.FLAGS.unprivileged_server_pipe_input != -1
            and flags.FLAGS.unprivileged_server_pipe_output != -1
            and flags.FLAGS.unprivileged_server_interface):
        communication.Main(
            communication.Channel.FromSerialized(
                pipe_input=flags.FLAGS.unprivileged_server_pipe_input,
                pipe_output=flags.FLAGS.unprivileged_server_pipe_output),
            interface_registry.GetConnectionHandlerForInterfaceString(
                flags.FLAGS.unprivileged_server_interface),
            flags.FLAGS.unprivileged_user, flags.FLAGS.unprivileged_group)
        return

    # Allow per platform configuration.
    config.CONFIG.AddContext(
        contexts.CLIENT_CONTEXT,
        "Context applied when we run the client process.")

    client_startup.ClientInit()

    if flags.FLAGS.install:
        installer.RunInstaller()
        sys.exit(0)

    if config.CONFIG["Client.fleetspeak_enabled"]:
        fleetspeak_client.GRRFleetspeakClient().Run()
        return

    errors = config.CONFIG.Validate(["Client", "CA", "Logging"])

    if errors and list(errors.keys()) != ["Client.private_key"]:
        raise config_lib.ConfigFormatError(errors)

    if config.CONFIG["Client.fleetspeak_enabled"]:
        raise ValueError(
            "This is not a Fleetspeak client, yet 'Client.fleetspeak_enabled' is "
            "set to 'True'.")

    enrollment_necessary = not config.CONFIG.Get("Client.private_key")
    # Instantiating the client will create a private_key so we need to use a flag.
    client = comms.GRRHTTPClient(ca_cert=config.CONFIG["CA.certificate"],
                                 private_key=config.CONFIG.Get(
                                     "Client.private_key", default=None))

    if enrollment_necessary:
        logging.info("No private key found, starting enrollment.")
        client.InitiateEnrolment()

    client.Run()
Example #3
0
def main(unused_args):
    client_plugins.RegisterPlugins()

    if flags.FLAGS.remote_debugging_port:
        _start_remote_debugging(flags.FLAGS.remote_debugging_port)
    elif flags.FLAGS.break_on_start:
        pdb.set_trace()

    # Allow per platform configuration.
    config.CONFIG.AddContext(
        contexts.CLIENT_CONTEXT,
        "Context applied when we run the client process.")

    client_startup.ClientInit()

    if flags.FLAGS.install:
        installer.RunInstaller()
        sys.exit(0)

    is_pyinstaller_binary = getattr(sys, "frozen", False)
    if is_pyinstaller_binary and platform.system() == "Windows":
        # Since `Client.install_path` is shared with the Sandbox, Sandbox
        # initialization makes only sense if we run from a proper installation.
        # This is the case if this is a PyInstaller binary.
        sandbox.InitSandbox(
            "{}_{}".format(config.CONFIG["Client.name"],
                           config.CONFIG["Source.version_string"]),
            [config.CONFIG["Client.install_path"]])

    if config.CONFIG["Client.fleetspeak_enabled"]:
        fleetspeak_client.GRRFleetspeakClient().Run()
        return

    errors = config.CONFIG.Validate(["Client", "CA", "Logging"])

    if errors and list(errors.keys()) != ["Client.private_key"]:
        raise config_lib.ConfigFormatError(errors)

    if config.CONFIG["Client.fleetspeak_enabled"]:
        raise ValueError(
            "This is not a Fleetspeak client, yet 'Client.fleetspeak_enabled' is "
            "set to 'True'.")

    enrollment_necessary = not config.CONFIG.Get("Client.private_key")
    # Instantiating the client will create a private_key so we need to use a flag.
    client = comms.GRRHTTPClient(ca_cert=config.CONFIG["CA.certificate"],
                                 private_key=config.CONFIG.Get(
                                     "Client.private_key", default=None))

    if enrollment_necessary:
        logging.info("No private key found, starting enrollment.")
        client.InitiateEnrolment()

    client.Run()
Example #4
0
def main(unused_args):
    config.CONFIG.AddContext(
        contexts.CLIENT_CONTEXT,
        "Context applied when we run the client process.")

    client_startup.ClientInit()

    if flags.FLAGS.install:
        installer.RunInstaller()

    if flags.FLAGS.break_on_start:
        pdb.set_trace()
    else:
        fleetspeak_client.GRRFleetspeakClient().Run()
Example #5
0
def main(argv):
    del argv  # Unused.
    config.CONFIG.AddContext(contexts.POOL_CLIENT_CONTEXT,
                             "Context applied when we run the pool client.")

    client_startup.ClientInit()

    config.CONFIG.SetWriteBack("/dev/null")

    CheckLocation()

    # Let the OS handler also handle sleuthkit requests since sleuthkit is not
    # thread safe.
    vfs.VFS_HANDLERS[_UseOSForTSKFile.supported_pathtype] = _UseOSForTSKFile

    CreateClientPool(flags.FLAGS.nrclients)
Example #6
0
def main(unused_args):
  if flags.FLAGS.remote_debugging_port:
    _start_remote_debugging(flags.FLAGS.remote_debugging_port)
  elif flags.FLAGS.break_on_start:
    pdb.set_trace()

  if flags.FLAGS.filesystem_server_socket != -1:
    communication.Main(flags.FLAGS.filesystem_server_socket,
                       server_lib.Dispatch)
    return

  # Allow per platform configuration.
  config.CONFIG.AddContext(contexts.CLIENT_CONTEXT,
                           "Context applied when we run the client process.")

  client_startup.ClientInit()

  if flags.FLAGS.install:
    installer.RunInstaller()
    sys.exit(0)

  if config.CONFIG["Client.fleetspeak_enabled"]:
    fleetspeak_client.GRRFleetspeakClient().Run()
    return

  errors = config.CONFIG.Validate(["Client", "CA", "Logging"])

  if errors and list(errors.keys()) != ["Client.private_key"]:
    raise config_lib.ConfigFormatError(errors)

  if config.CONFIG["Client.fleetspeak_enabled"]:
    raise ValueError(
        "This is not a Fleetspeak client, yet 'Client.fleetspeak_enabled' is "
        "set to 'True'.")

  enrollment_necessary = not config.CONFIG.Get("Client.private_key")
  # Instantiating the client will create a private_key so we need to use a flag.
  client = comms.GRRHTTPClient(
      ca_cert=config.CONFIG["CA.certificate"],
      private_key=config.CONFIG.Get("Client.private_key", default=None))

  if enrollment_necessary:
    logging.info("No private key found, starting enrollment.")
    client.InitiateEnrolment()

  client.Run()
Example #7
0
def main(argv):
  del argv  # Unused.
  config.CONFIG.AddContext(contexts.POOL_CLIENT_CONTEXT,
                           "Context applied when we run the pool client.")

  client_startup.ClientInit()

  config.CONFIG.SetWriteBack("/dev/null")

  CheckLocation()

  # Let the OS handler also handle sleuthkit requests since sleuthkit is not
  # thread safe.
  tsk = rdf_paths.PathSpec.PathType.TSK
  os = rdf_paths.PathSpec.PathType.OS
  vfs.VFS_HANDLERS[tsk] = vfs.VFS_HANDLERS[os]

  CreateClientPool(flags.FLAGS.nrclients)
Example #8
0
def main(unused_args):
  config.CONFIG.AddContext(contexts.CLIENT_CONTEXT,
                           "Context applied when we run the client process.")

  client_startup.ClientInit()

  if flags.FLAGS.install:
    installer.RunInstaller()

  if not config.CONFIG["Client.fleetspeak_enabled"]:
    raise ValueError(
        "This is a Fleetspeak client, yet 'Client.fleetspeak_enabled' is "
        "'False'.")

  if flags.FLAGS.break_on_start:
    pdb.set_trace()
  else:
    fleetspeak_client.GRRFleetspeakClient().Run()
Example #9
0
def main(args):
    """Launch the appropriate builder."""

    grr_config.CONFIG.AddContext(contexts.CLIENT_BUILD_CONTEXT)

    if args.subparser_name == "generate_client_config":
        # We don't need a full init to just build a config.
        GetClientConfig(args.client_config_output)
        return

    # We deliberately use args.context because client_startup.py pollutes
    # grr_config.CONFIG.context with the running system context.
    context = FLAGS.context
    context.append(contexts.CLIENT_BUILD_CONTEXT)
    client_startup.ClientInit()

    # Use basic console output logging so we can see what is happening.
    logger = logging.getLogger()
    handler = logging.StreamHandler()
    handler.setLevel(logging.INFO)
    logger.handlers = [handler]

    if args.subparser_name == "build":
        if grr_config.CONFIG.Get("ClientBuilder.fleetspeak_enabled"):
            if "Target:Darwin" in context:
                if not args.fleetspeak_service_config:
                    raise RuntimeError(
                        "--fleetspeak_service_config must be provided.")
                if not grr_config.CONFIG.Get("ClientBuilder.install_dir"):
                    raise RuntimeError(
                        "ClientBuilder.install_dir must be set.")
                if not grr_config.CONFIG.Get(
                        "ClientBuilder.fleetspeak_plist_path"):
                    raise RuntimeError(
                        "ClientBuilder.fleetspeak_plist_path must be set.")
            grr_config.CONFIG.Set("ClientBuilder.client_path",
                                  "grr_response_client.grr_fs_client")
        TemplateBuilder().BuildTemplate(
            context=context,
            output=args.output,
            fleetspeak_service_config=args.fleetspeak_service_config)
    elif args.subparser_name == "repack":
        if args.debug_build:
            context.append("DebugClientBuild Context")
        result_path = repacking.TemplateRepacker().RepackTemplate(
            args.template,
            args.output_dir,
            context=context,
            sign=args.sign,
            signed_template=args.signed_template)

        if not result_path:
            raise ErrorDuringRepacking(" ".join(sys.argv[:]))
    elif args.subparser_name == "repack_multiple":

        # Resolve globs manually on Windows.
        templates = []
        for template in args.templates:
            if "*" in template:
                templates.extend(glob.glob(template))
            else:
                # This could go through glob but then we'd swallow errors for
                # non existing files.
                templates.append(template)

        repack_configs = []
        for repack_config in args.repack_configs:
            if "*" in repack_config:
                repack_configs.extend(glob.glob(repack_config))
            else:
                # This could go through glob but then we'd swallow errors for
                # non existing files.
                repack_configs.append(repack_config)

        MultiTemplateRepacker().RepackTemplates(
            repack_configs,
            templates,
            args.output_dir,
            config=FLAGS.config,
            sign=args.sign,
            signed_template=args.signed_template)
    elif args.subparser_name == "sign_template":
        repacking.TemplateRepacker().SignTemplate(args.template,
                                                  args.output_file,
                                                  context=context)
        if not os.path.exists(args.output_file):
            raise RuntimeError("Signing failed: output not written")