コード例 #1
0
ファイル: taskscontrol.py プロジェクト: LubyRuffy/Scan-T
def taskshow(taskname='',tasktatus='',username='',taskid='',taskport='',result='',page='0'):

    validresult=False
    request_params=[]
    values_params=[]
    if taskname!='':
        request_params.append('tasksname')
        values_params.append(SQLTool.formatstring(taskname))
    if tasktatus!='':
        request_params.append('status')
        values_params.append(SQLTool.formatstring(tasktatus))
    if username!='':
        request_params.append('username')
        values_params.append(SQLTool.formatstring(username))
    if taskid!='':
        request_params.append('tasksid')
        values_params.append(SQLTool.formatstring(taskid))
    if taskport!='':
        request_params.append('taskport')
        values_params.append(SQLTool.formatstring(taskport))

    DBhelp=SQLTool.DBmanager()
    DBhelp.connectdb()

    table=localconfig.taskstable

    result,content,count,col=DBhelp.searchtableinfo_byparams([table], ['count(*)'], request_params, values_params)
    if count>0:
        count= int(result[0]['count(*)'])
    if count == 0:
        pagecount = 0
    elif count %limitpage> 0:

        pagecount=int((count+limitpage-1)/limitpage)


    else:
        pagecount = count / limitpage

    if pagecount>0:

        limit='    limit  '+str(int(page)*limitpage)+','+str(limitpage)
        result,content,count,col=DBhelp.searchtableinfo_byparams([table], ['username','tasksid','tasksname','status','starttime','tasksaddress','taskport','endtime','createtime','num','completenum'], request_params, values_params,limit,order='createtime desc')

        DBhelp.closedb()
        jobs=[]
        if count>0:
            validresult=True
            for temp in result :
                ajob=tasks.Tasks(username=temp['username'],tasksid=temp['tasksid'],tasksname=temp['tasksname'],taskstatus=temp['status'],starttime=temp['starttime'],taskaddress=temp['tasksaddress'],tasksport=temp['taskport'],endtime=temp['endtime'],createtime=temp['createtime'],num=temp['num'],completenum=temp['completenum'])


                jobs.append(ajob)
        return jobs,count,pagecount
    return [],0,pagecount
コード例 #2
0
ファイル: jobcontrol.py プロジェクト: v1cker/Scan-T
def jobupdate(taskid='',
              jobport='',
              jobaddress='',
              jobname='',
              priority='',
              jobstatus='',
              starttime='',
              result='',
              username='',
              finishtime=''):

    request_params = []
    values_params = []
    wset_params = []
    wand_params = []
    if starttime != '':
        request_params.append('starttime')
        values_params.append(SQLTool.formatstring(starttime))
    if finishtime != '':
        request_params.append('endtime')
        values_params.append(SQLTool.formatstring(finishtime))
    if jobaddress != '':
        request_params.append('taskaddress')
        values_params.append(jobaddress)
    if priority != '':
        request_params.append('taskprior')
        values_params.append(priority)
    if jobname != '':
        request_params.append('taskname')
        values_params.append(jobname)
    if jobstatus != '':
        request_params.append('taskstatus')
        values_params.append(jobstatus)
    if jobport != '':
        request_params.append('taskport')
        values_params.append(jobport)
    if result != '':
        request_params.append('result')
        values_params.append(result)
    if username != '':
        wset_params.append('username')
        wand_params.append(SQLTool.formatstring(username))
    if taskid != '':
        wset_params.append('taskid')
        wand_params.append(SQLTool.formatstring(taskid))
    table = localconfig.tasktable
    DBhelp = SQLTool.DBmanager()
    DBhelp.connectdb()

    tempresult = DBhelp.updatetableinfo_byparams([table], request_params,
                                                 values_params, wset_params,
                                                 wand_params)
    DBhelp.closedb()

    return tempresult
コード例 #3
0
def portadd(port):
    ip=port.getIP()
    port=port.getVendor()
    timesearch=port.getOsfamily()
    state=port.getState()
    name=port.getOsgen()
    product=port.getUpdatetime()
    version=port.getAccurate()
    script=port.getHostname()

    
    
    
    request_params=[]
    values_params=[]
    if ip!='':
        request_params.append('ip')
        values_params.append(SQLTool.formatstring(ip))
    if port!='':
        request_params.append('port')
        values_params.append(SQLTool.formatstring(port))
    if timesearch!='':
        request_params.append('timesearch')
        values_params.append(SQLTool.formatstring(timesearch))
    if state!='':
        request_params.append('state')
        values_params.append(SQLTool.formatstring(state))
    if name!='':
        request_params.append('name')
        values_params.append(SQLTool.formatstring(name))
    if product!='':
        request_params.append('product')
        values_params.append(SQLTool.formatstring(product))
    if version!='':
        request_params.append('version')
        values_params.append(SQLTool.formatstring(version))
    if script!='':
        request_params.append('script')
        values_params.append(SQLTool.formatstring(script))
    if detail!='':
        request_params.append('detail')
        values_params.append(SQLTool.formatstring(detail))  
    if head!='':
        request_params.append('head')
        values_params.append(SQLTool.formatstring(head))      
    table=localconfig.porttable
    DBhelp=SQLTool.DBmanager()
    DBhelp.connectdb()
    tempresult=None
    try:
        tempresult=DBhelp.replaceinserttableinfo_byparams(table, request_params, [tuple(values_params)])
    except Exception,e:
        print str(e)
コード例 #4
0
ファイル: jobcontrol.py プロジェクト: LubyRuffy/Scan-T
def jobupdate(taskid='',jobport='',jobaddress='',jobname='',priority='',jobstatus='',starttime='',result='',username='',finishtime='',groupid=''):


    request_params=[]
    values_params=[]
    wset_params=[]
    wand_params=[]
    if starttime!='':
        request_params.append('starttime')
        values_params.append(SQLTool.formatstring(starttime))
    if finishtime!='':
        request_params.append('endtime')
        values_params.append(SQLTool.formatstring(finishtime))
    if jobaddress!='':
        request_params.append('taskaddress')
        values_params.append(jobaddress)
    if priority!='':
        request_params.append('taskprior')
        values_params.append(priority)
    if jobname!='':
        request_params.append('taskname')
        values_params.append(jobname)
    if jobstatus!='':
        request_params.append('taskstatus')
        values_params.append(jobstatus)
    if jobport!='':
        request_params.append('taskport')
        values_params.append(jobport)
    if result!='':
        request_params.append('result')
        values_params.append(result)
    if username!='':
        wset_params.append('username')
        wand_params.append(SQLTool.formatstring(username))
    if taskid!='':
        wset_params.append('taskid')
        wand_params.append(SQLTool.formatstring(taskid))
    if groupid!='':
        wset_params.append('groupsid')
        wand_params.append(SQLTool.formatstring(str(groupid)))
    table=localconfig.tasktable

    DBhelp=SQLTool.DBmanager()
    DBhelp.connectdb()

    tempresult=DBhelp.updatetableinfo_byparams([table],request_params,values_params,wset_params,wand_params)
    DBhelp.closedb()

    return tempresult

    
    
    
コード例 #5
0
def jobshow(jobname='',jobstatus='',username='',taskid='',jobport='',result='',page='0',groupid='',jobaddress=''):
    validresult=False
    request_params=[]
    values_params=[]
    if groupid!='':
        request_params.append('groupsid')
        values_params.append(SQLTool.formatstring(groupid))
    if jobname!='':
        request_params.append('taskname')
        values_params.append(SQLTool.formatstring(jobname))
    if jobstatus!='':
        request_params.append('taskstatus')
        values_params.append(SQLTool.formatstring(jobstatus))
    if username!='':
        request_params.append('username')
        values_params.append(SQLTool.formatstring(username))
    if taskid!='':
        request_params.append('taskid')
        values_params.append(SQLTool.formatstring(taskid))
    if jobport!='':
        request_params.append('taskport')
        values_params.append(SQLTool.formatstring(jobport))

    if jobaddress!='':
        request_params.append('taskaddress')
        values_params.append(SQLTool.formatstring(jobaddress))
    DBhelp=SQLTool.DBmanager()
    DBhelp.connectdb()
    table=localconfig.tasktable
    result,content,count,col=DBhelp.searchtableinfo_byparams([table], ['count(*)'], request_params, values_params)
    if count>0:
        count= int(result[0]['count(*)'])
    if count == 0:
        pagecount = 0;
    elif count %limitpage> 0:
#         pagecount = math.ceil(count / limitpage)
        pagecount=int((count+limitpage-1)/limitpage) 


    else:
        pagecount = count / limitpage

#     print pagecount
    if pagecount>0:
    
        limit='    limit  '+str(int(page)*limitpage)+','+str(limitpage)
        result,content,count,col=DBhelp.searchtableinfo_byparams([table], ['username','taskid','taskname','taskprior','taskstatus','starttime','taskaddress','taskport','result','endtime','createtime','forcesearch','groupsid'], request_params, values_params,limit,order='createtime desc')
    
        DBhelp.closedb()
        jobs=[]
        if count>0:
            validresult=True
            for temp in result :
                ajob=job.Job(username=temp['username'],jobid=temp['taskid'],jobname=temp['taskname'],priority=temp['taskprior'],jobstatus=temp['taskstatus'],starttime=temp['starttime'],jobaddress=temp['taskaddress'],jobport=temp['taskport'],result=temp['result'],endtime=temp['endtime'],createtime=temp['createtime'],forcesearch=temp['forcesearch'],groupsid=temp['groupsid'])

#                 ajob=job.Job(username=temp[0],jobid=temp[1],jobname=temp[2],priority=temp[3],jobstatus=temp[4],starttime=temp[5],jobaddress=temp[6],jobport=temp[7],result=temp[8],endtime=temp[9],createtime=temp[10],forcesearch=temp[11])
                jobs.append(ajob)
        return jobs,count,pagecount
    return [],0,pagecount
コード例 #6
0
ファイル: ipcontrol.py プロジェクト: WinneShen/toolforspider
def ipshow(ip='',vendor='',osfamily='',osgen='',accurate='',updatetime='',hostname='',state='',page='0'):
    validresult=False
    request_params=[]
    values_params=[]
    if ip!='':
        request_params.append('ip')
        values_params.append(SQLTool.formatstring(ip))
    if vendor!='':
        request_params.append('vendor')
        values_params.append(SQLTool.formatstring(vendor))
    if osfamily!='':
        request_params.append('osfamily')
        values_params.append(SQLTool.formatstring(osfamily))
    if osgen!='':
        request_params.append('osgen')
        values_params.append(SQLTool.formatstring(osgen))
    if accurate!='':
        request_params.append('accurate')
        values_params.append(SQLTool.formatstring(accurate))
    if updatetime!='':
        request_params.append('updatetime')
        values_params.append(SQLTool.formatstring(updatetime))
    if hostname!='':
        request_params.append('hostname')
        values_params.append(SQLTool.formatstring(hostname))
    if state!='':
        request_params.append('state')
        values_params.append(SQLTool.formatstring(state))
    DBhelp=SQLTool.DBmanager()
    DBhelp.connectdb()
    table=localconfig.iptable
    result,content,count,col=DBhelp.searchtableinfo_byparams([table], ['ip','vendor','osfamily','osgen','accurate','updatetime','hostname','state'], request_params, values_params)

    if count == 0:
        pagecount = 0;
    elif count %limitpage> 0:
#         pagecount = math.ceil(count / limitpage)
        pagecount=int((count+limitpage-1)/limitpage) 


    else:
        pagecount = count / limitpage

#     print pagecount
    if pagecount>0:
    
        limit='    limit  '+str(int(page)*limitpage)+','+str(limitpage)
        result,content,count,col=DBhelp.searchtableinfo_byparams([table], ['ip','vendor','osfamily','osgen','accurate','updatetime','hostname','state'], request_params, values_params,limit,order='updatetime desc')
    
        DBhelp.closedb()
        ips=[]
        if count>0:
            validresult=True
            for temp in result :
                aip=ipmain.Ip(ip=temp['ip'],vendor=temp['vendor'],osfamily=temp['osfamily'],osgen=temp['osgen'],accurate=temp['accurate'],updatetime=temp['updatetime'],hostname=temp['hostname'],state=temp['state'])
#                 aip=ipmain.Ip(ip=temp[0],vendor=temp[1],osfamily=temp[2],osgen=temp[3],accurate=temp[4],updatetime=temp[5],hostname=temp[6],state=temp[7])
                ips.append(aip)
        return ips,count,pagecount
    return [],0,pagecount
コード例 #7
0
def storedata(ip='',port='',hackinfo=None):
    sqlTool=Sqldatatask.getObject()
    localtime=str(time.strftime("%Y-%m-%d %X", time.localtime()))
    insertdata=[]
#     if islocalwork==0:
#         work=[]
#         dic={"table":config.Config.iptable,"select_params": ['ip','vendor','osfamily','osgen','accurate','updatetime','hostname','state'],"insert_values": [(temphosts,tempvendor,temposfamily,temposgen,tempaccuracy,localtime,temphostname,tempstate)]}
#         tempdata={"func":'replaceinserttableinfo_byparams',"dic":dic}
#         jsondata=uploaditem.UploadData(url=self.webconfig.upload_ip_info,way='POST',params=tempdata)
#         work.append(jsondata)
#         self.uploadwork.add_work(work)
                    
#     else:

    hackinfo=SQLTool.escapewordby(str(hackinfo))
    extra=' on duplicate key update  hackinfo=\''+hackinfo+'\' , timesearch=\''+localtime+'\''
             
    insertdata.append((str(ip),port,hackinfo,str(port)))
 
 
    sqldatawprk=[]
    dic={"table":config.Config.porttable,"select_params":['ip','port','hackinfo','portnumber'],"insert_values":insertdata,"extra":extra}
                
    tempwprk=Sqldata.SqlData('inserttableinfo_byparams',dic)
    sqldatawprk.append(tempwprk)
    sqlTool.add_work(sqldatawprk)   
    pass
