Home > Backend Development > Python Tutorial > python通过scapy获取局域网所有主机mac地址示例

python通过scapy获取局域网所有主机mac地址示例

WBOY
Release: 2016-06-16 08:44:14
Original
2056 people have browsed it

python通过scapy获取局域网所有主机mac地址

复制代码 代码如下:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from scapy.all import srp,Ether,ARP,conf
ipscan='192.168.1.1/24'
try:
    ans,unans = srp(Ether(dst="FF:FF:FF:FF:FF:FF")/ARP(pdst=ipscan),timeout=2,verbose=False)
except Exception,e:
    print str(e)
else:
    for snd,rcv in ans:
        list_mac=rcv.sprintf("%Ether.src% - %ARP.psrc%")
        print list_mac


python通过scapy获取局域网所有主机mac地址示例
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template