def get_repairable_apps(handler, computer_id):
    m = "Getting all Repairable Applications for Computer ID that equals {!r}".format(computer_id)
    mylog.info(m)

    kwargs = {
        'qtype': 'manual_human',
        'sensors': [
            'Repairable Applications, opt:max_data_age:{}'.format(max_data_age),
        ],
        'question_filters': [
            'Computer ID, that =:{}'.format(computer_id)
        ],
        'question_options': [
            'max_data_age:{}'.format(max_data_age),
        ],
    }

    m = "Asking question with args:\n{}".format(utils.jsonify(kwargs))
    mylog.debug(m)

    ask_ra_ret = handler.ask(**kwargs)
    ask_ra_results = ask_ra_ret['question_results']
    ask_ra_dict = dictify_resultset(ask_ra_results)

    m = "Received resultset from question:\n{}".format(utils.jsonify(ask_ra_dict))
    mylog.debug(m)

    if not ask_ra_dict:
        m = "No applications available for repair!!"
        mylog.critical(m)
        sys.exit(1)

    return ask_ra_dict
def get_repairable_apps(handler, computer_id):
    m = "Getting all Repairable Applications for Computer ID that equals {!r}".format(
        computer_id)
    mylog.info(m)

    kwargs = {
        'qtype':
        'manual_human',
        'sensors': [
            'Repairable Applications, opt:max_data_age:{}'.format(
                max_data_age),
        ],
        'question_filters': ['Computer ID, that =:{}'.format(computer_id)],
        'question_options': [
            'max_data_age:{}'.format(max_data_age),
        ],
    }

    m = "Asking question with args:\n{}".format(utils.jsonify(kwargs))
    mylog.debug(m)

    ask_ra_ret = handler.ask(**kwargs)
    ask_ra_results = ask_ra_ret['question_results']
    ask_ra_dict = dictify_resultset(ask_ra_results)

    m = "Received resultset from question:\n{}".format(
        utils.jsonify(ask_ra_dict))
    mylog.debug(m)

    if not ask_ra_dict:
        m = "No applications available for repair!!"
        mylog.critical(m)
        sys.exit(1)

    return ask_ra_dict
def get_installed_apps(handler, computer_id):
    m = "Getting all Installed Applications for Computer ID that equals {!r}".format(computer_id)
    mylog.info(m)

    kwargs = {
        'qtype': 'manual_human',
        'sensors': [
            'Installed Applications, opt:max_data_age:{}'.format(max_data_age)
        ],
        'question_filters': [
            'Computer ID, that =:{}'.format(computer_id)
        ],
        'question_options': [
            'max_data_age:{}'.format(max_data_age),
        ],
    }

    m = "Asking question with args:\n{}".format(utils.jsonify(kwargs))
    mylog.debug(m)

    ask_ia_ret = handler.ask(**kwargs)
    ask_ia_results = ask_ia_ret['question_results']
    ask_ia_dict = dictify_resultset(ask_ia_results)

    m = "Received resultset from question:\n{}".format(utils.jsonify(ask_ia_dict))
    mylog.debug(m)
    return ask_ia_dict
def get_installed_apps(handler, computer_id):
    m = "Getting all Installed Applications for Computer ID that equals {!r}".format(
        computer_id)
    mylog.info(m)

    kwargs = {
        'qtype':
        'manual_human',
        'sensors':
        ['Installed Applications, opt:max_data_age:{}'.format(max_data_age)],
        'question_filters': ['Computer ID, that =:{}'.format(computer_id)],
        'question_options': [
            'max_data_age:{}'.format(max_data_age),
        ],
    }

    m = "Asking question with args:\n{}".format(utils.jsonify(kwargs))
    mylog.debug(m)

    ask_ia_ret = handler.ask(**kwargs)
    ask_ia_results = ask_ia_ret['question_results']
    ask_ia_dict = dictify_resultset(ask_ia_results)

    m = "Received resultset from question:\n{}".format(
        utils.jsonify(ask_ia_dict))
    mylog.debug(m)
    return ask_ia_dict