コード例 #8
0
ファイル: callbackfuzz.py プロジェクト: roottime/normal_hack
def storedata(ip='',port='',hackinfo=None):

    sqlTool=Sqldatatask.getObject()
    localtime=str(time.strftime("%Y-%m-%d %X", time.localtime()))
    insertdata=[]
     
    hackinfo=SQLTool.escapewordby(str(hackinfo))
    extra=' on duplicate key update  disclosure=\''+hackinfo+'\' , timesearch=\''+localtime+'\''
              
    insertdata.append((str(ip),port,hackinfo,str(port)))
    dic={"table":config.Config.porttable,"select_params":['ip','port','disclosure','portnumber'],"insert_values":insertdata,"extra":extra}

    if islocalwork==0:
        work=[]
        tempdata={"func":'inserttableinfo_byparams',"dic":dic}
        jsondata=uploaditem.UploadData(url=webconfig.WebConfig.upload_ip_info,way='POST',params=tempdata)
        work.append(jsondata)
        temp=uploadtask.getObject()
        temp.add_work(work)

                      
    else:

  
  
        sqldatawprk=[]
                 
        tempwprk=Sqldata.SqlData(func='inserttableinfo_byparams',dic)
        sqldatawprk.append(tempwprk)
        sqlTool.add_work(sqldatawprk)   
        print 'fuzz 数据存储'
        pass
コード例 #9
0
def storedata(ip='', port='', hackinfo=None):

    sqlTool = Sqldatatask.getObject()
    localtime = str(time.strftime("%Y-%m-%d %X", time.localtime()))
    insertdata = []
    #     if islocalwork==0:
    #         work=[]
    #         dic={"table":config.Config.iptable,"select_params": ['ip','vendor','osfamily','osgen','accurate','updatetime','hostname','state'],"insert_values": [(temphosts,tempvendor,temposfamily,temposgen,tempaccuracy,localtime,temphostname,tempstate)]}
    #         tempdata={"func":'replaceinserttableinfo_byparams',"dic":dic}
    #         jsondata=uploaditem.UploadData(url=self.webconfig.upload_ip_info,way='POST',params=tempdata)
    #         work.append(jsondata)
    #         self.uploadwork.add_work(work)

    #     else:

    hackinfo = SQLTool.escapewordby(str(hackinfo))
    extra = ' on duplicate key update  disclosure=\'' + hackinfo + '\' , timesearch=\'' + localtime + '\''

    insertdata.append((str(ip), port, hackinfo, str(port)))

    sqldatawprk = []
    dic = {
        "table": config.Config.porttable,
        "select_params": ['ip', 'port', 'disclosure', 'portnumber'],
        "insert_values": insertdata,
        "extra": extra
    }

    tempwprk = Sqldata.SqlData('inserttableinfo_byparams', dic)
    sqldatawprk.append(tempwprk)
    sqlTool.add_work(sqldatawprk)
    print 'fuzz 数据存储'
    pass
コード例 #10
0
ファイル: jobcontrol.py プロジェクト: v1cker/Scan-T
def jobadd(job):
    jobname = job.getJobname()
    jobaddress = job.getJobaddress()
    jobport = job.getPort()
    priority = job.getPriority()
    jobstatus = job.getStatus()
    username = job.getUsername()
    starttime = job.getStarttime()
    createtime = job.getCreatetime()
    taskid = job.getJobid()
    result = job.getResult()
    forcesearch = job.getForcesearch()
    print 'forcesearch is' + forcesearch
    request_params = []
    values_params = []
    if createtime != '':
        request_params.append('createtime')
        values_params.append(createtime)
    if starttime != '':
        request_params.append('starttime')
        values_params.append(starttime)
    if jobaddress != '':
        request_params.append('taskaddress')
        values_params.append(jobaddress)
    if priority != '':
        request_params.append('taskprior')
        values_params.append(priority)
    if jobname != '':
        request_params.append('taskname')
        values_params.append(jobname)
    if jobstatus != '':
        request_params.append('taskstatus')
        values_params.append(jobstatus)
    if username != '':
        request_params.append('username')
        values_params.append(username)
    if taskid != '':
        request_params.append('taskid')
        values_params.append(taskid)
    if jobport != '':
        request_params.append('taskport')
        values_params.append(jobport)
    if result != '':
        request_params.append('result')
        values_params.append(result)
    if forcesearch != '':
        request_params.append('forcesearch')
        values_params.append(forcesearch)
    table = localconfig.tasktable
    DBhelp = SQLTool.DBmanager()
    DBhelp.connectdb()

    tempresult = DBhelp.inserttableinfo_byparams(
        table=table,
        select_params=request_params,
        insert_values=[tuple(values_params)])

    DBhelp.closedb()

    return tempresult
コード例 #11
0
def validuser(username, password):
    validresult = False
    DBhelp = SQLTool.DBmanager()
    DBhelp.connectdb()
    result, content, count, col = DBhelp.searchtableinfo_byparams(
        [localconfig.usertable], ['username', 'role', 'userpower'],
        ['username', 'password'],
        [SQLTool.formatstring(username),
         SQLTool.formatstring(password)])
    DBhelp.closedb()
    role = ''
    userpower = ''
    if col > 0:

        validresult = True
        role = result[0]['role']
        userpower = result[0]['userpower']
#         role=result[0][1]
#         userpower=result[0][2]
    return validresult, username, role, userpower
コード例 #12
0
def portshow(ip='',port='',timesearch='',state='',name='',product='',version='',script='',detail='',page='0',extra='',command='and'):
    validresult=False
    request_params=[]
    values_params=[]
    if ip!='':
        request_params.append('ip')
        values_params.append(SQLTool.formatstring(ip))
    if port!='':
        request_params.append('port')
        values_params.append(SQLTool.formatstring(port))
    if timesearch!='':
        request_params.append('timesearch')
        values_params.append(SQLTool.formatstring(timesearch))
    if state!='':
        request_params.append('state')
        values_params.append(SQLTool.formatstring(state))
    if name!='':
        request_params.append('name')
        values_params.append(SQLTool.formatstring(name))
    if product!='':
        request_params.append('product')
        values_params.append(SQLTool.formatstring(product))
    if version!='':
        request_params.append('version')
        values_params.append(SQLTool.formatstring(version))
    if script!='':
        request_params.append('script')
        values_params.append(SQLTool.formatstring(script))
    if detail!='':
        request_params.append('detail')
        values_params.append(SQLTool.formatstring(detail))
    global DBhelp
    DBhelp=SQLTool.DBmanager()
    DBhelp.connectdb()
    localconfig=config.Config()
    table=localconfig.porttable
    content=None
    result=None
    try:
        result,content,count,col=DBhelp.searchtableinfo_byparams([table], ['ip','port','timesearch','state','name','product','version','script','detail'], request_params, values_params,extra=extra,command=command)
    except Exception,e:
        print str(e)+'portcontrol 50'
        if DBhelp is not None:
            DBhelp.closedb()
            DBhelp=None
        return [],0,0
コード例 #13
0
def addtask(job):
    jobname = job.getTasksname()    #NOT NULL
    jobaddress = job.getTaskaddress()   #NOT NULL
    jobport = job.getPort()

    jobstatus = job.getStatus()
    username = job.getUsername()
    starttime = job.getStarttime()
    createtime = job.getCreatetime()
    taskid = job.getTasksid()
    jobargument = job.getArgument()

    request_params = []
    values_params = []

    if createtime != '':
        request_params.append('createtime')
        values_params.append(createtime)
    if starttime != '':
        request_params.append('starttime')
        values_params.append(starttime)
    if jobaddress != '':
        request_params.append('tasksaddress')
        values_params.append(jobaddress)
    if jobname != '':
        request_params.append('tasksname')
        values_params.append(jobname)
    if jobstatus != '':
        request_params.append('status')
        values_params.append(jobstatus)
    if username != '':
        request_params.append('username')
        values_params.append(username)
    if taskid != '':
        request_params.append('tasksid')
        values_params.append(taskid)
    if jobargument != '':
    	request_params.append('tasksargument')
	values_params.append(jobargument)

    # 一定有这个字段,无需判断?
    request_params.append('taskport')
    values_params.append(jobport)

    table = localconfig.taskstable
    DBhelp = SQLTool.DBmanager()
    DBhelp.connectdb()

    tempresult = DBhelp.inserttableinfo_byparams(table=table, select_params = request_params,insert_values= [tuple(values_params)])

    DBhelp.closedb()

    return tempresult
