示例#1
0
文件: data_server.py 项目: biasys/grr
from grr.lib.rdfvalues import data_server as rdf_data_server
from grr.lib.rdfvalues import data_store as rdf_data_store

from grr.server.data_server import auth
from grr.server.data_server import constants
from grr.server.data_server import errors
from grr.server.data_server import master
from grr.server.data_server import rebalance
from grr.server.data_server import store
from grr.server.data_server import utils as sutils

flags.DEFINE_integer("port", None, "Specify the data server port.")

flags.DEFINE_string("path", None, "Specify the data store path.")

flags.DEFINE_bool("master", False, "Mark this data server as the master.")


class DataServerHandler(BaseHTTPRequestHandler, object):
  """Handler for HTTP requests to the data server."""

  # Data store service.
  SERVICE = None
  # MASTER is set if this data server is also running as master.
  MASTER = None
  # Set if the server is not the master.
  DATA_SERVER = None
  # Mapping information sent/created by the master.
  MAPPING = None
  CMDTABLE = None
  # Nonce store used for authentication.
示例#2
0
import abc
import atexit
import sys
import time

import logging

from grr.lib import access_control
from grr.lib import config_lib
from grr.lib import flags
from grr.lib import registry
from grr.lib import stats
from grr.lib import utils

flags.DEFINE_bool("list_storage", False,
                  "List all storage subsystems present.")

# A global data store handle
DB = None

# There are stub methods that don't return/yield as indicated by the docstring.
# pylint: disable=g-doc-return-or-yield


class Error(stats.CountingExceptionMixin, Exception):
    """Base class for all exceptions in this module."""
    pass


class TimeoutError(Exception):
    """Raised when an access times out."""
示例#3
0
文件: console.py 项目: hanul93/grr
flags.DEFINE_string("reason", None,
                    "Create a default token with this access reason ")

flags.DEFINE_string(
    "code_to_execute", None,
    "If present, no console is started but the code given in "
    "the flag is run instead (comparable to the -c option of "
    "IPython).")

flags.DEFINE_string(
    "command_file", None,
    "If present, no console is started but the code given in "
    "command file is supplied as input instead.")

flags.DEFINE_bool(
    "exit_on_complete", True,
    "If set to False and command_file or code_to_execute is "
    "set we keep the console alive after the code completes.")

flags.DEFINE_version(config_server.VERSION["packageversion"])


def Lister(arg):
    for x in arg:
        print x


def GetChildrenList(urn, token=None):
    return list(aff4.FACTORY.Open(urn, token=token).ListChildren())


def main(argv):
示例#4
0
    # pylint: disable=g-import-not-at-top
    import fuse
    # pylint: enable=g-import-not-at-top
except (EnvironmentError, ImportError):
    # We check for ImportErrors and EnvironmentErrors since submit checks throw an
    # EnvironmentError when fuse isn't installed.
    fuse = None

flags.DEFINE_string("aff4path", "/",
                    "Path in AFF4 to use as the root of the filesystem.")

flags.DEFINE_string("mountpoint", None,
                    "Path to point at which the system should be mounted.")

flags.DEFINE_bool(
    "background", False,
    "Whether or not to run the filesystem in the background,"
    " not viewing debug information.")

flags.DEFINE_float("timeout", 30,
                   "How long to poll a flow for before giving up.")

flags.DEFINE_integer(
    "max_age_before_refresh", 60 * 5,
    "Measured in seconds. Do a client-side update if it's"
    " been this long since we last did one.")

flags.DEFINE_bool(
    "ignore_cache", False, "Disables cache completely. Takes priority over"
    " refresh_policy.")

