漫衍式拒绝处事(DDoS)进攻指借助于客户/处事器技能,将多个计较机连系起来作为进攻平台,对一个或多个方针动员DDoS进攻,从而成倍地提高拒绝处事进攻的威力。凡是,进攻者利用一个盗窃帐号将DDoS主控措施安装在一个计较机上,在一个设定的时间主控措施将与大量署理措施通讯,署理措施已经被安装在网络上的很多计较机上。署理措施收到指令时就动员进攻。操作客户/处事器技能,主控措施能在几秒钟内激活成百上千次署理措施的运行。
此文中的API将台湾列为国度,非本人态度,台湾属于中国,台湾岛糊口的人不必然!
上码:
#!/usr/bin/python #coding=utf-8 ''' '''import plotly import plotly.plotly import plotly.graph_objs as abcc import plotly.plotly class Piecharts: def __init__(self): print "饼图生成中" def makePiecharts(self,labels,values,filename): trace = abcc.Pie(labels = labels,values= values) plotly.offline.plot([trace],filename=filename) import requests import sys try: iplist = sys.argv[1] except: print "IP list not given or some other error!" countrylist = {} regionlist = {} citylist = {} with open(iplist) as f: for ip in f.readlines(): if ip.strip() != '': url = 'http://ip-api.com/json/' + ip.strip() try: result = requests.get(url) jsontext = result.json() except: print "Error: Data not retrieved!" continue status = jsontext['status'] if status == 'fail': print "%s failed!" % ip.strip() continue mline = jsontext['as'] city = jsontext['city'] country = jsontext['country'] countryCode = jsontext['countryCode'] isp = jsontext['isp'] lat = jsontext['lat'] lon = jsontext['lon'] org = jsontext['org'] query = jsontext['query'] region = jsontext['region'] regionName = jsontext['regionName'] timezone = jsontext['timezone'] zipcode = jsontext['zip'] if not country in countrylist: countrylist[country] = 0 else: countrylist[country] += 1 if not regionName in regionlist: regionlist[regionName] = 0 else: regionlist[regionName] += 1 if not city in citylist: citylist[city] = 0 else: citylist[city] += 1 try: print ip.strip() + '--' + country + '--' + regionName except: print "Special character!" print countrylist #country labels = [i for i in countrylist] value = [countrylist[i] for i in countrylist] drive = Piecharts() drive.makePiecharts(labels,value,"country.html") #region labels = [i for i in regionlist] value = [regionlist[i] for i in regionlist] drive = Piecharts() drive.makePiecharts(labels,value,"region.html") #city labels = [i for i in citylist] value = [citylist[i] for i in citylist] drive = Piecharts() drive.makePiecharts(labels,value,"city.html")
gevent协程并发版
#!/usr/bin/python # coding=utf-8 ''' ''' import plotly import plotly.graph_objs as abcc import plotly.plotly class Piecharts: def __init__(self): print u'饼图生成中' def makePiecharts(self, labels, values, filename): trace = abcc.Pie(labels=labels, values=values) plotly.offline.plot([trace], filename=filename) import requests import sys try: iplist = sys.argv[1] except: print "IP list not given or some other error!" countrylist = {} regionlist = {} citylist = {} def locater(url): try: result = requests.get(url) jsontext = result.json() except: print "Error: Data not retrieved!" return status = jsontext['status'] if status == 'fail': print "%s failed!" % ip.strip() return mline = jsontext['as'] city = jsontext['city'] country = jsontext['country'] countryCode = jsontext['countryCode'] isp = jsontext['isp'] lat = jsontext['lat'] lon = jsontext['lon'] org = jsontext['org'] query = jsontext['query'] region = jsontext['region'] regionName = jsontext['regionName'] timezone = jsontext['timezone'] zipcode = jsontext['zip'] if not country in countrylist: countrylist[country] = 0 else: countrylist[country] += 1 if not regionName in regionlist: regionlist[regionName] = 0 else: regionlist[regionName] += 1 if not city in citylist: citylist[city] = 0 else: citylist[city] += 1 try: print ip.strip() + '--' + country + '--' + regionName except: print "Special character!" from gevent import monkey monkey.patch_socket() from gevent import pool import gevent pool = pool.Pool(40) glist = [] with open(iplist) as f: for ip in f.readlines(): if ip.strip() != '': url = 'http://ip-api.com/json/' + ip.strip() glist.append(pool.spawn(locater, url)) gevent.joinall(glist) # country labels = [i for i in countrylist] value = [countrylist[i] for i in countrylist] drive = Piecharts() drive.makePiecharts(labels, value, "country.html") # region labels = [i for i in regionlist] value = [regionlist[i] for i in regionlist] drive = Piecharts() drive.makePiecharts(labels, value, "region.html") # city labels = [i for i in citylist] value = [citylist[i] for i in citylist] drive = Piecharts() drive.makePiecharts(labels, value, "city.html")
饼图结果: