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解决汉字编码问题:Unicode Decode Error
最近在利用python读取一个含有汉字的文档时导致出现了乱码,并报出了两个错误,无奈只能上网找寻答案,后通过网友的帮助解决了这个问题,想着总结一下,下面这篇文章就主要介绍了python如何解决汉字编码问题,有需要的朋友们可以参考借鉴。2017-01-01python3线程池ThreadPoolExecutor处理csv文件数据
这篇文章主要为大家介绍了python3线程池ThreadPoolExecutor处理csv文件数据实现的实例过程,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪2022-06-06零基础写python爬虫之抓取百度贴吧并存储到本地txt文件改进版
前面已经发了一篇关于百度贴吧抓取的代码,今天我们来看下代码的改进版,参考了上篇抓取糗事百科的思路,给需要的小伙伴们参考下吧2014-11-11Jupyter notebook 输出部分显示不全的解决方案
这篇文章主要介绍了Jupyter notebook 输出部分显示不全的解决方案,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2021-04-04详解django的serializer序列化model几种方法
序列化是将对象状态转换为可保持或传输的格式的过程。这篇文章主要介绍了详解django的serializer序列化model几种方法。具有一定的参考价值,感兴趣的小伙伴们可以参考一下2018-10-10
最新评论