Exemplo n.º 1
0
  def __init__(
      self, hostname, reason, grr_server_url, username, password,
      artifacts=None, use_tsk=False, approvers=None, verbose=False):
    """Initializes a GRR artifact collector.

    Args:
      hostname:
      reason:
      grr_server_url:
      username (str): GRR server username.
      password (str): GRR server password.
      artifacts (Optional[list()]:
      use_tsk (Optional[bool]):
      approvers (Optional[list(str)]):
      verbose (Optional[bool]):
    """
    super(GRRArtifactCollector, self).__init__(verbose=verbose)
    self.output_path = tempfile.mkdtemp()
    self.grr_api = grr_api.InitHttp(
        api_endpoint=grr_server_url, auth=(username, password))
    self.artifacts = artifacts
    self.host = hostname
    self.use_tsk = use_tsk
    self.reason = reason
    self.approvers = approvers
    self._client_id = self._GetClientId(hostname)
    self._client = None
Exemplo n.º 2
0
  def setUp(self):
    super(ApiE2ETest, self).setUp()
    api_auth_manager.APIACLInit.InitApiAuthManager()

    self.port = HTTPApiEndToEndTestProgram.server_port
    self.endpoint = "http://localhost:%s" % self.port
    self.api = grr_api.InitHttp(api_endpoint=self.endpoint)
Exemplo n.º 3
0
def main(argv=None):
    arg_parser = GrrApiShellArgParser()
    flags = arg_parser.parse_args(args=argv or [])

    grr_api = api.InitHttp(**vars(flags))

    IPShell([sys.argv[0]], user_ns=dict(grr=grr_api))
Exemplo n.º 4
0
def main(argv=None):
  if not argv:
    argv = sys.argv[1:]

  arg_parser = GrrApiShellArgParser()
  flags = arg_parser.parse_args(args=argv)

  logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stderr))
  if flags.debug:
    logging.getLogger().setLevel(logging.DEBUG)

  auth = None
  if flags.basic_auth_username:
    auth = (flags.basic_auth_username, flags.basic_auth_password or "")

  grrapi = api.InitHttp(
      api_endpoint=flags.api_endpoint, page_size=flags.page_size, auth=auth)

  if flags.exec_code and flags.exec_file:
    print "--exec_code --exec_file flags can't be supplied together"
    sys.exit(1)
  elif flags.exec_code:
    # pylint: disable=exec-used
    exec (flags.exec_code, dict(grrapi=grrapi))
    # pylint: enable=exec-used
  elif flags.exec_file:
    execfile(flags.exec_file, dict(grrapi=grrapi))
  else:
    api_shell_lib.IPShell([sys.argv[0]], user_ns=dict(grrapi=grrapi))
Exemplo n.º 5
0
    def setUp(self):
        super(ApiE2ETest, self).setUp()

        api_auth_manager.APIACLInit.InitApiAuthManager()
        self.token.username = "******"
        webauth.WEBAUTH_MANAGER.SetUserName(self.token.username)

        self.port = HTTPApiEndToEndTestProgram.server_port
        self.endpoint = "http://localhost:%s" % self.port
        self.api = grr_api.InitHttp(api_endpoint=self.endpoint)
Exemplo n.º 6
0
def main(argv=None):
    arg_parser = GrrApiShellArgParser()
    flags = arg_parser.parse_args(args=argv or [])

    logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stderr))
    if flags.debug:
        logging.getLogger().setLevel(logging.DEBUG)

    auth = None
    if flags.basic_auth_username:
        auth = (flags.basic_auth_username, flags.basic_auth_password or "")

    grr_api = api.InitHttp(api_endpoint=flags.api_endpoint,
                           page_size=flags.page_size,
                           auth=auth)

    api_shell_lib.IPShell([sys.argv[0]], user_ns=dict(grr=grr_api))
Exemplo n.º 7
0
  def __init__(
      self, hunt_id, reason, grr_server_url, username, password, approvers=None,
      verbose=False):
    """ Initializes a GRR hunt results collector.

    Args:
      hunt_id:
      reason:
      grr_server_url:
      username:
      password:
      approvers:
      verbose:
    """
    super(GRRHuntCollector, self).__init__(verbose=verbose)
    self.output_path = tempfile.mkdtemp()
    self.grr_api = grr_api.InitHttp(
        api_endpoint=grr_server_url, auth=(username, password))
    self.approvers = approvers
    self.reason = reason
    self.hunt_id = hunt_id
    self._hunt = self.grr_api.Hunt(hunt_id).Get()
Exemplo n.º 8
0
    def setUp(self):
        super(ApiE2ETest, self).setUp()

        self.port = HTTPApiEndToEndTestProgram.server_port
        self.endpoint = "http://localhost:%s" % self.port
        self.api = grr_api.InitHttp(api_endpoint=self.endpoint)