コード例 #14
0
def divided(ports,params='port'):
    if ports=='':
        return ''
    sql='   and  ( '
    array=ports.split(',')
    
    for i in range(len(array)-1):
        resulto=re.match(r"^(\d*)\-(\d*)$",array[i]) 
        if resulto:  
            p = re.compile(r'\d+')
            list= p.findall(array[i])
            sql+=params+'  between '+SQLTool.formatstring(list[0])+' and  '+ SQLTool.formatstring(list[1])+' or '
                
        else:
            p = re.compile(r'\d+$')
            list= p.findall(array[i])
            sql+=params+'  ='+SQLTool.formatstring(list[0])+' or '
    temp=array[len(array)-1]
    resulto=re.match(r"^(\d*)\-(\d*)$",temp) 
    if resulto:  
        p = re.compile(r'\d+')
        list= p.findall(temp)
        sql+=params+'  between '+SQLTool.formatstring(list[0])+' and  '+ SQLTool.formatstring(list[1])+')   '
                
    else:
        p = re.compile(r'\d+$')
        list= p.findall(temp)
        sql+=params+'  ='+SQLTool.formatstring(list[0])+' )    '
    return sql
コード例 #15
0
def divided(ports, params='port'):
    if ports == '':
        return ''
    sql = '   and  ( '
    array = ports.split(',')

    for i in range(len(array) - 1):
        resulto = re.match(r"^(\d*)\-(\d*)$", array[i])
        if resulto:
            p = re.compile(r'\d+')
            list = p.findall(array[i])
            sql += params + '  between ' + SQLTool.formatstring(
                list[0]) + ' and  ' + SQLTool.formatstring(list[1]) + ' or '

        else:
            p = re.compile(r'\d+$')
            list = p.findall(array[i])
            sql += params + '  =' + SQLTool.formatstring(list[0]) + ' or '
    temp = array[len(array) - 1]
    resulto = re.match(r"^(\d*)\-(\d*)$", temp)
    if resulto:
        p = re.compile(r'\d+')
        list = p.findall(temp)
        sql += params + '  between ' + SQLTool.formatstring(
            list[0]) + ' and  ' + SQLTool.formatstring(list[1]) + ')   '

    else:
        p = re.compile(r'\d+$')
        list = p.findall(temp)
        sql += params + '  =' + SQLTool.formatstring(list[0]) + ' )    '
    return sql
コード例 #16
0
ファイル: mapcontrol.py プロジェクト: nanshihui/Scan-T
def mapshow(ip='',port='',state='',name='',product='',version='',searchcontent='',isdic=1):
    localconfig=config.Config()
    table=localconfig.porttable
    iptable=localconfig.iptable
    validresult=False
    request_params=[]
    values_params=[]

    if ip!='':
        request_params.append(table+'.'+'ip')
        values_params.append(SQLTool.formatstring(ip))
    if port!='':
        request_params.append('port')
        values_params.append(SQLTool.formatstring(port))

    if state!='':
        request_params.append(table+'.'+'state')
        values_params.append(SQLTool.formatstring(state))
    if name!='':
        request_params.append('name')
        values_params.append(SQLTool.formatstring(name))
    if product!='':
        request_params.append('product')
        values_params.append(SQLTool.formatstring(product))
    if version!='':
        request_params.append('version')
        values_params.append(SQLTool.formatstring(version))

    global DBhelp

    DBhelp=SQLTool.DBmanager()
    DBhelp.connectdb()
    size = 0
    content=None
    result=None
    sql=""""""
    if isdic==0:
        if searchcontent =='':
            sql="""SELECT city, COUNT(*) FROM ip_maindata  GROUP BY city"""
        else:
            sql="""SELECT city, COUNT(*) FROM (SELECT ip AS ipitem FROM snifferdata WHERE MATCH (version , product , head , detail , script , hackinfo , disclosure , keywords) AGAINST ('%s' IN BOOLEAN MODE)
    GROUP BY ip) AS iptable LEFT JOIN ip_maindata ON ipitem = ip_maindata.ip GROUP BY city""" %(searchcontent)
    else:
        sql="""SELECT city, COUNT(*) FROM (SELECT ip AS ipitem FROM snifferdata WHERE  """
        request_params_length=len(request_params)
        for k in range(0, request_params_length - 1):
            sql = sql + request_params[k] + ' = ' + values_params[k] +' and '
        sql = sql + request_params[request_params_length - 1] + ' = ' + values_params[request_params_length - 1] + '  '

        sql = sql + """ GROUP BY ip) AS iptable LEFT JOIN ip_maindata ON ipitem = ip_maindata.ip GROUP BY city """
    try:
         result,content,count,col=DBhelp.searchtableinfo_byparams(table=sql,usesql=1)
    except Exception,e:
         print str(e)+'portcontrol 69'
         if DBhelp is not None:
             DBhelp.closedb()
         return [],0,0
コード例 #17
0
def ipadd(ip):
    nowip = ip.getIP()
    vendor = ip.getVendor()
    osfamily = ip.getOsfamily()
    state = ip.getState()
    osgen = ip.getOsgen()
    updatetime = ip.getUpdatetime()
    accurate = ip.getAccurate()
    hostname = ip.getHostname()

    request_params = []
    values_params = []
    if nowip != '':
        request_params.append('ip')
        values_params.append(nowip)
    if vendor != '':
        request_params.append('vendor')
        values_params.append(vendor)
    if osfamily != '':
        request_params.append('osfamily')
        values_params.append(osfamily)
    if state != '':
        request_params.append('state')
        values_params.append(state)
    if osgen != '':
        request_params.append('osgen')
        values_params.append(osgen)
    if updatetime != '':
        request_params.append('updatetime')
        values_params.append(updatetime)
    if accurate != '':
        request_params.append('accurate')
        values_params.append(accurate)
    if hostname != '':
        request_params.append('hostname')
        values_params.append(hostname)
    if city != '':
        request_params.append('city')
        values_params.append(city)
    table = localconfig.iptable
    DBhelp = SQLTool.DBmanager()
    DBhelp.connectdb()

    tempresult = DBhelp.replaceinserttableinfo_byparams(
        table, request_params, [tuple(values_params)])
    DBhelp.closedb()

    return tempresult
コード例 #18
0
ファイル: jobcontrol.py プロジェクト: 0x-Jin/toolforspider
def jobshow(jobname='',jobstatus='',username='',taskid='',jobport='',result='',page='0'):
    validresult=False
    request_params=[]
    values_params=[]
    if jobname!='':
        request_params.append('taskname')
        values_params.append(SQLTool.formatstring(jobname))
    if jobstatus!='':
        request_params.append('taskstatus')
        values_params.append(SQLTool.formatstring(jobstatus))
    if username!='':
        request_params.append('username')
        values_params.append(SQLTool.formatstring(username))
    if taskid!='':
        request_params.append('taskid')
        values_params.append(SQLTool.formatstring(taskid))
    if jobport!='':
        request_params.append('taskport')
        values_params.append(SQLTool.formatstring(jobport))
    if result!='':
        request_params.append('result')
        values_params.append(SQLTool.formatstring(result))
    DBhelp=SQLTool.DBmanager()
    DBhelp.connectdb()
    table=localconfig.tasktable
    result,content,count,col=DBhelp.searchtableinfo_byparams([table], ['count(*)'], request_params, values_params)
    if count>0:
        count= int(result[0]['count(*)'])
    if count == 0:
        pagecount = 0;
    elif count %limitpage> 0:
#         pagecount = math.ceil(count / limitpage)
        pagecount=int((count+limitpage-1)/limitpage) 


    else:
        pagecount = count / limitpage

#     print pagecount
    if pagecount>0:
    
        limit='    limit  '+str(int(page)*limitpage)+','+str(limitpage)
        result,content,count,col=DBhelp.searchtableinfo_byparams([table], ['username','taskid','taskname','taskprior','taskstatus','starttime','taskaddress','taskport','result','endtime','createtime','forcesearch'], request_params, values_params,limit,order='createtime desc')
    
        DBhelp.closedb()
        jobs=[]
        if count>0:
            validresult=True
            for temp in result :
                ajob=job.Job(username=temp['username'],jobid=temp['taskid'],jobname=temp['taskname'],priority=temp['taskprior'],jobstatus=temp['taskstatus'],starttime=temp['starttime'],jobaddress=temp['taskaddress'],jobport=temp['taskport'],result=temp['result'],endtime=temp['endtime'],createtime=temp['createtime'],forcesearch=temp['forcesearch'])

#                 ajob=job.Job(username=temp[0],jobid=temp[1],jobname=temp[2],priority=temp[3],jobstatus=temp[4],starttime=temp[5],jobaddress=temp[6],jobport=temp[7],result=temp[8],endtime=temp[9],createtime=temp[10],forcesearch=temp[11])
                jobs.append(ajob)
        return jobs,count,pagecount
    return [],0,pagecount
コード例 #19
0
def taskshow(taskname='',tasktatus='',username='',taskid='',taskport='',result='',page='0'):

    validresult=False
    request_params=[]
    values_params=[]
    if taskname!='':
        request_params.append('tasksname')
        values_params.append(SQLTool.formatstring(taskname))
    if tasktatus!='':
        request_params.append('status')
        values_params.append(SQLTool.formatstring(tasktatus))
    if username!='':
        request_params.append('username')
        values_params.append(SQLTool.formatstring(username))
    if taskid!='':
        request_params.append('tasksid')
        values_params.append(SQLTool.formatstring(taskid))
    if taskport!='':
        request_params.append('taskport')
        values_params.append(SQLTool.formatstring(taskport))

    DBhelp=SQLTool.DBmanager()
    DBhelp.connectdb()

    table=localconfig.taskstable

    result,content,count,col=DBhelp.searchtableinfo_byparams([table], ['count(*)'], request_params, values_params)
    if count>0:
        count= int(result[0]['count(*)'])
    if count == 0:
        pagecount = 0
    elif count %limitpage> 0:

        pagecount=int((count+limitpage-1)/limitpage)


    else:
        pagecount = count / limitpage

    if pagecount>0:

        limit='    limit  '+str(int(page)*limitpage)+','+str(limitpage)
        result,content,count,col=DBhelp.searchtableinfo_byparams([table], ['username','tasksid','tasksname','status','starttime','tasksaddress','taskport','endtime','createtime','num','completenum'], request_params, values_params,limit,order='createtime desc')

        DBhelp.closedb()
        jobs=[]
        if count>0:
            validresult=True
            for temp in result :
                ajob=tasks.Tasks(username=temp['username'],tasksid=temp['tasksid'],tasksname=temp['tasksname'],taskstatus=temp['status'],starttime=temp['starttime'],taskaddress=temp['tasksaddress'],tasksport=temp['taskport'],endtime=temp['endtime'],createtime=temp['createtime'],num=temp['num'],completenum=temp['completenum'])


                jobs.append(ajob)
        return jobs,count,pagecount
    return [],0,pagecount
コード例 #20
0
def validuser(username,password):
    validresult=False
    DBhelp=SQLTool.DBmanager()
    DBhelp.connectdb()
	# result = sql's result; ({'username': '******', 'role': '3', 'userpower': '3'},) 
	# content = sql's some content, don't know what it is to use
	# conunt = result's count; col = 第二个参数的个数
    result, content, count, col=DBhelp.searchtableinfo_byparams([localconfig.usertable], ['username','role','userpower'], ['username','password'], [SQLTool.formatstring(username),SQLTool.formatstring(password)], order='username desc')
    DBhelp.closedb()
    role = ''
    userpower = ''
    if col > 0:
        validresult = True
        role = result[0]['role']
        userpower = result[0]['userpower']
#         role=result[0][1]
#         userpower=result[0][2]
    return validresult, username, role, userpower
コード例 #21
0
def storedata(ip='', port='', hackresults=None):
    sqlTool = Sqldatatask.getObject()
    localtime = str(time.strftime("%Y-%m-%d %X", time.localtime()))
    insertdata = []
    hackresults = SQLTool.escapewordby(str(hackresults))
    extra = ' on duplicate key update hackresults=\'' + hackresults + '\' , timesearch=\'' + localtime + '\''

    insertdata.append((str(ip), port, hackresults, str(port)))

    sqldatawprk = []
    dic = {
        "table": config.Config.porttable,
        "select_params": ['ip', 'port', 'hackresults', 'portnumber'],
        "insert_values": insertdata,
        "extra": extra
    }

    tempwprk = Sqldata.SqlData('inserttableinfo_byparams', dic)
    sqldatawprk.append(tempwprk)
    sqlTool.add_work(sqldatawprk)
    pass
コード例 #22
0
ファイル: callbackfuzz.py プロジェクト: the-404/normal_hack
def storedata(ip='', port='', hackinfo=None):

    sqlTool = Sqldatatask.getObject()
    localtime = str(time.strftime("%Y-%m-%d %X", time.localtime()))
    insertdata = []

    hackinfo = SQLTool.escapewordby(str(hackinfo))
    extra = ' on duplicate key update  disclosure=\'' + hackinfo + '\' , timesearch=\'' + localtime + '\''

    insertdata.append((str(ip), port, hackinfo, str(port)))
    dic = {
        "table": config.Config.porttable,
        "select_params": ['ip', 'port', 'disclosure', 'portnumber'],
        "insert_values": insertdata,
        "extra": extra
    }

    if islocalwork == 0:
        work = []
        tempdata = {"func": 'inserttableinfo_byparams', "dic": dic}
        jsondata = uploaditem.UploadData(
            url=webconfig.WebConfig.upload_ip_info,
            way='POST',
            params=tempdata)
        work.append(jsondata)
        temp = uploadtask.getObject()
        temp.add_work(work)

    else:

        sqldatawprk = []

        tempwprk = Sqldata.SqlData('inserttableinfo_byparams', dic)
        sqldatawprk.append(tempwprk)
        sqlTool.add_work(sqldatawprk)
        print 'fuzz 数据存储'
        pass
