码迷,mamicode.com
首页 > 编程语言 > 详细

Python主机探测,存活发现主机

时间:2018-05-22 12:48:49      阅读:778      评论:0      收藏:0      [点我收藏+]

标签:Python

#!/usr/bin/env python3 #-*-coding:utf-8-*- # @Author  : 杜文涛 # @Time    : 2018/5/22 9:24 # @File    : scapy_test.py #encoding=utf-8 from scapy.all import * def worker():     ip_list=[]     for ipFix in range(1,20):         ip="192.168.0."+str(ipFix)         arpPkt = Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=ip, hwdst="ff:ff:ff:ff:ff:ff")         res = srp1(arpPkt, timeout=1, verbose=False)         if res:             print ("IP: " + res.psrc + "     MAC: " + res.hwsrc)             ip_list.append(res.psrc)     return ip_list if __name__=="__main__":     fp = open('ip.txt','w')     ip_list = worker()     i = 0     for ip in ip_list:         fp.write(ip+'\n')         i += 1     print("扫描到的IP数:"+str(i))     fp.close()


Python主机探测,存活发现主机

标签:Python

原文地址:http://blog.51cto.com/tdcqvip/2118993

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!