def init(self): '''更新任务类型''' MT = models.TaskType for name, f in self.tasklist.items(): try: R = MT.get(MT.task_name == f['name']) except MT.DoesNotExist: R = MT(task_name=f['name']) R.task_desc = f['doc'] R.task_type = f['type'] R.save() '''更新插件''' PluginsManage.load('./payloads') MP = models.TaskPlugins MV = models.Vulnerable for plug in BaseHostPlugin.payloads() + BaseWebPlugin.payloads(): if plug.bugname == ('', ): continue RV, cd = MV.get_or_create(vul_name=plug.bugname) if cd: RV.vul_rank = plug.bugrank RV.vul_desc = plug.bugdesc RV.vul_plan = plug.bugplan RV.vul_number = plug.bugnumber RV.save() R, cd = MP.get_or_create(plug_name=plug.__class__.__name__) if cd: R.updatedate = datetime.datetime.now() R.vulid = RV R.plug_desc = plug.bugname R.plug_type = plug.__class__.__base__ R.plug_file = plug.__class__ R.save()
def __init__(self,taskid): PluginsManage.load('./payloads') M = models.ScanTask self.Q = M.get(M.task_id==taskid) self.T = app.AsyncResult(taskid) self.settings = {} self.target = None self.args = json.loads(self.Q.task_args) self.target = str(self.Q.task_host).strip() '''
def __init__(self, taskid): PluginsManage.load('./payloads') M = models.ScanTask self.Q = M.get(M.task_id == taskid) self.T = app.AsyncResult(taskid) self.settings = {} self.target = None self.args = {} av = {} for d in str(self.Q.task_args).strip().split(): if d is None or d == 'None': continue d = d[1:].split('=') av[d[0]] = d[1] self.args = av self.target = str(self.Q.task_host).strip() '''
def scan(self): MP = models.Project MH = models.HostResult MR = models.PortResult plug_names = self.args.get('plug', '').split(',') for plug_name in plug_names: logging.info('Scan plug name: %s' % plug_name) hosts = self.target ret = [] try: R = MP.get(MP.project_id == hosts) for H in MH.select().where(MH.projectid == R): ret.append(str(H.host_ip)) except MP.DoesNotExist: for H in gethosts(self.target): ret.append(H) wret = [] hret = [] for H in ret: for P in MR.select().join(MH).where( (MH.host_ip == H) & (MH.projectid == self.Q.projectid)): if str(P.service_name) == 'http': hp = 'https' if '443' in str(P.port) else 'http' url = '%s://%s:%s/' % (hp, str(P.host), str(P.port)) host = BaseWebSite(url) wret.append(host) else: host = BaseHost(str(P.host), str(P.port), service=str(P.service_name)) hret.append(host) ret = [] for plug in PluginsManage.get_plugins(plug_name): if isinstance(plug, BaseHostPlugin): for host in hret: ret.append((plug, host)) elif isinstance(plug, BaseWebPlugin): for host in wret: ret.append((plug, host)) pool = CoroutinePool(10) for plug, host in ret: pool.spawn(self.payloadverify, plug, host) pool.join()