예제 #1
0
def taskdetail(request):
    if request.method == 'GET':
        islogin = request.COOKIES.get('islogin', False)
        # jobid应该自动获取,不是手动赋值,仅为测试!!
        # jobid = request.GET.get('jobid','1410a6d6-90ac-11e8-af6f-74e50ba386da')
        jobid = request.GET.get('jobid', '')
        username = request.COOKIES.get('username', '')
        role = request.COOKIES.get('role', '1')

        ctx = {}
        ctx['islogin'] = islogin
        ctx['jobid'] = jobid
        ctx['username'] = username
        ctx['role'] = role

        # return render_to_response('nmaptoolview/post.html', ctx)

        # jobs: 返回的数据库结果, count:多少个结果, pagecount:页面数
        if islogin == False:
            return render_to_response('nmaptoolview/login.html', {'data': ''})
        # 数据库表中原始存在的数据一定是管理员建立的,role初始化非1,因此role!=1一定是普通的用户,注册都设置为1
        if role == '1':
            jobs, count, pagecount = jobcontrol.jobshow(username=username,
                                                        taskid=jobid)
        else:
            jobs, count, pagecount = jobcontrol.jobshow(taskid=jobid)
        if count > 0 and jobid != '':
            return render_to_response('nmaptoolview/taskdetail.html', {
                'taskid': jobid,
                'username': username
            })
        else:
            return HttpResponse("权限不足或者没有此任务")
예제 #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")  
예제 #3
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")  
예제 #4
0
def taskdetail(request):
    if request.method=='GET':
        islogin = request.COOKIES.get('islogin',False)
        jobid= request.GET.get('jobid','')
        username = request.COOKIES.get('username','')
        role = request.COOKIES.get('role','1')
        if islogin==False:
            return render_to_response('nmaptoolview/login.html', {'data':''})
        if role=='1':
            jobs,count,pagecount=jobcontrol.jobshow(username=username,taskid=jobid)
        else:
            jobs,count,pagecount=jobcontrol.jobshow(taskid=jobid)
        if count>0 and jobid!='':
            return render_to_response('nmaptoolview/taskdetail.html', {'taskid':jobid,'username':username})
        else:
            return HttpResponse("权限不足或者没有此任务")
예제 #5
0
def updatejob(request,state=''):
    if request.method=='POST':
        islogin = request.COOKIES.get('islogin',False)
        jobid= request.POST.get('taskid','')
        username = request.COOKIES.get('username','') 
        role = request.COOKIES.get('role','1')
        response_data = {}  
        response_data['result'] = '0' 
        if role=='1':
            tempresult=jobcontrol.jobupdate(jobstatus=state,username=username,taskid=jobid)
#             print 'this is user'
        else:
            tempresult=jobcontrol.jobupdate(jobstatus=state,taskid=jobid)
        if tempresult==True:
            if state=='2':
                jobs,count,pagecount=jobcontrol.jobshow(taskid=jobid)
                if count>0:
                    tasktotally=taskcontrol.getObject()
                    if jobs[0].getForcesearch==1:


                        tasktotally.add_work(jobs)
                    else:

                        tasktotally.add_work(jobs)
                        
            response_data['result'] = '1'
        return response_data
예제 #6
0
def taskdetail(request):
    if request.method=='GET':
        islogin = request.COOKIES.get('islogin',False)
        jobid= request.GET.get('jobid','')
        username = request.COOKIES.get('username','')
        role = request.COOKIES.get('role','1')
        if islogin==False:
            return render_to_response('nmaptoolview/login.html', {'data':''})
        if role=='1':
            jobs,count,pagecount=jobcontrol.jobshow(username=username,taskid=jobid)
        else:
            jobs,count,pagecount=jobcontrol.jobshow(taskid=jobid)
        if count>0 and jobid!='':
            return render_to_response('nmaptoolview/taskdetail.html', {'taskid':jobid,'username':username})
        else:
            return HttpResponse("权限不足或者没有此任务")
예제 #7
0
def updatejob(request,state=''):
    if request.method=='POST':
        islogin = request.COOKIES.get('islogin',False)
        jobid= request.POST.get('taskid','')
        username = request.COOKIES.get('username','') 
        role = request.COOKIES.get('role','1')
        response_data = {}  
        response_data['result'] = '0' 
        if role=='1':
            tempresult=jobcontrol.jobupdate(jobstatus=state,username=username,taskid=jobid)
#             print 'this is user'
        else:
            tempresult=jobcontrol.jobupdate(jobstatus=state,taskid=jobid)
        if tempresult==True:
            if state=='2':
                jobs,count,pagecount=jobcontrol.jobshow(taskid=jobid)
                if count>0:
                    tasktotally=taskcontrol.getObject()
                    if jobs[0].getForcesearch==1:


                        tasktotally.add_work(jobs)
                    else:

                        tasktotally.add_work(jobs)
                        
            response_data['result'] = '1'
        return response_data
예제 #8
0
def jobshow(request):

    islogin = request.COOKIES.get('islogin', False)
    username = request.POST.get('username', '')
    page = request.POST.get('page', '0')
    response_data = {}
    response_data['result'] = '0'
    response_data['page'] = page
    if islogin:
        response_data['result'] = '1'
        jobs, count, pagecount = jobcontrol.jobshow(username=username,
                                                    page=page)
        response_data['length'] = count
        response_data['jobs'] = jobs
        response_data['pagecount'] = pagecount
        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")
예제 #9
0
def jobshow(request):

    islogin = request.COOKIES.get('islogin',False)
    username=request.POST.get('username','')
    page=request.POST.get('page','0')
    response_data = {}  
    response_data['result'] = '0' 
    response_data['page']=page
    if islogin:
        response_data['result'] = '1' 
        jobs,count,pagecount=jobcontrol.jobshow(username=username,page=page)
        response_data['length']=count
        response_data['jobs']=jobs
        response_data['pagecount']=pagecount
        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")  
예제 #10
0
def updatejob(request, state=''):
    print(
        "==========================================================================\n======================job state:%s request.method:%s======================\n==========================================================================\n"
        % (state, request.method))
    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')
        username = request.COOKIES.get('username', '')
        role = request.COOKIES.get('role', '1')
        response_data = {}
        response_data['result'] = '0'

        ctx = {}
        ctx['islogin'] = islogin
        ctx['jobid'] = jobid
        ctx['username'] = username
        ctx['role'] = role
        ctx['state'] = state
        # return render(request, 'nmaptoolview/post.html', ctx)

        if role == '1':  # normal user
            tempresult = jobcontrol.jobupdate(jobstatus=state,
                                              username=username,
                                              taskid=jobid)
        else:
            tempresult = jobcontrol.jobupdate(jobstatus=state, taskid=jobid)

        if tempresult == True:
            if state == '2':
                jobs, count, pagecount = jobcontrol.jobshow(taskid=jobid)

                if count > 0:
                    tasktotally = taskcontrol.getObject(
                    )  # return nmaptask(sniffertask.snifferTask(1))
                    if jobs[0].getForcesearch == 1:
                        tasktotally.add_work(jobs)
                    else:
                        tasktotally.add_work(jobs)
            response_data['result'] = '1'
        return response_data
예제 #11
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")