コード例 #23
0
def storedata(ip='', port='', disclosures=None):
    sqlTool = Sqldatatask.getObject()
    localtime = str(time.strftime("%Y-%m-%d %X", time.localtime()))
    insertdata = []
    # {'223.223.187.90:8080': [{'status': 200, 'url': '223.223.187.90:8080/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/etc/passwd'}, {'status': 200, 'url': '223.223.187.90:8080/file/Placard/upload/Imo_DownLoadUI.php?cid=1&uid=1&type=1&filename=/../../../../etc/passwd'}, {'status': 200, 'url': '223.223.187.90:8080/resin-doc/resource/tutorial/jndi-appconfig/test?inputFile=/etc/passwd'}, {'status': 200, 'url': '223.223.187.90:8080/wp-config.php~'}, {'status': 200, 'url': '223.223.187.90:8080/'}]}
    # 现在是依次遍历list集合拼接,是否可以直接返回list集合,像hackresults一样
    disclosure = ''
    # for ip_port in disclosures:
    # 	disinfo_list = disclosures[ip_port]
    # for disinfo in disinfo_list:
    #     disclosure += str(disinfo) + '\\n '
    #	    disinfo_list.remove(disinfo)

    #    print "fuzzey detect callbackfuzz: ", type(disclosures), str(disclosures)   # a dict
    disclosure = SQLTool.escapewordby(str(disclosures))
    extra = ' on duplicate key update  disclosure=\'' + disclosure + '\' , timesearch=\'' + localtime + '\''

    insertdata.append((str(ip), port, disclosure, str(port)))

    sqldatawprk = []
    dic = {
        "table": config.Config.porttable,
        "select_params": ['ip', 'port', 'disclosure', 'portnumber'],
        "insert_values": insertdata,
        "extra": extra
    }

    tempwprk = Sqldata.SqlData('inserttableinfo_byparams', dic)
    sqldatawprk.append(tempwprk)
    sqlTool.add_work(sqldatawprk)

    from ..vuldect import pocsearchtask
    temp = pocsearchtask.getObject()
    # head,context,ip,port,productname,keywords,nmapscript,protocol
    temp.add_work([(None, None, ip, port, None, None, disclosures, None)])
    pass
コード例 #24
0
ファイル: portcontrol.py プロジェクト: he1m4n6a/toolforspider
            result,content,count,col=DBhelp.searchtableinfo_byparams([table+' left join ip_maindata on snifferdata.ip=ip_maindata.ip'], [table+'.'+'ip','port','timesearch',table+'.'+'state','name','product','version','script','detail','head','city','hackinfo','disclosure'], request_params, values_params,limit=limit,order=table+'.'+'port',extra=extra,command=command)
        except Exception,e:
            print str(e)+'portcontrol 69'
            if DBhelp is not None:
                DBhelp.closedb()
            return [],0,0
        if DBhelp is not None:
                DBhelp.closedb()
                DBhelp=None
            

        portarray=[]
        if count>0:
            validresult=True
            for temp in result :
                aport=ports.Port(ip=temp['ip'],port=temp['port'],timesearch=temp['timesearch'],state=temp['state'],name=temp['name'],product=temp['product'],version=temp['version'],script=SQLTool.decodestring(temp['script']),detail=SQLTool.decodestring(temp['detail']),head=SQLTool.decodestring(temp['head']),city=temp['city'],hackinfo=SQLTool.decodestring(temp['hackinfo']),disclosure=SQLTool.decodestring(temp['disclosure']))

#                 aport=ports.Port(ip=temp[0],port=temp[1],timesearch=temp[2],state=temp[3],name=temp[4],product=temp[5],version=temp[6],script=temp[7])
                portarray.append(aport)
        print str(count)+'          '+str(pagecount)
        return portarray,count,pagecount
    return [],0,pagecount
def portshow(ip='',port='',timesearch='',state='',name='',product='',version='',script='',detail='',page='0',extra='',command='and',head='',city=''):
    validresult=False
    request_params=[]
    values_params=[]
    if ip!='':
        request_params.append('ip')
        values_params.append(SQLTool.formatstring(ip))
    if port!='':
        request_params.append('port')
コード例 #25
0
        except Exception,e:
            print str(e)+'portcontrol 69'
            if DBhelp is not None:
                DBhelp.closedb()
            return [],0,0
        if DBhelp is not None:
                DBhelp.closedb()
                DBhelp=None
            

        portarray=[]
        if count>0:
            validresult=True
            import  base64
            for temp in result :
                aport=ports.Port(ip=temp['ip'],port=temp['port'],timesearch=temp['timesearch'],state=temp['state'],name=temp['name'],product=temp['product'],version=temp['version'],script=base64.b64encode(SQLTool.getdecodeproperty(temp,'script')),detail=SQLTool.getdecodeproperty(temp,'detail'),head=SQLTool.getdecodeproperty(temp,'head'),city=temp['city'],hackinfo=SQLTool.getdecodeproperty(temp,'hackinfo'),disclosure=SQLTool.getdecodeproperty(temp,'disclosure'))

#                 aport=ports.Port(ip=temp[0],port=temp[1],timesearch=temp[2],state=temp[3],name=temp[4],product=temp[5],version=temp[6],script=temp[7])
                portarray.append(aport)
        print str(count)+'          '+str(pagecount)
        return portarray,count,pagecount
    return [],0,pagecount
def portshow(ip='',port='',timesearch='',state='',name='',product='',version='',script='',detail='',page='0',extra='',command='and',head='',city='',order='port'):
    validresult=False
    request_params=[]
    values_params=[]
    if ip!='':
        request_params.append('ip')
        values_params.append(SQLTool.formatstring(ip))
    if port!='':
        request_params.append('port')
コード例 #26
0
def mapshow(ip='',
            port='',
            state='',
            name='',
            product='',
            version='',
            searchcontent='',
            isdic=1):
    localconfig = config.Config()
    table = localconfig.porttable
    iptable = localconfig.iptable
    validresult = False
    request_params = []
    values_params = []

    if ip != '':
        request_params.append(table + '.' + 'ip')
        values_params.append(SQLTool.formatstring(ip))
    if port != '':
        request_params.append('port')
        values_params.append(SQLTool.formatstring(port))

    if state != '':
        request_params.append(table + '.' + 'state')
        values_params.append(SQLTool.formatstring(state))
    if name != '':
        request_params.append('name')
        values_params.append(SQLTool.formatstring(name))
    if product != '':
        request_params.append('product')
        values_params.append(SQLTool.formatstring(product))
    if version != '':
        request_params.append('version')
        values_params.append(SQLTool.formatstring(version))

    global DBhelp

    DBhelp = SQLTool.DBmanager()
    DBhelp.connectdb()
    size = 0
    content = None
    result = None
    sql = """"""
    if isdic == 0:
        if searchcontent == '':
            sql = """SELECT city, COUNT(*) FROM ip_maindata  GROUP BY city"""
        else:
            sql = """SELECT city, COUNT(*) FROM (SELECT ip AS ipitem FROM snifferdata WHERE MATCH (version , product , head , detail , script , hackinfo , disclosure , keywords) AGAINST ('%s' IN BOOLEAN MODE)
    GROUP BY ip) AS iptable LEFT JOIN ip_maindata ON ipitem = ip_maindata.ip GROUP BY city""" % (
                searchcontent)
    else:
        sql = """SELECT city, COUNT(*) FROM (SELECT ip AS ipitem FROM snifferdata WHERE  """
        request_params_length = len(request_params)
        for k in range(0, request_params_length - 1):
            sql = sql + request_params[k] + ' = ' + values_params[k] + ' and '
        sql = sql + request_params[request_params_length -
                                   1] + ' = ' + values_params[
                                       request_params_length - 1] + '  '

        sql = sql + """ GROUP BY ip) AS iptable LEFT JOIN ip_maindata ON ipitem = ip_maindata.ip GROUP BY city """
    try:
        result, content, count, col = DBhelp.searchtableinfo_byparams(
            table=sql, usesql=1)
    except Exception, e:
        print str(e) + 'portcontrol 69'
        if DBhelp is not None:
            DBhelp.closedb()
        return [], 0, 0
