手机
当前位置:查字典教程网 >脚本专栏 >python >python局域网ip扫描示例分享
python局域网ip扫描示例分享
摘要:复制代码代码如下:#!/usr/bin/python#-*-coding:utf-8-*-fromscapy.allimport*fromt...

复制代码 代码如下:

#!/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基础教程之udp端口扫描

python读写ini文件示例(python读写文件)

python查找第k小元素代码分享

python使用scrapy解析js示例

python 字符串split的用法分享

python thread 并发且顺序运行示例

python实现博客文章爬虫示例

pyqt4教程之messagebox使用示例分享

pyqt4教程之实现windows窗口小示例分享

vc6编写python扩展的方法分享

精品推荐
分类导航