def getIplist(self,startip,endip): ip_list = [] res = () res = self.iprange(startip,endip) if res < 0: print 'endip must be bigger than startone' return else: jobs=[] ipsize=int(res[2])+1 for x in xrange(ipsize): startipnum = self.ip2num(startip) startipnum = startipnum + x ip=self.num2ip(startipnum) # self.getlocationtool.add_work([str(ip)]) ajob=job.Job(jobaddress=str(ip),jobport='',forcesearch='0',isjob='0') # tasktotally=taskcontrol.getObject() # # tasktotally.add_work([ajob]) jobs.append(ajob) if len(jobs)==10 or x==ipsize-1: tasktotally=sniffertask.getObject() tasktotally.add_work(jobs) time.sleep(1) jobs=[]
def getIplist(self, startip, endip): ip_list = [] res = () res = self.iprange(startip, endip) if res < 0: print 'endip must be bigger than startone' return else: jobs = [] ipsize = int(res[2]) + 1 for x in xrange(ipsize): startipnum = self.ip2num(startip) startipnum = startipnum + x ip = self.num2ip(startipnum) # self.getlocationtool.add_work([str(ip)]) ajob = job.Job(jobaddress=str(ip), jobport='', forcesearch='0', isjob='0') # tasktotally=taskcontrol.getObject() # # tasktotally.add_work([ajob]) jobs.append(ajob) if len(jobs) == 10 or x == ipsize - 1: tasktotally = sniffertask.getObject() tasktotally.add_work(jobs) time.sleep(1) jobs = []
def do_scan(self,port='80',num='10',needdetail='0'): path=os.getcwd() # p= Popen(" ./zmap -B 4M -p "+port+" -N "+num+" -q -O json", stdout=PIPE, shell=True,cwd=path+'/zmap-2.1.0/src') p= Popen(" zmap -w /root/github/Scan-T/spidermanage/spidertool/iparea.json -B 1M -p "+port+" -N "+num+" -q -O json", stdout=PIPE, shell=True) # 'sudo zmap -p 80 -B 10M -N 50 -q --output-fields=classification,saddr,daddr,sport,dport,seqnum,acknum,cooldown,repeat -o - '+ # '| sudo ./forge-socket -c 50 -d http-req > http-banners.out' #p= Popen(" ./zmap -B 10M -p 80 -n 100000 ", stdout=PIPE, shell=True,cwd=path+'/zmap-2.1.0/src') p.wait() retcode= p.returncode if retcode==0: returnmsg=p.stdout.read() p = re.compile(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}') list= p.findall(returnmsg) # self.sqlTool.connectdb() localtime=str(time.strftime("%Y-%m-%d %X", time.localtime())) insertdata=[] jobs=[] p=0 for i in list: insertdata.append((str(i),port,localtime,'open',str(port))) p=p+1 if p==20 or i==list[len(list)-1]: extra=' on duplicate key update state=\'open\' , timesearch=\''+localtime+'\'' sqldatawprk=[] dic={"table":self.config.porttable,"select_params":['ip','port','timesearch','state','portnumber'],"insert_values":insertdata,"extra":extra} tempwprk=Sqldata.SqlData('inserttableinfo_byparams',dic) sqldatawprk.append(tempwprk) self.sqlTool.add_work(sqldatawprk) p=0 insertdata=[] if needdetail!='0': tasktotally=sniffertask.getObject() tasktotally.add_work(jobs) jobs=[] if needdetail=='0': global portname nowportname=portname.get(port,'') self.portscan.add_work([(nowportname,str(i),port,'open','','')]) else: ajob=job.Job(jobaddress=str(i),jobport='',forcesearch='0',isjob='0') jobs.append(ajob)
def do_scan(self, port='80', num='10', needdetail='0'): path = os.getcwd() # p= Popen(" ./zmap -B 4M -p "+port+" -N "+num+" -q -O json", stdout=PIPE, shell=True,cwd=path+'/zmap-2.1.0/src') p = Popen( " zmap -w /root/github/Scan-T/spidermanage/spidertool/iparea.json -B 1M -p " + port + " -N " + num + " -q -O json", stdout=PIPE, shell=True) # 'sudo zmap -p 80 -B 10M -N 50 -q --output-fields=classification,saddr,daddr,sport,dport,seqnum,acknum,cooldown,repeat -o - '+ # '| sudo ./forge-socket -c 50 -d http-req > http-banners.out' #p= Popen(" ./zmap -B 10M -p 80 -n 100000 ", stdout=PIPE, shell=True,cwd=path+'/zmap-2.1.0/src') p.wait() retcode = p.returncode if retcode == 0: returnmsg = p.stdout.read() p = re.compile(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}') list = p.findall(returnmsg) # self.sqlTool.connectdb() localtime = str(time.strftime("%Y-%m-%d %X", time.localtime())) insertdata = [] jobs = [] p = 0 for i in list: insertdata.append((str(i), port, localtime, 'open', str(port))) p = p + 1 if p == 20 or i == list[len(list) - 1]: extra = ' on duplicate key update state=\'open\' , timesearch=\'' + localtime + '\'' sqldatawprk = [] dic = { "table": self.config.porttable, "select_params": ['ip', 'port', 'timesearch', 'state', 'portnumber'], "insert_values": insertdata, "extra": extra } tempwprk = Sqldata.SqlData('inserttableinfo_byparams', dic) sqldatawprk.append(tempwprk) self.sqlTool.add_work(sqldatawprk) p = 0 insertdata = [] if needdetail != '0': tasktotally = sniffertask.getObject() tasktotally.add_work(jobs) jobs = [] if needdetail == '0': global portname nowportname = portname.get(port, '') self.portscan.add_work([(nowportname, str(i), port, 'open', '', '')]) else: ajob = job.Job(jobaddress=str(i), jobport='', forcesearch='0', isjob='0') jobs.append(ajob)