コード例 #27
0
def portabstractshow(ip='',
                     port='',
                     timesearch='',
                     state='',
                     name='',
                     product='',
                     version='',
                     script='',
                     detail='',
                     page='0',
                     extra='',
                     command='and',
                     head='',
                     city='',
                     hackresults='',
                     disclosure=''):
    localconfig = config.Config()
    port_table = localconfig.porttable  #snifferdata
    ip_table = localconfig.iptable  #ip_maindata
    validresult = False
    request_params = []
    values_params = []

    if ip != '':
        request_params.append(port_table + '.' + 'ip')
        values_params.append(SQLTool.formatstring(ip))
    if port != '':
        request_params.append('port')
        values_params.append(SQLTool.formatstring(port))
    if timesearch != '':
        request_params.append('timesearch')
        values_params.append(SQLTool.formatstring(timesearch))
    if state != '':
        request_params.append(port_table + '.' + 'state')
        values_params.append(SQLTool.formatstring(state))
    if name != '':
        request_params.append('name')
        values_params.append(SQLTool.formatstring(name))
    if product != '':
        request_params.append('product')
        values_params.append(SQLTool.formatstring(product))
    if version != '':
        request_params.append('version')
        values_params.append(SQLTool.formatstring(version))
    if script != '':
        request_params.append('script')
        values_params.append(SQLTool.formatstring(script))
    if detail != '':
        request_params.append('detail')
        values_params.append(SQLTool.formatstring(detail))
    if head != '':
        request_params.append('head')
        values_params.append(SQLTool.formatstring(head))
    if city != '':
        request_params.append('city')
        values_params.append(SQLTool.formatstring(city))
    global DBhelp

    DBhelp = SQLTool.DBmanager()
    DBhelp.connectdb()

    content = None
    result = None
    try:
        result, content, count, col = DBhelp.searchtableinfo_byparams(
            [
                port_table + ' left join ' + ip_table + ' on ' + port_table +
                '.ip=' + ip_table + '.ip'
            ], ['count(*)'],
            request_params,
            values_params,
            extra=extra,
            command=command)
    except Exception, e:
        print "portcontrol::portabstractshow() 62::", str(e)
        if DBhelp is not None:
            DBhelp.closedb()
            DBhelp = None
        return [], 0, 0
コード例 #28
0
def portadd(port):
    ip = port.getIP()
    port = port.getVendor()
    timesearch = port.getOsfamily()
    state = port.getState()
    name = port.getOsgen()
    product = port.getUpdatetime()
    version = port.getAccurate()
    script = port.getHostname()

    request_params = []
    values_params = []
    if ip != '':
        request_params.append('ip')
        values_params.append(SQLTool.formatstring(ip))
    if port != '':
        request_params.append('port')
        values_params.append(SQLTool.formatstring(port))
        request_params.append('portnumber')
        values_params.append(SQLTool.formatstring(port))
    if timesearch != '':
        request_params.append('timesearch')
        values_params.append(SQLTool.formatstring(timesearch))
    if state != '':
        request_params.append('state')
        values_params.append(SQLTool.formatstring(state))
    if name != '':
        request_params.append('name')
        values_params.append(SQLTool.formatstring(name))
    if product != '':
        request_params.append('product')
        values_params.append(SQLTool.formatstring(product))
    if version != '':
        request_params.append('version')
        values_params.append(SQLTool.formatstring(version))
    if script != '':
        request_params.append('script')
        values_params.append(SQLTool.formatstring(script))
    if detail != '':
        request_params.append('detail')
        values_params.append(SQLTool.formatstring(detail))
    if head != '':
        request_params.append('head')
        values_params.append(SQLTool.formatstring(head))
    table = localconfig.porttable
    DBhelp = SQLTool.DBmanager()
    DBhelp.connectdb()
    tempresult = None
    try:
        tempresult = DBhelp.replaceinserttableinfo_byparams(
            table, request_params, [tuple(values_params)])
    except Exception, e:
        print str(e)
コード例 #29
0
def portshow(ip='',
             port='',
             timesearch='',
             state='',
             name='',
             product='',
             version='',
             script='',
             detail='',
             page='0',
             extra='',
             command='and',
             head='',
             city=''):
    validresult = False
    request_params = []
    values_params = []
    if ip != '':
        request_params.append('ip')
        values_params.append(SQLTool.formatstring(ip))
    if port != '':
        request_params.append('port')
        values_params.append(SQLTool.formatstring(port))
    if timesearch != '':
        request_params.append('timesearch')
        values_params.append(SQLTool.formatstring(timesearch))
    if state != '':
        request_params.append('state')
        values_params.append(SQLTool.formatstring(state))
    if name != '':
        request_params.append('name')
        values_params.append(SQLTool.formatstring(name))
    if product != '':
        request_params.append('product')
        values_params.append(SQLTool.formatstring(product))
    if version != '':
        request_params.append('version')
        values_params.append(SQLTool.formatstring(version))
    if script != '':
        request_params.append('script')
        values_params.append(SQLTool.formatstring(script))
    if detail != '':
        request_params.append('detail')
        values_params.append(SQLTool.formatstring(detail))
    if head != '':
        request_params.append('head')
        values_params.append(SQLTool.formatstring(head))
    if city != '':
        request_params.append('city')
        values_params.append(SQLTool.formatstring(city))
    global DBhelp
    DBhelp = SQLTool.DBmanager()
    DBhelp.connectdb()
    localconfig = config.Config()
    table = localconfig.porttable
    content = None
    result = None
    try:
        result, content, count, col = DBhelp.searchtableinfo_byparams(
            [table], ['count(*)'],
            request_params,
            values_params,
            extra=extra,
            command=command)
    except Exception, e:
        print str(e) + 'portcontrol 50'
        if DBhelp is not None:
            DBhelp.closedb()
            DBhelp = None
        return [], 0, 0
コード例 #30
0
        portarray = []
        if count > 0:
            validresult = True
            import base64
            for temp in result:
                aport = ports.Port(
                    ip=temp['ip'],
                    port=temp['port'],
                    timesearch=temp['timesearch'],
                    state=temp['state'],
                    name=temp['name'],
                    product=temp['product'],
                    version=temp['version'],
                    script=base64.b64encode(
                        SQLTool.getdecodeproperty(temp, 'script')),
                    detail=SQLTool.getdecodeproperty(temp, 'detail'),
                    head=SQLTool.getdecodeproperty(temp, 'head'),
                    city=temp['city'],
                    hackinfo=SQLTool.getdecodeproperty(temp, 'hackinfo'),
                    disclosure=SQLTool.getdecodeproperty(temp, 'disclosure'))

                #                 aport=ports.Port(ip=temp[0],port=temp[1],timesearch=temp[2],state=temp[3],name=temp[4],product=temp[5],version=temp[6],script=temp[7])
                portarray.append(aport)
        print str(count) + '          ' + str(pagecount)
        return portarray, count, pagecount
    return [], 0, pagecount


