Ejemplo n.º 1
0
def detailpage(request):
    content=request.POST.get('content','')
    page=request.POST.get('page','0')
    response_data = {}  
    response_data['result'] = '0'
    print content
    if  content!='':
        extra='    or   script  like \'%'+content+'%\' or detail  like \'%'+content+'%\'  or timesearch like ' +'\'%'+content+'%\''
        ports,portcount,portpagecount=portcontrol.portshow(ip=content,port=content,timesearch=content,state=content,name=content,product=content,version=content,page=page,extra=extra,command='or')

        response_data['result'] = '1' 
    
    
        response_data['ports']=ports
        response_data['portslength']=portcount
        response_data['portspagecount']=portpagecount
        response_data['portspage']=page
    return HttpResponse(json.dumps(response_data,skipkeys=True,default=webtool.object2dict), content_type="application/json")  
Ejemplo n.º 2
0
    def task(self, req, threadname):
        if len(req) > 2:

            startip = str(req[0])
            stopip = str(req[1])
            taskid = req[2].get('taskid', '')
            taskport = req[2].get('taskport', '')
            isjob = req[2].get('isjob', '0')
            username = req[2].get('username', '')
            command = req[2].get('command', '')
            status = req[2].get('status', '')
            mode = req[2].get('mode', '2')
            if command == 'create':
                if mode == 1:
                    self.getIplist(startip, stopip, taskid, taskport, isjob,
                                   username, command, status)
                else:

                    jobs, count, pagecount = jobcontrol.jobshow(groupid=taskid)
                    if count > 0:
                        ip = jobs[0].getJobaddress()

                        print '当前数据库读到最后一次的任务是:' + ip
                        if self.iprange(
                                ip, stopip
                        ) < 0 or ip == stopip:  #or self.iprange(ip, startip)>0 or ip==startip
                            print '该任务之前已经创建无需重复创建'

                        else:
                            startipnum = self.ip2num(ip)
                            startipnum = startipnum + 1
                            ip = self.num2ip(startipnum)
                            self.getIplist(ip, stopip, taskid, taskport, isjob,
                                           username, command, status)

                    else:
                        self.getIplist(startip, stopip, taskid, taskport,
                                       isjob, username, command, status)

                pass
            elif command == 'work':
                if mode == 1:
                    self.getIplist(startip, stopip, taskid, taskport, isjob,
                                   username, command, status)
                elif mode == 0:

                    jobs, count, pagecount = jobcontrol.jobshow(groupid=taskid,
                                                                jobstatus='5')
                    if count > 0:
                        ip = jobs[0].getJobaddress()

                        print '当前数据库读到最后一次已完成的任务是:' + ip
                        if self.iprange(
                                ip, stopip
                        ) < 0 or ip == stopip:  # or self.iprange(ip, startip)>0 or ip==startip
                            print '该任务之前已经创建无需重复创建'

                        else:
                            print '恢复启动任务'
                            startipnum = self.ip2num(ip)
                            startipnum = startipnum + 1
                            ip = self.num2ip(startipnum)
                            print ip, stopip
                            self.getIplist(ip, stopip, taskid, taskport, isjob,
                                           username, command, status)

                    else:

                        self.getIplist(startip, stopip, taskid, taskport,
                                       isjob, username, command, status)

                else:
                    portarray, count, pagecount = portcontrol.portshow(
                        order='timesearch desc')
                    if count > 0:
                        ip = portarray[0].getIP()
                        print '当前数据库读到最后一次ip:' + ip
                        startip = ip
                    print 'start task from %s to %s' % (startip, stopip)
                    self.getIplist(startip, stopip, taskid, taskport, isjob,
                                   username, command, status)

        ans = ''
        print threadname + '执行任务中' + str(datetime.datetime.now())
        return ans
Ejemplo n.º 3
0
    def task(self,req,threadname):
        if len(req)>2:

            startip=str(req[0])
            stopip=str(req[1])
            taskid = req[2].get('taskid','')
            taskport = req[2].get('taskport','')
            isjob = req[2].get('isjob','0')
            username=req[2].get('username','')
            command=req[2].get('command','')
            status = req[2].get('status','')
            mode=req[2].get('mode','2')
            if command=='create':
                if mode==1:
                    self.getIplist(startip, stopip, taskid, taskport, isjob, username, command, status)
                else:

                    jobs, count, pagecount=jobcontrol.jobshow(groupid=taskid)
                    if count>0:
                        ip=jobs[0].getJobaddress()

                        print '当前数据库读到最后一次的任务是:'+ip
                        if self.iprange(ip, stopip)<0 or ip==stopip :#or self.iprange(ip, startip)>0 or ip==startip
                            print '该任务之前已经创建无需重复创建'

                        else:
                            startipnum = self.ip2num(ip)
                            startipnum = startipnum + 1
                            ip = self.num2ip(startipnum)
                            self.getIplist(ip, stopip, taskid, taskport, isjob, username, command, status)

                    else:
                        self.getIplist(startip, stopip, taskid, taskport, isjob, username, command, status)


                pass
            elif command=='work':
                if mode == 1:
                    self.getIplist(startip, stopip, taskid, taskport, isjob, username, command, status)
                elif mode ==0:



                    jobs, count, pagecount = jobcontrol.jobshow(groupid=taskid,jobstatus='5')
                    if count > 0:
                        ip = jobs[0].getJobaddress()

                        print '当前数据库读到最后一次已完成的任务是:' + ip
                        if self.iprange(ip,
                                        stopip) < 0 or ip == stopip:  # or self.iprange(ip, startip)>0 or ip==startip
                            print '该任务之前已经创建无需重复创建'

                        else:
                            print '恢复启动任务'
                            startipnum = self.ip2num(ip)
                            startipnum = startipnum + 1
                            ip = self.num2ip(startipnum)
                            print ip,stopip
                            self.getIplist(ip, stopip, taskid, taskport, isjob, username, command, status)

                    else:

                        self.getIplist(startip, stopip, taskid, taskport, isjob, username, command, status)

                else:
                    portarray, count, pagecount=portcontrol.portshow(order='timesearch desc')
                    if count>0:
                        ip = portarray[0].getIP()
                        print '当前数据库读到最后一次ip:' + ip
                        startip=ip
                    print 'start task from %s to %s' %(startip,stopip)
                    self.getIplist(startip, stopip, taskid, taskport, isjob, username, command, status)


        ans=''
        print threadname+'执行任务中'+str(datetime.datetime.now())
        return ans