Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python scapy get mac of remote device

>>> from subprocess import Popen, PIPE
>>> import re
>>> IP = "1.2.3.4"

>>> # do_ping(IP)
>>> # The time between ping and arp check must be small, as ARP may not cache long

>>> pid = Popen(["arp", "-n", IP], stdout=PIPE)
>>> s = pid.communicate()[0]
>>> mac = re.search(r"(([a-fd]{1,2}:){5}[a-fd]{1,2})", s).groups()[0]
>>> mac
"fe:fd:61:6b:8a:0f"
Comment

PREVIOUS NEXT
Code Example
Python :: tf.reduce_sum() 
Python :: decode multipart/form-data python lambda 
Python :: install fastapi 
Python :: renpy 
Python :: weighted average in python pandas 
Python :: python .findall 
Python :: Python NumPy ndarray flatten Function Example 
Python :: time in python code 
Python :: pip install pandas Getting requirements to build wheel 
Python :: gensim show_topics get topic 
Python :: discord.py message user 
Python :: df sort by column names 
Python :: how to run loops 3 times in python 
Python :: python tkinter ttk 
Python :: executing curl commands in python 
Python :: python generate string 
Python :: python round without math 
Python :: sortedcontainers sorteddict import 
Python :: basic flask app python 
Python :: How to develop a UDP echo client? 
Python :: python override string class 
Python :: IQR to remove outlier 
Python :: pthon return value with highest occurences 
Python :: os.startfile 
Python :: character to ascii python 
Python :: collections counter sort by value 
Python :: numpy concatenation python 
Python :: python dictionary pop key 
Python :: Character limit python system 
Python :: r char to numeric dataframe all columns 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =