run scapy from python script .. - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: run scapy from python script .. (/thread-12715.html) Pages:
1
2
|
RE: run scapy from python script .. - evilcode1 - Sep-12-2018 (Sep-12-2018, 08:11 AM)buran Wrote: it's because your file name is scapy.py. You import your own file, not scapy package. Rename your file. okay thank u its working now ... but i have another issue i need to get all the mac address from the arp_scan() function ... and pass them to another to get the vendor for each mac this is my code ... : #! /usr/bin/python import urllib2 import json import codecs def arp_scan(): from scapy.all import srp,Ether,ARP,conf conf.verb=0 ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst="192.168.20.0/24"),timeout=2) for snd,rcv in ans: d = rcv.sprintf("%Ether.src%") print(d) arp_scan() #API base url,you can also use https if you need url = "http://macvendors.co/api/" #Mac address to lookup vendor from mac_address = arp_scan() request = urllib2.Request(url+mac_address, headers={'User-Agent' : "API Browser"}) response = urllib2.urlopen( request ) #Fix: json object must be str, not 'bytes' reader = codecs.getreader("utf-8") obj = json.load(reader(response)) #Print company name print (obj['result']['company']);error :
RE: run scapy from python script .. - ichabod801 - Sep-12-2018 Your arp_scan function does not have a return statement, so it returns None by default. So that's what mac_address gets set to, and that causes the error. You need to return the string version of whatever MAC address you're looking for from the arp_scan function. RE: run scapy from python script .. - evilcode1 - Sep-12-2018 (Sep-12-2018, 04:54 PM)ichabod801 Wrote: Your arp_scan function does not have a return statement, so it returns None by default. So that's what mac_address gets set to, and that causes the error. You need to return the string version of whatever MAC address you're looking for from the arp_scan function.how ? RE: run scapy from python script .. - ichabod801 - Sep-13-2018 With a return statement: def add_two(x): return x + 2 I'm not sure exactly what should be returned out of your function, but you would use the return statement to do it. If this is new to you, you should check out the functions tutorial (link in my signature below).
|