flags.DEFINE_enum("refresh_policy",
示例#5
0
from grr.client import comms
from grr.client import vfs
from grr.lib import client_startup
from grr.lib import config_lib
from grr.lib import flags
from grr.lib.rdfvalues import crypto as rdf_crypto
from grr.lib.rdfvalues import paths as rdf_paths

flags.DEFINE_integer("nrclients", 1, "Number of clients to start")

flags.DEFINE_string(
    "cert_file", "", "Path to a file that stores all certificates for"
    "the client pool.")

flags.DEFINE_bool(
    "enroll_only", False,
    "If specified, the script will enroll all clients and exit.")


class PoolGRRClient(threading.Thread):
    """A GRR client for running in pool mode."""
    def __init__(self, ca_cert=None, private_key=None):
        """Constructor."""
        super(PoolGRRClient, self).__init__()
        self.private_key = private_key
        self.daemon = True

        self.client = comms.GRRHTTPClient(ca_cert=ca_cert,
                                          private_key=private_key)
        self.stop = False
        # Is this client already enrolled?
示例#6
0
import logging

# pylint: disable=unused-import,g-bad-import-order
from grr.lib import server_plugins
# pylint: enable=unused-import,g-bad-import-order

from grr.endtoend_tests import base
from grr.lib import access_control
from grr.lib import aff4
from grr.lib import config_lib
from grr.lib import flags
from grr.lib import startup
from grr.lib.aff4_objects import users as aff4_users

flags.DEFINE_bool("local_client", True,
                  "The target client(s) are running locally.")

flags.DEFINE_bool("local_worker", False, "Run tests with a local worker.")

flags.DEFINE_list(
    "client_ids", [], "List of client ids to test. If unset we use "
    "Test.end_to_end_client_ids from the config.")

flags.DEFINE_list(
    "hostnames", [], "List of client hostnames to test. If unset we use "
    "Test.end_to_end_client_hostnames from the config.")

flags.DEFINE_list(
    "testnames", [], "List of test names to run. If unset we run all "
    "relevant tests.")
示例#7
0
from grr.server.grr_response_server.gui import wsgiapp_testlib
from grr.server.grr_response_server.hunts import implementation
from grr.server.grr_response_server.hunts import standard
from grr.test_lib import acl_test_lib
from grr.test_lib import action_mocks
from grr.test_lib import artifact_test_lib
from grr.test_lib import hunt_test_lib
from grr.test_lib import test_lib

flags.DEFINE_string(
    "chrome_driver_path", None,
    "Path to the chrome driver binary. If not set, webdriver "
    "will search on PATH for the binary.")

flags.DEFINE_bool(
    "use_headless_chrome", False, "If set, run Chrome driver in "
    "headless mode. Useful when running tests in a window-manager-less "
    "environment.")

# A increasing sequence of times.
TIME_0 = test_lib.FIXED_TIME
TIME_1 = TIME_0 + rdfvalue.Duration("1d")
TIME_2 = TIME_1 + rdfvalue.Duration("1d")


def DateString(t):
    return t.Format("%Y-%m-%d")


def DateTimeString(t):
    return t.Format("%Y-%m-%d %H:%M:%S")
示例#8
0
文件: client.py 项目: sh1nu11bi/grr
import logging
import pdb

from grr import config
# pylint: disable=unused-import
from grr_response_client import client_plugins
# pylint: enable=unused-import
from grr_response_client import client_startup
from grr_response_client import comms
from grr_response_client import installer
from grr.config import contexts
from grr.lib import config_lib
from grr.lib import flags

flags.DEFINE_bool("install", False, "Specify this to install the client.")

flags.DEFINE_bool(
    "break_on_start", False,
    "If True break into a pdb shell immediately on startup. This"
    " can be used for debugging the client manually.")

flags.DEFINE_bool(
    "debug_client_actions", False,
    "If True break into a pdb shell before executing any client"
    " action.")


def main(unused_args):
    # Allow per platform configuration.
    config.CONFIG.AddContext(
示例#9
0
# pylint: disable=unused-import,g-bad-import-order
from grr.lib import server_plugins
# pylint: enable=unused-import,g-bad-import-order

from grr.gui import admin_ui
from grr.lib import config_lib
from grr.lib import flags
from grr.lib import startup
from grr.server.data_server import data_server
from grr.tools import http_server
from grr.worker import enroller
from grr.worker import worker


flags.DEFINE_bool("start_enroller", False,
                  "Start the server as enroller.")

flags.DEFINE_bool("start_worker", False,
                  "Start the server as worker.")

flags.DEFINE_bool("start_http_server", False,
                  "Start the server as HTTP server.")

flags.DEFINE_bool("start_ui", False,
                  "Start the server as user interface.")

flags.DEFINE_bool("start_dataserver", False,
                  "Start the dataserver.")


def main(argv):
示例#10
0
from grr.server import data_store
from grr.server import server_logging
from grr.server.data_server import auth
from grr.server.data_server import constants
from grr.server.data_server import errors
from grr.server.data_server import master
from grr.server.data_server import rebalance
from grr.server.data_server import store
from grr.server.data_server import utils as sutils

flags.DEFINE_integer("port", None, "Specify the data server port.")

flags.DEFINE_string("path", None, "Specify the data store path.")

flags.DEFINE_bool("master", False, "Mark this data server as the master.")

flags.DEFINE_bool("ipv6", False, "Use IPV6 to accept connections.")


class DataServerHandler(BaseHTTPRequestHandler, object):
    """Handler for HTTP requests to the data server."""

    # Data store service.
    SERVICE = None
    # MASTER is set if this data server is also running as master.
    MASTER = None
    # Set if the server is not the master.
    DATA_SERVER = None
    # Mapping information sent/created by the master.
    MAPPING = None
示例#11
0
from grr_response_client import client_startup
from grr_response_client import comms
from grr_response_client import vfs
from grr.config import contexts
from grr.lib import flags
from grr.lib.rdfvalues import crypto as rdf_crypto
from grr.lib.rdfvalues import paths as rdf_paths

flags.DEFINE_integer("nrclients", 1, "Number of clients to start")

flags.DEFINE_string(
    "cert_file", "", "Path to a file that stores all certificates for"
    "the client pool.")

flags.DEFINE_bool(
    "enroll_only", False,
    "If specified, the script will enroll all clients and exit.")

flags.DEFINE_bool(
    "fast_poll", False,
    "If specified, every client in the pool will work in the "
    "fast poll mode. This is useful for benchmarks, as in fast "
    "poll mode the timeouts are predictable and benchmarks "
    "results are more stable.")


class PoolGRRClient(threading.Thread):
    """A GRR client for running in pool mode."""
    def __init__(self, ca_cert=None, private_key=None, fast_poll=False):
        """Constructor."""
        super(PoolGRRClient, self).__init__()
示例#12
0
flags.DEFINE_string("api_password", "", "Password for GRR API.")

flags.DEFINE_list("client_ids", [], "List of client ids to test.")

flags.DEFINE_list("hostnames", [], "List of client hostnames to test.")

flags.DEFINE_list(
    "testnames", [], "List of test cases to run. If unset we run all "
    "tests for a client's platform.")

# We use a logging Filter to exclude noisy unwanted log output.
flags.DEFINE_list("filenames_excluded_from_log", ["connectionpool.py"],
                  "Files whose log messages won't get printed.")

flags.DEFINE_bool("upload_test_binaries", True,
                  "Whether to upload executables needed by some e2e tests.")


def RunEndToEndTests():
    """Runs end-to-end tests against clients using the GRR API."""

    ValidateAllTests()

    logging.info("Connecting to API at %s", flags.FLAGS.api_endpoint)
    password = flags.FLAGS.api_password
    if not password:
        password = getpass.getpass(prompt="Please enter the API password for "
                                   "user '%s': " % flags.FLAGS.api_user)
    grr_api = api.InitHttp(api_endpoint=flags.FLAGS.api_endpoint,
                           auth=(flags.FLAGS.api_user, password))