1
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

the result of this code

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
3
  • Could you provide your plateform/OS/Python version/scapy version ? Also the value of scapy.conf.iface ? That would help figuring out what the problem is :) Commented Mar 10, 2019 at 22:39
  • scapy 2.4.0. with npcap, windows 8.1 and python 3.7.2 Commented Mar 10, 2019 at 23:26
  • print(scapy.conf.iface) result = None Commented Mar 10, 2019 at 23:27

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

1

You can try "iface" with your network interface. Ex:

sendp(Ether()/IP(dst="1.2.3.4",ttl=(1,4)), iface="eth1")

More info: https://scapy.readthedocs.io/en/latest/usage.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.