def uninstall_package(handler, uninstall_string, computer_id):
    m = "Issuing uninstall string {!r} to Computer ID that equals {!r}".format(
        uninstall_string, computer_id)
    mylog.info(m)

    # escape any {}'s in the uninstall string so they dont break pytans param parsing
    uninstall_string = uninstall_string.replace('{', '\\{').replace('}', '\\}')
    kwargs = {
        'package':
        'Uninstall MSI Parameterized{{$1={}}}'.format(uninstall_string),
        'action_filters': [
            'Computer ID, that =:{}'.format(computer_id),
            'Online, that =:True',
        ],
        'run':
        True,
    }
    m = "Uninstalling Application with args:\n{}".format(utils.jsonify(kwargs))
    mylog.debug(m)
    dep_ret = handler.deploy_action_human(**kwargs)

    m = "Uninstall string {!r} finished running on Computer ID that equals {!r}".format(
        uninstall_string, computer_id)
    mylog.info(m)

    return dep_ret
def get_logged_in_matches(handler, logged_in_user):
    m = "Searching for all servers with a Logged In user that equals '{}'".format(
        logged_in_user)
    mylog.info(m)

    kwargs = {
        'qtype':
        'manual_human',
        'sensors': [
            'Computer ID',
            'Computer Name',
            'IP Address',
            'Logged In Users',
            'Operating System',
        ],
        'question_filters':
        ['Logged In Users, that =:{}'.format(logged_in_user)],
    }

    m = "Asking question with args:\n{}".format(utils.jsonify(kwargs))
    mylog.debug(m)

    ask_logged_in_ret = handler.ask(**kwargs)
    ask_logged_in_results = ask_logged_in_ret['question_results']

    if not ask_logged_in_results.rows:
        m = "No servers found that match the question '{}'".format(
            ask_logged_in_ret['question_object'].query_text)
        mylog.critical(m)
        sys.exit(1)

    ask_logged_in_dict = dictify_resultset(ask_logged_in_results)

    m = "Received resultset from question:\n{}".format(
        utils.jsonify(ask_logged_in_dict))
    mylog.debug(m)
    return ask_logged_in_dict
def get_logged_in_matches(handler, logged_in_user):
    m = "Searching for all servers with a Logged In user that equals '{}'".format(logged_in_user)
    mylog.info(m)

    kwargs = {
        'qtype': 'manual_human',
        'sensors': [
            'Computer ID',
            'Computer Name',
            'IP Address',
            'Logged In Users',
            'Operating System',
        ],
        'question_filters': [
            'Logged In Users, that =:{}'.format(logged_in_user)
        ],
    }

    m = "Asking question with args:\n{}".format(utils.jsonify(kwargs))
    mylog.debug(m)

    ask_logged_in_ret = handler.ask(**kwargs)
    ask_logged_in_results = ask_logged_in_ret['question_results']

    if not ask_logged_in_results.rows:
        m = "No servers found that match the question '{}'".format(
            ask_logged_in_ret['question_object'].query_text
        )
        mylog.critical(m)
        sys.exit(1)

    ask_logged_in_dict = dictify_resultset(ask_logged_in_results)

    m = "Received resultset from question:\n{}".format(utils.jsonify(ask_logged_in_dict))
    mylog.debug(m)
    return ask_logged_in_dict
def repair_package(handler, guid, computer_id):
    m = "Repairing GUID {!r} to Computer ID that equals {!r}".format(guid, computer_id)
    mylog.info(m)

    kwargs = {
        'package': 'Repair MSI{{$1={}}}'.format(guid),
        'action_filters': [
            'Computer ID, that =:{}'.format(computer_id),
            'Online, that =:True',
        ],
        'run': True,
    }
    m = "Repairing Application with args:\n{}".format(utils.jsonify(kwargs))
    mylog.debug(m)
    dep_ret = handler.deploy_action_human(**kwargs)

    m = "GUID {!r} finished repairing on Computer ID that equals {!r}".format(guid, computer_id)
    mylog.info(m)

    return dep_ret
def install_package(handler, package_name, computer_id):
    m = "Installing package {!r} to Computer ID that equals {!r}".format(package_name, computer_id)
    mylog.info(m)

    kwargs = {
        'package': package_name,
        'action_filters': [
            'Computer ID, that =:{}'.format(computer_id),
            'Online, that =:True',
        ],
        'run': True,
    }
    m = "Installing Application with args:\n{}".format(utils.jsonify(kwargs))
    mylog.debug(m)
    dep_ret = handler.deploy_action_human(**kwargs)

    m = "Package {!r} finished installing on Computer ID that equals {!r}".format(
        package_name, computer_id)
    mylog.info(m)

    return dep_ret
