def task(self,req,threadname): self.logger and self.logger.info('%s 端口扫描 执行任务中%s', threadname,str(datetime.datetime.now())) # print req[0],req[1],req[2],req[3] if req[3]!='open': return '' ip=req[1] port=req[2] productname=req[4] nmapscript=req[5] head=None ans=None hackinfo='' keywords='' if req[0]=='http' or req[0]=='https': if ip[0:4]=='http': address=ip+':'+port else: if port=='443': address='https'+'://'+ip+':'+port else: address=req[0]+'://'+ip+':'+port print address head,ans = self.connectpool.getConnect(address) from template_identify import page_identify keywords,hackinfo=page_identify.identify_main(head=head,context=ans,ip=ip,port=port,productname=productname,protocol=req[0],nmapscript=nmapscript) else: head,ans,keywords,hackinfo=self.portscan.do_scan(head=head,context=ans,ip=ip,port=port,name=req[0],productname=productname,nmapscript=nmapscript) # print ans # self.sqlTool.connectdb() localtime=str(time.strftime("%Y-%m-%d %X", time.localtime())) insertdata=[] temp=str(ans) head=SQLTool.escapewordby(head) msg=SQLTool.escapewordby(temp) hackinfomsg=SQLTool.escapewordby(hackinfo) keywords=SQLTool.escapewordby(keywords) import Sqldata insertdata.append((ip,port,localtime,str(head),msg,str(port),hackinfomsg,keywords)) extra=' on duplicate key update detail=\''+msg+'\' ,head=\''+str(head)+'\', timesearch=\''+localtime+'\',hackinfo=\''+hackinfomsg+'\',keywords=\''+str(keywords)+'\'' sqldatawprk=[] dic={"table":self.config.porttable,"select_params":['ip','port','timesearch','detail','head','portnumber','hackinfo','keywords'],"insert_values":insertdata,"extra":extra} tempwprk=Sqldata.SqlData('inserttableinfo_byparams',dic) sqldatawprk.append(tempwprk) self.sqlTool.add_work(sqldatawprk) # inserttableinfo_byparams(table=self.config.porttable,select_params=['ip','port','timesearch','detail'],insert_values=insertdata,extra=extra) # self.sqlTool.closedb() self.logger and self.logger.info('%s 端口扫描 任务结束%s', threadname,str(datetime.datetime.now())) return ans
def task(self,req,threadname): print threadname+'执行任务中'+str(datetime.datetime.now()) # print req[0],req[1],req[2],req[3] if req[3]!='open': return '' ip=req[1] port=req[2] head=None ans=None hackinfo='' keywords='' if req[0]=='http' or req[0]=='https': if ip[0:4]=='http': address=ip+':'+port else: if port=='443': address='https'+'://'+ip+':'+port else: address=req[0]+'://'+ip+':'+port print address head,ans = self.connectpool.getConnect(address) from template_identify import page_identify keywords,hackinfo=page_identify.identify_main(head=head,context=ans,ip=ip,port=port) else: head,ans,keywords,hackinfo=self.portscan.do_scan(ip,port,req[0]) # print ans # self.sqlTool.connectdb() localtime=str(time.strftime("%Y-%m-%d %X", time.localtime())) insertdata=[] temp=str(ans) insertdata.append((ip,port,localtime,str(head),str(temp).replace("'","'"),str(port),hackinfo.replace("'","'"),keywords)) extra=' on duplicate key update detail=\''+str(temp).replace("'","'")+'\' ,head=\''+str(head)+'\', timesearch=\''+localtime+'\',hackinfo=\''+str(hackinfo).replace("'","'")+'\',keywords=\''+str(keywords)+'\'' sqldatawprk=[] dic={"table":self.config.porttable,"select_params":['ip','port','timesearch','detail','head','portnumber','hackinfo','keywords'],"insert_values":insertdata,"extra":extra} tempwprk=Sqldata.SqlData('inserttableinfo_byparams',dic) sqldatawprk.append(tempwprk) self.sqlTool.add_work(sqldatawprk) # inserttableinfo_byparams(table=self.config.porttable,select_params=['ip','port','timesearch','detail'],insert_values=insertdata,extra=extra) # self.sqlTool.closedb() print threadname+'任务结束'+str(datetime.datetime.now()) return ans
def task(self,req,threadname): self.logger and self.logger.info('%s 端口扫描 执行任务中%s', threadname,str(datetime.datetime.now())) # print req[0],req[1],req[2],req[3] if req[3]!='open': return '' ip=req[1] port=req[2] productname=req[4] nmapscript=req[5] head=None ans=None hackinfo='' keywords='' if (req[0]=='http' or req[0]=='https') or (req[0]=='tcpwrapped' and port in ['80','8080','7001']): if ip[0:4]=='http': address=ip+':'+port else: if port=='443': address='https'+'://'+ip+':'+port else: if req[0]=='tcpwrapped' and port in ['80','8080','7001']: address = 'http://' + ip + ':' + port else: address=req[0]+'://'+ip+':'+port head,ans = self.connectpool.getConnect(address) from template_identify import page_identify keywords,hackinfo=page_identify.identify_main(head=head,context=ans,ip=ip,port=port,productname=productname,protocol=req[0],nmapscript=nmapscript) else: head,ans,keywords,hackinfo=self.portscan.do_scan(head=head,context=ans,ip=ip,port=port,name=req[0],productname=productname,nmapscript=nmapscript) pass # print ans # self.sqlTool.connectdb() localtime=str(time.strftime("%Y-%m-%d %X", time.localtime())) insertdata=[] temp=str(ans) head=SQLTool.escapewordby('{'+head+'}') msg=SQLTool.escapewordby('{'+temp+'}') hackinfomsg=SQLTool.escapewordby(hackinfo) keywords=SQLTool.escapewordby(keywords) import Sqldata insertdata.append((ip,port,localtime,msg,str(head),str(port),hackinfomsg,keywords)) extra=' on duplicate key update detail=\''+msg+'\' ,head=\''+str(head)+'\', timesearch=\''+localtime+'\',hackinfo=\''+hackinfomsg+'\',keywords=\''+str(keywords)+'\'' sqldatawprk=[] dic={"table":self.config.porttable,"select_params":['ip','port','timesearch','detail','head','portnumber','hackinfo','keywords'],"insert_values":insertdata,"extra":extra} tempwprk=Sqldata.SqlData('inserttableinfo_byparams',dic) sqldatawprk.append(tempwprk) self.sqlTool.add_work(sqldatawprk) # inserttableinfo_byparams(table=self.config.porttable,select_params=['ip','port','timesearch','detail'],insert_values=insertdata,extra=extra) # self.sqlTool.closedb() self.logger and self.logger.info('%s 端口扫描 任务结束%s', threadname,str(datetime.datetime.now())) return ans
def task(self, req, threadname): print threadname + '执行任务中' + str(datetime.datetime.now()) # print req[0],req[1],req[2],req[3] if req[3] != 'open': return '' ip = req[1] port = req[2] productname = req[4] nmapscript = req[5] head = None ans = None hackinfo = '' keywords = '' if req[0] == 'http' or req[0] == 'https': if ip[0:4] == 'http': address = ip + ':' + port else: if port == '443': address = 'https' + '://' + ip + ':' + port else: address = req[0] + '://' + ip + ':' + port print address head, ans = self.connectpool.getConnect(address) from template_identify import page_identify keywords, hackinfo = page_identify.identify_main( head=head, context=ans, ip=ip, port=port, productname=productname, protocol=req[0], nmapscript=nmapscript) else: head, ans, keywords, hackinfo = self.portscan.do_scan( head=head, context=ans, ip=ip, port=port, name=req[0], productname=productname, nmapscript=nmapscript) localtime = str(time.strftime("%Y-%m-%d %X", time.localtime())) insertdata = [] temp = str(ans) head = SQLTool.escapeword(head) msg = SQLTool.escapeword(temp) hackinfomsg = SQLTool.escapeword(hackinfo) keywords = SQLTool.escapewordby(keywords) insertdata.append((ip, port, localtime, str(head), msg, str(port), hackinfomsg, keywords)) extra = ' on duplicate key update detail=\'' + msg + '\' ,head=\'' + str( head ) + '\', timesearch=\'' + localtime + '\',hackinfo=\'' + hackinfomsg + '\',keywords=\'' + str( keywords) + '\'' sqldatawprk = [] dic = { "table": self.config.porttable, "select_params": [ 'ip', 'port', 'timesearch', 'detail', 'head', 'portnumber', 'hackinfo', 'keywords' ], "insert_values": insertdata, "extra": extra } if self.islocalwork == 0: tempdata = {"func": 'inserttableinfo_byparams', "dic": dic} jsondata = uploaditem.UploadData( url=self.webconfig.upload_port_info, way='POST', params=tempdata) sqldatawprk.append(jsondata) self.uploadwork.add_work(sqldatawprk) else: tempwprk = Sqldata.SqlData('inserttableinfo_byparams', dic) sqldatawprk.append(tempwprk) self.sqlTool.add_work(sqldatawprk) # inserttableinfo_byparams(table=self.config.porttable,select_params=['ip','port','timesearch','detail'],insert_values=insertdata,extra=extra) # self.sqlTool.closedb() print threadname + '任务结束' + str(datetime.datetime.now()) return ans
def task(self, req, threadname): print threadname + '执行任务中' + str(datetime.datetime.now()) # print req[0],req[1],req[2],req[3] if req[3] != 'open': return '' ip = req[1] port = req[2] head = None ans = None hackinfo = '' keywords = '' if req[0] == 'http' or req[0] == 'https': if ip[0:4] == 'http': address = ip + ':' + port else: if port == '443': address = 'https' + '://' + ip + ':' + port else: address = req[0] + '://' + ip + ':' + port print address head, ans = self.connectpool.getConnect(address) from template_identify import page_identify keywords, hackinfo = page_identify.identify_main(head=head, context=ans, ip=ip, port=port) else: head, ans, keywords, hackinfo = self.portscan.do_scan( ip, port, req[0]) # print ans # self.sqlTool.connectdb() localtime = str(time.strftime("%Y-%m-%d %X", time.localtime())) insertdata = [] temp = str(ans) insertdata.append( (ip, port, localtime, str(head), str(temp).replace("'", "'"), str(port), hackinfo.replace("'", "'"), keywords)) extra = ' on duplicate key update detail=\'' + str(temp).replace( "'", "'" ) + '\' ,head=\'' + str( head) + '\', timesearch=\'' + localtime + '\',hackinfo=\'' + str( hackinfo).replace( "'", "'") + '\',keywords=\'' + str(keywords) + '\'' sqldatawprk = [] dic = { "table": self.config.porttable, "select_params": [ 'ip', 'port', 'timesearch', 'detail', 'head', 'portnumber', 'hackinfo', 'keywords' ], "insert_values": insertdata, "extra": extra } tempwprk = Sqldata.SqlData('inserttableinfo_byparams', dic) sqldatawprk.append(tempwprk) self.sqlTool.add_work(sqldatawprk) # inserttableinfo_byparams(table=self.config.porttable,select_params=['ip','port','timesearch','detail'],insert_values=insertdata,extra=extra) # self.sqlTool.closedb() print threadname + '任务结束' + str(datetime.datetime.now()) return ans