python局域网ip扫描示例分享

它是那样的舒展,那样高雅。特别是盛夏时节,热青奔放,有粉的,白的,紫的……,互不相让,竟相开放,它们好象正在表演一场时装表演。在巨大的碧绿的荷叶上,小水珠滚来滚去,偶尔一些小青蛙跳上一片荷叶,把荷叶当做歌台。在陽光的照耀下,水珠闪闪发光,显得楚楚动人。


#!/usr/bin/python
# -*- coding: utf-8 -*-

from scapy.all import *
from time import ctime,sleep
import threading
TIMEOUT = 4
conf.verb=0


def pro(cc,handle):
dst = "192.168.1." + str(cc)
packet = IP(dst=dst, ttl=20)/ICMP()
reply = sr1(packet, timeout=TIMEOUT)
if not (reply is None):
handle.write(reply.src+" is online"+"\n")
#print reply.src, "is online"

def main():
threads=[]
f=open('ip.log','a')
for i in range(2,254):
t=threading.Thread(target=pro,args=(i,f))
threads.append(t)
print "main Thread begins at ",ctime()
for t in threads :
t.start()
for t in threads :
t.join()
print "main Thread ends at ",ctime()

if __name__=="__main__" :
main();

以上就是python局域网ip扫描示例分享。水寒江静,月明星疏。也许我们都该持有一颗良善的心,把今生当作最后一世,守候在缘分必经的路口,尊重每一段来之不易的感情。轻叩庭园,换一种踏雪寻梅的心情,找回诗意的简单。光阴无涯,聚散有时。因为懂得,所以慈悲。更多关于python局域网ip扫描示例分享请关注haodaima.com其它相关文章!

标签: python ip