def uninstall_package(handler, uninstall_string, computer_id):
    m = "Issuing uninstall string {!r} to Computer ID that equals {!r}".format(
        uninstall_string, computer_id)
    mylog.info(m)

    # escape any {}'s in the uninstall string so they dont break pytans param parsing
    uninstall_string = uninstall_string.replace('{', '\\{').replace('}', '\\}')
    kwargs = {
        'package': 'Uninstall MSI Parameterized{{$1={}}}'.format(uninstall_string),
        'action_filters': [
            'Computer ID, that =:{}'.format(computer_id),
            'Online, that =:True',
        ],
        'run': True,
    }
    m = "Uninstalling Application with args:\n{}".format(utils.jsonify(kwargs))
    mylog.debug(m)
    dep_ret = handler.deploy_action_human(**kwargs)

    m = "Uninstall string {!r} finished running on Computer ID that equals {!r}".format(
        uninstall_string, computer_id)
    mylog.info(m)

    return dep_ret
def repair_package(handler, guid, computer_id):
    m = "Repairing GUID {!r} to Computer ID that equals {!r}".format(
        guid, computer_id)
    mylog.info(m)

    kwargs = {
        'package':
        'Repair MSI{{$1={}}}'.format(guid),
        'action_filters': [
            'Computer ID, that =:{}'.format(computer_id),
            'Online, that =:True',
        ],
        'run':
        True,
    }
    m = "Repairing Application with args:\n{}".format(utils.jsonify(kwargs))
    mylog.debug(m)
    dep_ret = handler.deploy_action_human(**kwargs)

    m = "GUID {!r} finished repairing on Computer ID that equals {!r}".format(
        guid, computer_id)
    mylog.info(m)

    return dep_ret
def install_package(handler, package_name, computer_id):
    m = "Installing package {!r} to Computer ID that equals {!r}".format(
        package_name, computer_id)
    mylog.info(m)

    kwargs = {
        'package':
        package_name,
        'action_filters': [
            'Computer ID, that =:{}'.format(computer_id),
            'Online, that =:True',
        ],
        'run':
        True,
    }
    m = "Installing Application with args:\n{}".format(utils.jsonify(kwargs))
    mylog.debug(m)
    dep_ret = handler.deploy_action_human(**kwargs)

    m = "Package {!r} finished installing on Computer ID that equals {!r}".format(
        package_name, computer_id)
    mylog.info(m)

    return dep_ret
Ejemplo n.º 13
0
 def test_jsonify(self):
     exp = '{\n  "x": "d"\n}'
     self.assertEquals(utils.jsonify({'x': 'd'}), exp)
Ejemplo n.º 14
0
    d_opts = [
        'package', 'action_filters', 'action_options', 'run', 'report_file', 'report_dir',
        'start_seconds_from_now', 'expire_seconds', 'get_results',
        'package_help', 'filters_help', 'options_help',
    ]
    report_dir = all_args.get('report_dir', '')
    report_file = all_args.get('report_file', '')
    if not report_file:
        prefix = 'deploy_action_'
    else:
        prefix = ''

    d_args = {k: all_args.pop(k) for k in d_opts}

    print "++ Deploying action:\n{}".format(utils.jsonify(d_args))
    try:
        ret = handler.deploy_action_human(**d_args)
    except Exception as e:
        print e
        sys.exit(99)

    print "++ Deployed Action {!r} ID: {!r}".format(
        ret['action_object'].name, ret['action_object'].id
    )
    print "++ Command used in Action: {!r}".format(
        ret['action_object'].package_spec.command
    )

    if ret['action_progress_human']:
        print "++ Deploy action progress check results:"
Ejemplo n.º 15
0
    parser.add_argument(
        '--json',
        required=False,
        default=False,
        action='store_true',
        dest='json',
        help='Show a json dump of the server information',
    )

    args = parser.parse_args()
    all_args = args.__dict__
    if not args.username:
        username = raw_input('Tanium Username: '******'username'] = username.strip()

    if not args.password:
        password = getpass.getpass('Tanium Password: '******'password'] = password.strip()

    if not args.host:
        host = raw_input('Tanium Host: ')
        all_args['host'] = host.strip()

    handler = process_handler_args(parser, all_args)

    if args.json:
        print utils.jsonify(handler.session.server_info)
    else:
        print str(handler)
        print_obj(handler.session.server_info)