def portshow(ip='',
             port='',
コード例 #31
0
def ipshow(ip='',
           vendor='',
           osfamily='',
           osgen='',
           accurate='',
           updatetime='',
           hostname='',
           state='',
           page='0',
           city=''):
    validresult = False
    request_params = []
    values_params = []
    if ip != '':
        request_params.append('ip')
        values_params.append(SQLTool.formatstring(ip))
    if vendor != '':
        request_params.append('vendor')
        values_params.append(SQLTool.formatstring(vendor))
    if osfamily != '':
        request_params.append('osfamily')
        values_params.append(SQLTool.formatstring(osfamily))
    if osgen != '':
        request_params.append('osgen')
        values_params.append(SQLTool.formatstring(osgen))
    if accurate != '':
        request_params.append('accurate')
        values_params.append(SQLTool.formatstring(accurate))
    if updatetime != '':
        request_params.append('updatetime')
        values_params.append(SQLTool.formatstring(updatetime))
    if hostname != '':
        request_params.append('hostname')
        values_params.append(SQLTool.formatstring(hostname))
    if state != '':
        request_params.append('state')
        values_params.append(SQLTool.formatstring(state))
    if city != '':
        request_params.append('city')
        values_params.append(SQLTool.formatstring(city))
    DBhelp = SQLTool.DBmanager()
    DBhelp.connectdb()
    table = localconfig.iptable
    result, content, count, col = DBhelp.searchtableinfo_byparams([table], [
        'ip', 'vendor', 'osfamily', 'osgen', 'accurate', 'updatetime',
        'hostname', 'state', 'city'
    ], request_params, values_params)

    if count == 0:
        pagecount = 0
    elif count % limitpage > 0:
        #         pagecount = math.ceil(count / limitpage)
        pagecount = int((count + limitpage - 1) / limitpage)

    else:
        pagecount = count / limitpage

#     print str(pagecount)+'当前页数'
    if pagecount > 0:

        limit = '    limit  ' + str(
            int(page) * limitpage) + ',' + str(limitpage)
        result, content, count, col = DBhelp.searchtableinfo_byparams(
            [table], [
                'ip', 'vendor', 'osfamily', 'osgen', 'accurate', 'updatetime',
                'hostname', 'state', 'city'
            ],
            request_params,
            values_params,
            limit,
            order='updatetime desc')

        DBhelp.closedb()
        ips = []
        if count > 0:
            validresult = True
            for temp in result:
                aip = ipmain.Ip(ip=temp['ip'],
                                vendor=temp['vendor'],
                                osfamily=temp['osfamily'],
                                osgen=temp['osgen'],
                                accurate=temp['accurate'],
                                updatetime=temp['updatetime'],
                                hostname=temp['hostname'],
                                state=temp['state'],
                                city=temp['city'])
                #                 aip=ipmain.Ip(ip=temp[0],vendor=temp[1],osfamily=temp[2],osgen=temp[3],accurate=temp[4],updatetime=temp[5],hostname=temp[6],state=temp[7])
                ips.append(aip)
        return ips, count, pagecount
    return [], 0, pagecount
コード例 #32
0
ファイル: portcontrol.py プロジェクト: he1m4n6a/toolforspider
def portabstractshow(ip='',port='',timesearch='',state='',name='',product='',version='',script='',detail='',page='0',extra='',command='and',head='',city='',hackinfo='',disclosure=''):
    localconfig=config.Config()
    table=localconfig.porttable
    iptable=localconfig.iptable
    validresult=False
    request_params=[]
    values_params=[]

    if ip!='':
        request_params.append(table+'.'+'ip')
        values_params.append(SQLTool.formatstring(ip))
    if port!='':
        request_params.append('port')
        values_params.append(SQLTool.formatstring(port))
    if timesearch!='':
        request_params.append('timesearch')
        values_params.append(SQLTool.formatstring(timesearch))
    if state!='':
        request_params.append(table+'.'+'state')
        values_params.append(SQLTool.formatstring(state))
    if name!='':
        request_params.append('name')
        values_params.append(SQLTool.formatstring(name))
    if product!='':
        request_params.append('product')
        values_params.append(SQLTool.formatstring(product))
    if version!='':
        request_params.append('version')
        values_params.append(SQLTool.formatstring(version))
    if script!='':
        request_params.append('script')
        values_params.append(SQLTool.formatstring(script))
    if detail!='':
        request_params.append('detail')
        values_params.append(SQLTool.formatstring(detail))
    if head!='':
        request_params.append('head')
        values_params.append(SQLTool.formatstring(head))
    if city!='':
        request_params.append('city')
        values_params.append(SQLTool.formatstring(city))
    global DBhelp

    DBhelp=SQLTool.DBmanager()
    DBhelp.connectdb()
    
    content=None
    result=None
    try:
        result,content,count,col=DBhelp.searchtableinfo_byparams([table+' left join ip_maindata on snifferdata.ip=ip_maindata.ip'], ['count(*)'], request_params, values_params,extra=extra,command=command)
    except Exception,e:
        print str(e)+'portcontrol 58'
        if DBhelp is not None:
            DBhelp.closedb()
            DBhelp=None
        return [],0,0
コード例 #33
0
ファイル: control.py プロジェクト: suxinging/toolforspider
#coding:utf-8
from spidertool import searchTask
from spidertool import dealTask
from spidertool import SQLTool
import datetime
if __name__ == "__main__":
    links = [
        'http://www.bunz.edu.cn', 'http://www.baidu.com',
        'http://www.hao123.com', 'http://www.cctv.com', 'http://www.vip.com'
    ]
    S_produce = searchTask.searchTask()  #表示创建的是线程
    S_produce.set_deal_num(10)
    S_produce.add_work(links)

    S_produce.start_task()

    searchResultSQL = SQLTool.DBmanager()
    searchResultSQL.connectdb()
    F_consume = dealTask.dealTask(0)  #参数0表示创建的是进程
    F_consume.set_deal_num(10)

    while S_produce.has_work_left():
        v, b = S_produce.get_finish_work()

        searchResultSQL.inserttableinfo_byparams(
            'webdata', ["address", "content", "meettime"],
            [(v, b, str(datetime.datetime.now()))])
        F_consume.add_work(b)
    while True:
        pass
コード例 #34
0
            DBhelp.closedb()
            DBhelp = None

        portarray = []
        if count > 0:
            validresult = True
            for temp in result:
                aport = ports.Port(
                    ip=temp['ip'],
                    port=temp['port'],
                    timesearch=temp['timesearch'],
                    state=temp['state'],
                    name=temp['name'],
                    product=temp['product'],
                    version=temp['version'],
                    script=SQLTool.decodestring(temp['script']),
                    detail=SQLTool.decodestring(temp['detail']),
                    head=SQLTool.decodestring(temp['head']),
                    city=temp['city'],
                    hackinfo=SQLTool.decodestring(temp['hackinfo']),
                    disclosure=SQLTool.decodestring(temp['disclosure']))

                #                 aport=ports.Port(ip=temp[0],port=temp[1],timesearch=temp[2],state=temp[3],name=temp[4],product=temp[5],version=temp[6],script=temp[7])
                portarray.append(aport)
        print str(count) + '          ' + str(pagecount)
        return portarray, count, pagecount
    return [], 0, pagecount


def portshow(ip='',
             port='',