def add_domain_to_scope(domain, scope_id): task_data = { 'name': '添加域名', 'target': domain, 'start_time': '-', 'status': 'waiting', 'type': 'domain', "task_tag": "task", 'options': { 'domain_brute': True, 'domain_brute_type': 'test', 'port_scan_type': 'test', 'port_scan': True, 'service_detection': False, 'service_brute': False, 'os_detection': False, 'site_identify': True, 'site_capture': False, 'file_leak': False, 'alt_dns': False, 'site_spider': False, 'search_engines': False, 'ssl_cert': False, 'fofa_search': False, 'crtsh_search': True } } utils.conn_db('task').insert_one(task_data) task_id = str(task_data.pop("_id")) domain_task(domain, task_id, task_data["options"]) services.sync_asset(task_id=task_id, scope_id=scope_id)
def wrap_domain_executors(base_domain=None, job_id=None, scope_id=None, options=None, name=""): celery_id = "" if current_task._get_current_object(): celery_id = current_task.request.id task_data = { 'name': name, 'target': base_domain, 'start_time': '-', 'status': 'waiting', 'type': 'domain', 'task_tag': 'monitor', #标记为监控任务 'options': { 'domain_brute': True, 'domain_brute_type': 'test', 'riskiq_search': False, 'alt_dns': False, 'arl_search': True, 'port_scan_type': 'test', 'port_scan': True, 'service_detection': False, 'service_brute': False, 'os_detection': False, 'site_identify': False, 'site_capture': False, 'file_leak': False, 'site_spider': False, 'search_engines': False, 'ssl_cert': False, 'fofa_search': False, 'scope_id': scope_id }, 'celery_id': celery_id } if options is None: options = {} task_data["options"].update(options) conn('task').insert_one(task_data) task_id = str(task_data.pop("_id")) domain_executor = DomainExecutor(base_domain, task_id, task_data["options"]) try: update_job_run(job_id) new_domain = domain_executor.run() if new_domain: sync_asset(task_id, scope_id, update_flag=True) except Exception as e: logger.exception(e) domain_executor.update_task_field("status", TaskStatus.ERROR) domain_executor.update_task_field("end_time", utils.curr_date()) logger.info("end domain_executors {} {} {}".format(base_domain, scope_id, options))