Not exactly what you're looking for, but definitely on the right track. You could also do something similar to the verified answer. Sniff(prn=arp_monitor_callback, filter="arp", store=0) Return pkt.sprintf("%ARP.hwsrc% %ARP.psrc%") If ARP in pkt and pkt.op in (1,2): #who-has or is-at You must either call a system command such as arp to get ARP information, or generate your own packets using Scapy.Įdit: An example using Scapy from their website: As mentioned in the answer chosen by the asker of that question, Python doesn't have a built-in way to do it. Note: Many devices have multiple MAC addresses, so consider your device and. An example of a Mac address is: 00-B0-D0-63-C2-26. The command, chmac. There was a similar question answered not too long ago on this site. A MAC (Media Access Control) address, sometimes referred to as a hardware or physical address, is a unique, 12-character alphanumeric attribute that is used to identify individual electronic devices on a network. ChMac, a quick Windows batch CLI utility to change or randomize network adapter MAC address for security, or to work around usage limit of public Wi-Fi hotspots, either automatically or manually. > # The time between ping and arp check must be small, as ARP may not cache long Knowing that, you do a little subprocess magic - otherwise you're writing ARP cache checking code yourself, and you don't want to do that: > from subprocess import Popen, PIPE The goal is to build a script that will poll a databases of IP addresses on regular intervals ensuring that the mac addresses have not changed and if they have, email alerts to myself. PING 97.107.138.15 (97.107.138.15) 56(84) bytes of data.Ħ4 bytes from 97.107.138.15: icmp_seq=1 ttl=64 time=1.25 msĪddress HWtype HWaddress Flags Mask Ifaceĩ7.107.138.15 ether fe:fd:61:6b:8a:0f C eth0 I'm looking for a way (with python) to obtain the layer II address from a device on my local network. That will place the target - as long as it's within your netmask, which it sounds like in this situation it will be - in your system's ARP cache. A small change to the regular expression will make it work in OS X.įirst, you must ping the target. Awesome, now you can build your own email client using this recipe. I don't have Windows handy, so the following solution works on the Linux box I wrote it on. To answer the question with Python depends on your platform.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |