0

I am building a Mini-Project and I came across this problem..I have to find MAC Addresses of all Devices that were in my Home Network .Here I got all the devices local IP addresses (I pinged from 1 to 255 and noted down all responded devices IP's).Here i am using Windows with python 2.7.x .I do also need the Network Card Manufacturer Name. In other words I just want the raw data that the WI-FI Watcher shows.

My aim to get MAC and Network Card Manufacturer Name

1 Answers1

0

First of all please make sure you ping all the hosts in your subnet. I would ping the broadcast address first, then just in case all of them, maybe some of them did not respond to your broadcast.

This way you will fill the local ARP cache of your machine. Then you can run this executable:

arp -a -v

Which will output information on all the IP addresses and their corresponding MAC address.

Then it's just a matter of looking up the OUI of the MAC address.

In pure python, as you mention in your comment, you can use "Scapy". you can find an ARP ping example here:

https://freezion.com/2009/01/22/arp-ping-using-scapy/

Basically:

from scapy import srp,Ether,ARP,conf
conf.verb=0
ans,unans=srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=sys.argv[1]),
          timeout=2)

For OUI lookup, you can use this small bit of code, although it has an external dependency:

import requests

for addr in ['88:53:2E:67:07:BE', 'FC:FB:FB:01:FA:21',
    'D4:F4:6F:C9:EF:8D', '23:45:67']:
vendor = requests.get('http://api.macvendors.com/' + addr).text
print(addr, vendor)

Also, you can try the OUI parser lib from Wireshark.

NOTE: this does not work if ICMP is disabled on the destination hosts, in that case you have to run a traditional portscan and find open ports.

santamanno
  • 626
  • 4
  • 12
  • Thanks for the help, that really helped me..But i am looking for some python program that uses some modules and functions to meet my needs(gathering the output of arp -a -v and later on filtering out the valid Devices needs quite a bit of time).Along with that I am looking for some API that can return the NIC manufacturer name.Once again Thanks for the help..Really appreciated. – sunil varma Sep 01 '19 at 12:36
  • I am getting Timed Out message when i am trying to ping my broadcast Ip .My subnet mask is 255.255.255.0 and my network is 192.168.2.x and my computer IP is 192.168.2.6 and i made the ping to 192.168.2.255 being thought that it will be as my Broadcast IP..Even now also i am pretty sure that is my Broadcast IP .Aside of this i am unable to import srp,Ether,ARP,conf from scapy on windows – sunil varma Sep 01 '19 at 14:15
  • Apologies, the windows ping command cannot ping broadcast, you can use this script from scapy: https://stackoverflow.com/a/7816003/2288436 - Also why can't you import it? Did you install the module? – santamanno Sep 01 '19 at 17:39
  • Yeah i have installed scapy module ..I am getting a error saying >>> from scapy import srp,Ether,ARP,conf Traceback (most recent call last): File "", line 1, in from scapy import srp,Ether,ARP,conf ImportError: cannot import name srp I am on python 2.7.x is that what causing this error? – sunil varma Sep 02 '19 at 11:24