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. There was a similar question answered not too long ago on this site. > # 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 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. 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. |