Skip to content

Commit

Permalink
add domain search support
Browse files Browse the repository at this point in the history
  • Loading branch information
nanshihui committed Oct 8, 2016
1 parent d875e08 commit 2d4ec91
Show file tree
Hide file tree
Showing 8 changed files with 336 additions and 373 deletions.
648 changes: 294 additions & 354 deletions .idea/workspace.xml

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions spidermanage/nmaptoolbackground/control/taskscontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,21 +234,24 @@ def identifyip(msg,dic):
regix="(\d+\.\d+\.\d+\.\d+)\-(\d+\.\d+\.\d+\.\d+)"
for i in msg:
m1 = re.search(regix, i)
print m1,i,'this is 237'
if m1:
iprange=m1.group().split('-')
print iprange,i
startip=iprange[0]

stopip = iprange[1]


listitem.add_work([(startip, stopip, dic)])

else:
regix = "(\d+\.\d+\.\d+\.\d+)"
m1 = re.search(regix, i)
if m1:
ary.add(m1.group())
# else:
# ary.add(i)
regixx = "(\d+\.\d+\.\d+\.\d+)"
m2 = re.search(regixx, i)
if m2:
ary.add(m2.group())
else:
ary.add(i)
for i in ary:
listitem.add_work([(i, i, dic)])

Expand Down
2 changes: 1 addition & 1 deletion spidermanage/nmaptoolbackground/tasks/taskroute.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def taskadd(request):
result = taskscontrol.taskadd(job)

temp= taskscontrol.createjob(job)
# print result

if result:
print '操作成功'
response_data['result'] = '1'
Expand Down
2 changes: 1 addition & 1 deletion spidermanage/spidertool/getLocationTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def task(self,req,threadname):


insertdata.append((ip,country,country_id,area,area_id,region,region_id,city,city_id,county,county_id,isp,isp_id,localtime))

extra=' on duplicate key update updatetime='+SQLTool.formatstring(localtime)+',country='+SQLTool.formatstring(country)+', country_id='+SQLTool.formatstring(country_id)+',area='+SQLTool.formatstring(area)+', area_id='+SQLTool.formatstring(area_id)+',region='+SQLTool.formatstring(region)+', region_id='+SQLTool.formatstring(region_id)+',city='+SQLTool.formatstring(city)+', city_id='+SQLTool.formatstring(city_id)+',county='+SQLTool.formatstring(county)+', county_id='+SQLTool.formatstring(county_id)+',isp='+SQLTool.formatstring(isp)+', isp_id='+SQLTool.formatstring(isp_id)

sqldatawprk=[]
Expand Down
17 changes: 12 additions & 5 deletions spidermanage/spidertool/iptask.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,13 @@ def task(self,req,threadname):

def getIplist(self,startip,endip,taskid,taskport,isjob,username,command,status):
ip_list = []

isdomain=0
res = ()
res = self.iprange(startip,endip)
try:
res = self.iprange(startip,endip)
except:
isdomain=1
res =(0,0,0)
if res < 0:
print 'endip must be bigger than startone'
return
Expand All @@ -115,9 +119,12 @@ def getIplist(self,startip,endip,taskid,taskport,isjob,username,command,status):
ipsize=int(res[2])+1
insertdata = []
for x in xrange(ipsize):
startipnum = self.ip2num(startip)
startipnum = startipnum + x
ip=self.num2ip(startipnum)
if isdomain:
ip=startip
else:
startipnum = self.ip2num(startip)
startipnum = startipnum + x
ip=self.num2ip(startipnum)


if isjob == '0':
Expand Down
4 changes: 3 additions & 1 deletion spidermanage/spidertool/iptool.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,7 @@ def getIplist(self,startip,endip):
ip_list.append(self.num2ip(startipnum))
return ip_list
if __name__ == '__main__':

a=IPTool()
a.getIplist('219.1.1.1','219.255.255.255')
# print a.iprange('www.baidu.com','www.baidu.com')
# a.getIplist('219.1.1.1','219.255.255.255')
5 changes: 4 additions & 1 deletion spidermanage/spidertool/sniffertool.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ def callback_result(self,scan_result):
# self.sqlTool.replaceinserttableinfo_byparams(table=self.config.iptable,select_params= ['ip','vendor','osfamily','osgen','accurate','updatetime','hostname','state'],insert_values= [(temphosts,tempvendor,temposfamily,temposgen,tempaccuracy,localtime,temphostname,tempstate)])
sqldatawprk=[]
dic={"table":self.config.iptable,"select_params": ['ip','vendor','osfamily','osgen','accurate','updatetime','hostname','state'],"insert_values": [(temphosts,tempvendor,temposfamily,temposgen,tempaccuracy,localtime,temphostname,tempstate)]}

tempwprk=Sqldata.SqlData('replaceinserttableinfo_byparams',dic)

sqldatawprk.append(tempwprk)
self.sqlTool.add_work(sqldatawprk)
except Exception,e:
Expand All @@ -153,6 +155,7 @@ def callback_result(self,scan_result):
sqldatawprk=[]
dic={"table":self.config.porttable,"select_params": ['ip','port','timesearch','state','name','product','version','script','portnumber'],"insert_values": [(temphosts,tempport,localtime,tempportstate,tempportname,tempproduct,tempportversion,tempscript,str(tempport))]}
tempwprk=Sqldata.SqlData('replaceinserttableinfo_byparams',dic)

sqldatawprk.append(tempwprk)
self.sqlTool.add_work(sqldatawprk)
self.portscan.add_work([(tempportname,temphosts,tempport,tempportstate,tempproduct,tempscript)])
Expand Down Expand Up @@ -257,7 +260,7 @@ def callback_resultl(host, scan_result):

temp=SniffrtTool()
# hosts=['www.cctv.com','localhost','www.baidu.com']'www.cctv.com' www.vip.com
hosts=['121.43.104.188']
hosts=['www.baidu.com']
temp.scanaddress(hosts,ports=['80'],arguments='')


Expand Down
16 changes: 12 additions & 4 deletions spidermanage/spidertool/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,26 @@
def identifyip(msg):
ary=set()
msgary=msg.split(',')
print msgary,16
import re
regix="(\d+\.\d+\.\d+\.\d+)\-(\d+\.\d+\.\d+\.\d+)"

for i in msgary:
print i,20
m1 = re.search(regix, i)
print 'm1',i,m1,22
if m1:
ary|= set(m1.group().split('-'))
t=m1.group().split('-')
print t
ary|= set(t)
else:
regix = "(\d+\.\d+\.\d+\.\d+)"
m1 = re.search(regix, i)
ary.add(m1.group())
m2 = re.search(regix, i)
if m2:
ary.add(m2.group())
del m1
return ary
print identifyip("123.0.23.12-2.2.2.2,2.2.2.2")
print identifyip("145.23.45.2-145.23.45.3,www.baidu.com,56.32.12.32")
def aa():
print 'already in port'
class bb:
Expand Down

0 comments on commit 2d4ec91

Please sign in to comment.