def service_run(request, name, crits_type, identifier): """ Run a service. """ request.user._setup() if request.method == 'POST': custom_config = request.POST elif request.method == "GET": # Run with no config... custom_config = {} user = request.user acl = get_acl_object(crits_type) if user.has_access_to(acl.SERVICES_EXECUTE): result = run_service(name, crits_type, identifier, user, execute=settings.SERVICE_MODEL, custom_config=custom_config, is_triage_run=False) else: result = {"success":False, "message":"User does not have permission to run services."} if result['success'] == True: return refresh_services(request, crits_type, identifier) else: return HttpResponse(json.dumps(result), content_type="application/json")
def service_run(request, name, crits_type, identifier): """ Run a service. """ request.user._setup() if request.method == 'POST': custom_config = request.POST elif request.method == "GET": # Run with no config... custom_config = {} user = request.user acl = get_acl_object(crits_type) if user.has_access_to(acl.SERVICES_EXECUTE): result = run_service(name, crits_type, identifier, user, execute=settings.SERVICE_MODEL, custom_config=custom_config, is_triage_run=False) else: result = { "success": False, "message": "User does not have permission to run services." } if result['success'] == True: return refresh_services(request, crits_type, identifier) else: return HttpResponse(json.dumps(result), content_type="application/json")
def run_services(self, service_list, obj_list, verbose=False, config={}): if verbose: print "Running services\n-------------------\n" for obj in obj_list: for service in service_list: if verbose: print " [+] {0} scan obj: {1}".format(service, obj.id) try: result = run_service(service, obj._meta['crits_type'], obj.id, self.user, obj=obj, custom_config=config, execute='process') if result['success'] != True: if verbose: print " [+] %s" % result['html'] except ServiceAnalysisError as e: if verbose: print " [+] %s" % e
def run_services(self, service_list, obj_list, verbose=False, config={}): if verbose: print "Running services\n-------------------\n" for obj in obj_list: for service in service_list: if verbose: print " [+] {0} scan obj: {1}".format(service, obj.id) try: result = run_service(service, obj._meta['crits_type'], obj.id, self.username, obj=obj, custom_config=config, execute='process') if result['success'] != True: if verbose: print " [+] %s" % result['html'] except ServiceAnalysisError as e: if verbose: print " [+] %s" % e
def service_run(request, name, crits_type, identifier): """ Run a service. """ username = str(request.user.username) if request.method == 'POST': custom_config = request.POST elif request.method == "GET": # Run with no config... custom_config = {} result = run_service(name, crits_type, identifier, username, execute=settings.SERVICE_MODEL, custom_config=custom_config) if result['success'] == True: return refresh_services(request, crits_type, identifier) else: return HttpResponse(json.dumps(result), content_type="application/json")
def run(self, argv): parser = OptionParser() parser.add_option("-d", "--domain", action="store", dest="domain", type="string", help="Domain to use (if not provided, do all)") parser.add_option("-c", "--config", dest="config", default={}, help="Service configuration") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="Be verbose") parser.add_option("-n", "--dry_run", action="store_true", dest="dry_run", default=False, help="Dry run, just show what would happen.") (opts, args) = parser.parse_args(argv) if opts.domain: if opts.verbose: print "[+] Using domain: %s" % opts.domain domain = opts.domain else: if opts.verbose: print "[+] Using ALL domains" domain = None config = {} if opts.config: config = ast.literal_eval(opts.config) if not config: print "No config provided, defaulting to live only." config['live_query'] = True else: print "Using config: %s" % config query = { '$or': [ { 'whois': { '$exists': True, '$not': {'$size': 0} } }, { 'unsupported_attrs.whois': { '$exists': True, '$not': {'$size': 0} } } ] } if domain: query['domain'] = domain doms = Domain.objects(__raw__=query) for dom in doms: print "Executing whois for %s" % dom.domain if opts.dry_run: continue try: result = run_service('whois', 'Domain', dom.id, self.username, obj=dom, custom_config=config) dom.save() except ServiceAnalysisError as e: print "Service error: %s" % e except ValidationError as e: print "Validation error: %s" % e
def run(self, argv): parser = OptionParser() parser.add_option("-d", "--domain", action="store", dest="domain", type="string", help="Domain to use (if not provided, do all)") parser.add_option("-c", "--config", dest="config", default={}, help="Service configuration") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="Be verbose") parser.add_option("-n", "--dry_run", action="store_true", dest="dry_run", default=False, help="Dry run, just show what would happen.") (opts, args) = parser.parse_args(argv) if opts.domain: if opts.verbose: print "[+] Using domain: %s" % opts.domain domain = opts.domain else: if opts.verbose: print "[+] Using ALL domains" domain = None config = {} if opts.config: config = ast.literal_eval(opts.config) if not config: print "No config provided, defaulting to live only." config['live_query'] = True else: print "Using config: %s" % config query = { '$or': [{ 'whois': { '$exists': True, '$not': { '$size': 0 } } }, { 'unsupported_attrs.whois': { '$exists': True, '$not': { '$size': 0 } } }] } if domain: query['domain'] = domain doms = Domain.objects(__raw__=query) for dom in doms: print "Executing whois for %s" % dom.domain if opts.dry_run: continue try: result = run_service('whois', 'Domain', dom.id, self.username, obj=dom, custom_config=config) dom.save() except ServiceAnalysisError as e: print "Service error: %s" % e except ValidationError as e: print "Validation error: %s" % e