python局域网ip扫描示例分享

时间:2022-10-19 08:43:45 


#!/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
0
投稿

猜你喜欢

  • 树莓派4B安装Tensorflow的方法步骤

    2023-09-05 17:28:06
  • axios发送post请求,提交图片类型表单数据方法

    2024-04-26 17:40:27
  • python selenium自动化测试框架搭建的方法步骤

    2023-05-24 21:38:49
  • 老生常谈python之鸭子类和多态

    2023-09-26 09:00:26
  • python写的一个squid访问日志分析的小程序

    2021-08-02 14:09:09
  • python实现对象列表根据某个属性排序的方法详解

    2022-12-24 23:47:43
  • Python面经之16个高频面试问题总结

    2022-09-10 18:36:33
  • python排序算法之归并排序

    2021-03-24 06:05:39
  • python使用turtle库绘制时钟

    2022-09-13 07:06:51
  • Python3爬虫学习之将爬取的信息保存到本地的方法详解

    2023-01-07 14:20:26
  • python3操作微信itchat实现发送图片

    2022-03-26 11:42:52
  • 对python中各个response的使用说明

    2023-01-20 02:43:16
  • 详解pytorch的多GPU训练的两种方式

    2023-08-04 09:58:29
  • 使用Python绘制图表大全总结

    2022-08-09 20:35:27
  • 浅析python标准库中的glob

    2023-08-04 02:39:10
  • MySQL单表多关键字模糊查询的实现方法

    2024-01-12 18:12:14
  • CSS3的新特性

    2009-03-23 17:46:00
  • Python使用pyecharts绘制世界地图,省级地图,城市地图实例详解

    2022-08-08 06:37:22
  • mysql 5.1版本修改密码及远程登录mysql数据库的方法

    2024-01-17 15:38:02
  • Pip install和Conda install的使用

    2023-11-04 17:32:37
  • asp之家 网络编程 m.aspxhome.com