import scapy.all as scapy
import requests
import json
This code work with API for getting information about venders
def vender_finding(mac_adr):
mac_url = 'http://macvendors.co/api/%s'
vender = (requests.get(mac_url % mac_adr))
response_dict = json.loads(json.dumps(vender.json()))
return response_dict['result']['company']
This code returns all devices connected to the network. result is something like this
def scan(ip):
arp_request = scapy.ARP(pdst=ip)
broadcast = scapy.Ether(dst="ff:ff:ff:ff:ff:ff")
arp_request_broadcast = broadcast/arp_request
This is the line which gives an error
answered_list = scapy.srp(arp_request_broadcast, timeout=1, verbose=False)[0]
clents_list = []
for element in answered_list[1:]:
company = vender_finding(element[1].hwsrc)
clent_dict = {"ip": element[1].psrc, "mac": element[1].hwsrc, "vender": company}
clents_list.append(clent_dict)
print(clents_list)
return clents_list
scan('192.168.1.0/24')
but now its return error like this. In here now a new error starts to occur.
answered_list = scapy.srp(arp_request_broadcast, timeout=1, verbose=False)[0]
This the error that I am getting.
raise ValueError("Unknown network interface %r" % name)
ValueError: Unknown network interface None
By installing the following software issue solved.
1.python 2.7.2 from python.org
2.Microsoft Visual C++ Compiler for Python 2.7 from https://www.microsoft.com/en-us/download/confirmation.aspx?id=44266.
(check this link for more. Microsoft Visual C++ 9.0 is required)
3.pip install scapy==2.4.3rc1 (this is recommended by StackOverflow contributor. this work very well.)
(check these link answer for a recommendation by user Cukic0d. GUID number of windows interface giving error: ValueError: Unknown network interface '{1619EEF1-4D71-4831-87AC-8E5DC3AA516A}')
4.winpcap (to perform scapy sniff() must install this)
Install python 2.7.2 and then install Microsoft Visual C++ Compiler for Python 2.7