本文整理匯總了Python中spidertool.SQLTool.formatstring方法的典型用法代碼示例。如果您正苦於以下問題:Python SQLTool.formatstring方法的具體用法?Python SQLTool.formatstring怎麽用?Python SQLTool.formatstring使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類spidertool.SQLTool
的用法示例。
在下文中一共展示了SQLTool.formatstring方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: taskshow
# 需要導入模塊: from spidertool import SQLTool [as 別名]
# 或者: from spidertool.SQLTool import formatstring [as 別名]
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: jobupdate
# 需要導入模塊: from spidertool import SQLTool [as 別名]
# 或者: from spidertool.SQLTool import formatstring [as 別名]
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
示例3: portadd
# 需要導入模塊: from spidertool import SQLTool [as 別名]
# 或者: from spidertool.SQLTool import formatstring [as 別名]
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: ipshow
# 需要導入模塊: from spidertool import SQLTool [as 別名]
# 或者: from spidertool.SQLTool import formatstring [as 別名]
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
示例5: portshow
# 需要導入模塊: from spidertool import SQLTool [as 別名]
# 或者: from spidertool.SQLTool import formatstring [as 別名]
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
示例6: divided
# 需要導入模塊: from spidertool import SQLTool [as 別名]
# 或者: from spidertool.SQLTool import formatstring [as 別名]
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
示例7: mapshow
# 需要導入模塊: from spidertool import SQLTool [as 別名]
# 或者: from spidertool.SQLTool import formatstring [as 別名]
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
示例8: jobshow
# 需要導入模塊: from spidertool import SQLTool [as 別名]
# 或者: from spidertool.SQLTool import formatstring [as 別名]
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
示例9: portabstractshow
# 需要導入模塊: from spidertool import SQLTool [as 別名]
# 或者: from spidertool.SQLTool import formatstring [as 別名]
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