示例#1
0
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", "if_older_than_max_age",
                  ["if_older_than_max_age", "always", "never"],
                  "How to refresh the cache. Options are: always (on every"
                  " client-side access), never, or, by default,"
                  " if_older_than_max_age (if last accessed > max_age seconds"
                  " ago).", type=str)

flags.DEFINE_bool("force_sparse_image", False,
                  "Whether to convert existing files bigger than the"
示例#2
0
from grr.lib import registry
from grr.lib import stats
from grr.lib import utils

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.")

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
示例#3
0
import os

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

from grr.lib import flags
from grr.lib import utils
from grr.server import aff4
from grr.server import data_store
from grr.server import server_startup

from grr.server.aff4_objects import filestore

flags.DEFINE_string("filename", "", "File with hashes.")
flags.DEFINE_integer("start", None, "Start row in the file.")


def _ImportRow(store, row, product_code_list, op_system_code_list):
  sha1 = row[0].lower()
  md5 = row[1].lower()
  crc = int(row[2].lower(), 16)
  file_name = utils.SmartUnicode(row[3])
  file_size = int(row[4])
  special_code = row[7]
  store.AddHash(sha1, md5, crc, file_name, file_size, product_code_list,
                op_system_code_list, special_code)


def ImportFile(store, filename, start):
  """Import hashes from 'filename' into 'store'."""
示例#4
0
from grr.test_lib import test_lib
from grr.lib import tests
from grr.lib import utils
from grr.parsers import tests
from grr.path_detection import tests
from grr.server import tests
from grr.worker import worker_test
# pylint: enable=unused-import,g-bad-import-order

flags.DEFINE_string("output", None,
                    "The name of the file we write on (default stderr).")

flags.DEFINE_list("exclude_tests", [],
                  "A comma-separated list of tests to exclude form running.")

flags.DEFINE_integer("processes", 0,
                     "Total number of simultaneous tests to run.")


def Red(s):
    return "\033[91m %s\033[00m" % s


def Green(s):
    return "\033[92m %s\033[00m" % s


class GRREverythingTestLoader(test_lib.GRRTestLoader):
    """Load all GRR test cases."""
    base_class = test_lib.GRRBaseTest

示例#5
0
# pylint: disable=unused-import,g-bad-import-order
from grr.lib import server_plugins
from grr.gui.api_plugins import tests as tests_lib
# pylint: enable=unused-import,g-bad-import-order

import json

from grr.gui import api_test_lib
from grr.gui import http_api

from grr.lib import flags
from grr.lib import testing_startup

flags.DEFINE_integer(
    "api_version", 1, "API version to use when generating tests. "
    "Version 1 uses custom JSON format, while version 2 "
    "relies on Protobuf3-compatible JSON format.")


def GroupRegressionTestsByHandler():
    result = {}
    for cls in api_test_lib.ApiCallHandlerRegressionTest.classes.values():
        if getattr(cls, "handler", None):
            result.setdefault(cls.handler, []).append(cls)

    return result


def main(unused_argv):
    sample_data = {}
示例#6
0
from grr.client import client

# pylint: disable=unused-import
# Make sure we load the client plugins
from grr.client import client_plugins
# pylint: enable=unused-import

from grr.client import comms
from grr.client import vfs
from grr.lib import config_lib
from grr.lib import flags
from grr.lib import startup
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(client.GRRClient, threading.Thread):
  """A GRR client for running in pool mode."""

  def __init__(self, *args, **kw):
    """Constructor."""
    super(PoolGRRClient, self).__init__(*args, **kw)
示例#7
0
# pylint: disable=unused-import,g-bad-import-order
from grr.lib import server_plugins
from grr.tools import http_server
from grr.gui import webauth
# pylint: enable=unused-import,g-bad-import-order

from grr.lib import communicator
from grr.lib import config_lib
from grr.lib import flags
from grr.lib import flow
from grr.lib import rdfvalue
from grr.lib import startup


flags.DEFINE_integer("max_queue_size", 500,
                     "Maximum number of messages to queue for the client.")

flags.DEFINE_integer("max_retransmission_time", 10,
                     "Maximum number of times we are allowed to "
                     "retransmit a request until it fails.")

flags.DEFINE_integer("message_expiry_time", 600,
                     "Maximum time messages remain valid within the system.")




class GrrWSGIServer(object):
  """A WSGI based GRR HTTP server."""

  server_pem = ""
示例#8
0
flags.DEFINE_string("aff4path", None,
                    "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", "if_older_than_max_age",
                  ["if_older_than_max_age", "always", "never"],
                  "How to refresh the cache. Options are: always (on every "
                  "client-side access), never, or, by default, "
                  "if_older_than_max_age (if last accessed > max_age seconds "
                  "ago).", type=str)

# The modes we'll use for aff4 objects that aren't really files.
# Taken from /etc
示例#9
0
from grr.server.grr_response_server import server_plugins
# pylint: enable=g-bad-import-order

from grr import config
from grr_api_client import api
from grr_api_client import api_shell_lib
from grr.config import contexts
from grr.config import server as config_server
from grr.lib import flags
from grr.server.grr_response_server import access_control
from grr.server.grr_response_server import fleetspeak_connector
from grr.server.grr_response_server import server_startup
from grr.server.grr_response_server.bin import api_shell_raw_access_lib

flags.DEFINE_integer(
    "page_size", 1000,
    "Page size used when paging through collections of items. Default is 1000."
)

flags.DEFINE_string(
    "username", None, "Username to use when making raw API calls. If not "
    "specified, USER environment variable value will be used.")

flags.DEFINE_string(
    "exec_code", None,
    "If present, no IPython shell is started but the code given in "
    "the flag is run instead (comparable to the -c option of "
    "IPython). The code will be able to use a predefined "
    "global 'grrapi' object.")

flags.DEFINE_string(
    "exec_file", None,
示例#10
0
#!/usr/bin/env python
"""Base classes and routines used by all end to end tests."""

import abc
import logging
import StringIO
import time

import unittest

from grr_api_client import errors
from grr.lib import flags

flags.DEFINE_integer("flow_timeout_secs", 650,
                     "How long to wait for flows to finish.")

flags.DEFINE_integer(
    "flow_results_sla_secs", 60,
    "How long to wait for flow results to be available after a flow completes."
)


class Error(Exception):
    """Base class for end-to-end tests exceptions."""


def GetClientTestTargets(grr_api=None,
                         client_ids=None,
                         hostnames=None,
                         checkin_duration_threshold=3600):
    """Get client urns for end-to-end tests.
示例#11
0
文件: test_base.py 项目: hanul93/grr
#!/usr/bin/env python
"""Base classes and routines used by all end to end tests."""

import abc
import logging
import StringIO
import time

import unittest

from grr_api_client import errors
from grr.lib import flags

flags.DEFINE_integer("flow_timeout_secs", 650,
                     "How long to wait for flows to finish.")


class Error(Exception):
    """Base class for end-to-end tests exceptions."""


def GetClientTestTargets(grr_api=None,
                         client_ids=None,
                         hostnames=None,
                         checkin_duration_threshold=3600):
    """Get client urns for end-to-end tests.

  Args:
    grr_api: GRR API object.
    client_ids: list of client id URN strings or rdf_client.ClientURNs.
    hostnames: list of hostnames to search for.