Exemple #1
0
    def scan(self):

        MP = models.Project
        MH = models.HostResult
        MR = models.PortResult
        ping = int(self.args.get('ping',0))
        for target in [self.target] if ping else gethosts(self.target):
            self.portscan(target)
        ret = []
        payloads = BaseHostPlugin.payloads() + BaseWebPlugin.payloads()
        for plug in payloads:
            for H in gethosts(self.target):
                for P in MR.select().join(MH).where((MH.host_ip == H)&(MH.projectid == self.Q.projectid)):
                    if isinstance(plug,BaseHostPlugin):
                        host = BaseHost(str(P.host),str(P.port),service=str(P.service_name))
                        ret.append((plug,host))
                    elif 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)
                        ret.append((plug,host))

        pool = CoroutinePool(len(payloads))
        for plug,host in ret:
            pool.spawn(self.payloadverify,plug,host)
        pool.join()
Exemple #2
0
 def load(self, url, threads=100):
     self.url = url
     pool = CoroutinePool(threads)
     for cms in self.cmsdict:
         pool.spawn(self.getver, cms['url'], cms['re'], cms['name'],
                    cms['md5'])
     pool.join()
     return self.result
Exemple #3
0
 def scan(self):
     hosts = self.ping(self.hosts) if self.neping else self.hosts
     pool = CoroutinePool(self.threads)
     for host in hosts:
         for port in self.ports:
             pool.spawn(self.addret, host, port)
     pool.join()
     return self.result
Exemple #4
0
 def gethttptitle(self):    
     MP = models.PortResult
     sw = MP.port_type == 'tcp'
     sw &= MP.service_name == 'http'
     pool = CoroutinePool(10)
     for q in MP.select().where(sw):
         pool.spawn(self.selecthttp,q)
         #self.selecthttp(q)
     pool.join()
     print('task done')
Exemple #5
0
    def scan(self):
        #不使用存活扫描时将IP分开来单个扫描保证进度能完整保存
        ping = int(self.args.get('ping', 1))
        for target in [self.target] if ping else gethosts(self.target):
            self.portscan(target)

        MP = models.PortResult
        sw = MP.port_type != 'tcp/http'
        sw &= MP.service_name == 'http'
        pool = CoroutinePool(10)
        for q in MP.select().where(sw):
            pool.spawn(self.selecthttp, q)
        pool.join()
Exemple #6
0
    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()
Exemple #7
0
 def run1(self):
     pool = ThreadPool(self.settings['threads'])
     self.FLAG = self.settings['timeout']
     try:
         self.addreq(self.basereq)
         self.parse(self.basereq.response())
     except:
         self.ISSTART = False
         return
     #5分钟后还没有任务加进来就当爬完了
     while self.ISSTART and self.FLAG > 0:
         #logging.load('Reload ... Wait for %s'%self.FLAG)
         try:
             req = self.ReqQueue.get(block=False)
             pool.spawn(self.request, req)
         except queue.Empty:
             time.sleep(1)
             self.FLAG -= 1
     self.ISSTART = False
     pool.join()
Exemple #8
0
 def run(self):
     pool = ThreadPool(self.settings['threads'])
     self.FLAG = self.settings['timeout']
     try:
         self.request(BaseRequest(self.basereq.url,headers=self.settings['headers'],session=self.session,proxy=self.settings['proxy']))
     except Exception as e:
         print('err',e)
         self.ISSTART = False
         return
     #5分钟后还没有任务加进来就当爬完了
     while self.ISSTART and self.FLAG > 0:
         #logging.load('Reload ... Wait for %s'%self.FLAG)
         try:
             req = self.ReqQueue.get(block=False)
             pool.spawn(self.request,req)
         except queue.Empty:
             time.sleep(1)
             self.FLAG -= 1
     self.ISSTART = False
     pool.join()
Exemple #9
0
 def webscan(self):
     pool = CoroutinePool(3)
     for payload in BaseWebPlugin.payloads():
         pool.spawn(self.payloadverify,payload,self.crawle.website)
     pool.join()