Beispiel #1
0
def ipmain(request):   
    if request.method=='POST':
        islogin = request.COOKIES.get('islogin',False)
        jobid= request.POST.get('taskid','')
        page= request.POST.get('page','0')
        username = request.COOKIES.get('username','') 
        role = request.COOKIES.get('role','1')
        response_data = {}  
        response_data['result'] = '0' 
        if role=='1':
            jobs,count,pagecount=jobcontrol.jobshow(username=username,taskid=jobid)
#             print 'this is user'
        else:
            jobs,count,pagecount=jobcontrol.jobshow(taskid=jobid)
#             print 'this is administor'
        if count>0 and jobid!='':
            ip=jobs[0].getJobaddress()   
            port=jobs[0].getPort()
            statuss=jobs[0].getStatus()
            isip=webtool.isip(ip)
            if isip:
                
                ips,counts,pagecounts=ipcontrol.ipshow(ip=ip)
            else:
                ips,counts,pagecounts=ipcontrol.ipshow(hostname=ip)
                if counts>0:
                    ip=ips[0].getIP()
                else:
                    ip='未知'
            response_data['result'] = '1' 
            response_data['ipstate'] = '0' 
            response_data['ip']=ip
            response_data['jobstate']=statuss
#             print 'it has this task'
            if counts>0:
#                 print 'it has this ip'
                response_data['ipstate'] = '1' 
                response_data['length']=counts
                response_data['ips']=ips[0]
                response_data['pagecount']=pagecounts
                portinfo=portcontrol.divided(port,'port')
                ports,portcount,portpagecount=portcontrol.portshow(ip=ip,page=page,extra=portinfo)
                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")  
            else:
                return HttpResponse(json.dumps(response_data,skipkeys=True,default=webtool.object2dict), content_type="application/json")  

        else:
            return HttpResponse(json.dumps(response_data,skipkeys=True,default=webtool.object2dict), content_type="application/json")  
Beispiel #2
0
def ipmain(request):   
    if request.method=='POST':
        islogin = request.COOKIES.get('islogin',False)
        jobid= request.POST.get('taskid','')
        page= request.POST.get('page','0')
        username = request.COOKIES.get('username','') 
        role = request.COOKIES.get('role','1')
        response_data = {}  
        response_data['result'] = '0' 
        if role=='1':
            jobs,count,pagecount=jobcontrol.jobshow(username=username,taskid=jobid)
#             print 'this is user'
        else:
            jobs,count,pagecount=jobcontrol.jobshow(taskid=jobid)
#             print 'this is administor'
        if count>0 and jobid!='':
            ip=jobs[0].getJobaddress()   
            port=jobs[0].getPort()
            statuss=jobs[0].getStatus()
            isip=webtool.isip(ip)
            if isip:
                
                ips,counts,pagecounts=ipcontrol.ipshow(ip=ip)
            else:
                ips,counts,pagecounts=ipcontrol.ipshow(hostname=ip)
                if counts>0:
                    ip=ips[0].getIP()
                else:
                    ip='未知'
            response_data['result'] = '1' 
            response_data['ipstate'] = '0' 
            response_data['ip']=ip
            response_data['jobstate']=statuss
#             print 'it has this task'
            if counts>0:
#                 print 'it has this ip'
                response_data['ipstate'] = '1' 
                response_data['length']=counts
                response_data['ips']=ips[0]
                response_data['pagecount']=pagecounts
                portinfo=portcontrol.divided(port,'port')
                ports,portcount,portpagecount=portcontrol.portshow(ip=ip,page=page,extra=portinfo)
                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")  
            else:
                return HttpResponse(json.dumps(response_data,skipkeys=True,default=webtool.object2dict), content_type="application/json")  

        else:
            return HttpResponse(json.dumps(response_data,skipkeys=True,default=webtool.object2dict), content_type="application/json")  
Beispiel #3
0
def ipmain(request):
    if request.method == 'POST':  #POST
        islogin = request.COOKIES.get('islogin', False)
        jobid = request.POST.get('taskid', '')
        # jobid = request.POST.get('taskid','1410a6d6-90ac-11e8-af6f-74e50ba386da')
        page = request.POST.get('page', '0')
        username = request.COOKIES.get('username', '')
        role = request.COOKIES.get('role', '1')
        response_data = {}
        response_data['result'] = '0'

        # 从ip_maindata表中,根据条件过滤信息,表内容什么时候写入的?
        if role == '1':
            jobs, count, pagecount = jobcontrol.jobshow(username=username,
                                                        taskid=jobid)
            print 'this is user, jobid=', jobid
        else:
            jobs, count, pagecount = jobcontrol.jobshow(taskid=jobid)
            print 'this is administor, jobid=', jobid

        if count > 0 and jobid != '':
            ip = jobs[0].getJobaddress()
            port = jobs[0].getPort()
            jobstatuss = jobs[0].getStatus()
            isip = webtool.isip(ip)  #xxx.xxx.xxx.xxx

            # ips:所有结果存入的一个list中(每个结果都是一个Ip对象) counts:查询到的结果数量, pagecounts:页面数
            if isip:
                ips, counts, pagecounts = ipcontrol.ipshow(ip=ip)
            else:
                ips, counts, pagecounts = ipcontrol.ipshow(hostname=ip)

                if counts > 0:
                    ip = ips[0].getIP()
                else:
                    ip = '未知'
            response_data['result'] = '1'
            response_data['ipstate'] = '0'
            response_data['ip'] = ip
            response_data['jobstate'] = jobstatuss
            #             print 'it has this task'
            if counts > 0:
                table = localconfig.iptable
                print('%s has ip:%s' % (table, ip))
                response_data['ipstate'] = '1'
                response_data['length'] = counts
                response_data['ips'] = ips[0]
                response_data['pagecount'] = pagecounts
                portinfo = portcontrol.divided(
                    port, 'port'
                )  # from a part sql sentence "and (port=xxx/port between a and b or...)"
                # ports为返回的端口信息,存储每个端口的结果(Port对象)
                ports, portcount, portpagecount = portcontrol.portshow(
                    ip=ip, page=page, extra=portinfo)
                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")
            else:
                return HttpResponse(json.dumps(response_data,
                                               skipkeys=True,
                                               default=webtool.object2dict),
                                    content_type="application/json")
        else:
            return HttpResponse(json.dumps(response_data,
                                           skipkeys=True,
                                           default=webtool.object2dict),
                                content_type="application/json")