def get(mac_address, settings): api_client = ApiClient(settings["macaddress_io_api_key"]) try: response = api_client.get_raw_data(mac_address, 'json') return json.loads(response) except maclookup_exceptions.EmptyResponseException: raise LookupError('Empty response') except maclookup_exceptions.UnparsableResponseException: raise LookupError('Unparsable response') except maclookup_exceptions.ServerErrorException: raise LookupError('Internal server error') except maclookup_exceptions.UnknownOutputFormatException: raise LookupError('Unknown output') except maclookup_exceptions.AuthorizationRequiredException: raise LookupError('Authorization required') except maclookup_exceptions.AccessDeniedException: raise LookupError('Access denied') except maclookup_exceptions.InvalidMacOrOuiException: raise LookupError('Invalid MAC or OUI') except maclookup_exceptions.NotEnoughCreditsException: raise LookupError('Not enough credits') except Exception: raise LookupError('Unknown error')
def getvendor(macaddress): try: #client = ApiClient('at_UfWgZ7z8ilVI5fZyXvp84PJzMW2Hj') client = ApiClient(apikey) logging.basicConfig(filename='myapp.log', level=logging.WARNING) print(client.get_vendor(macaddress)) except Exception as e: print("Not_found")
def scan(self, ip): ARP = scapy.ARP(pdst=ip) Ether = scapy.Ether(dst="ff:ff:ff:ff:ff:ff") packet = Ether / ARP ans = scapy.srp(packet, timeout=2, verbose=False)[0] client_list = [] for element in ans: MAC = element[1].hwsrc vendor = ApiClient("at_yS7J9zWswF0lxuKHa6b3352LuTOTs") client_dict = { "IP": element[1].psrc, "MAC": MAC, "Vendor": str(vendor.get_vendor(MAC).decode()) } client_list.append(client_dict) return client_list
def cli(macs, api_key, limit, vendor, separator, mac_with_vendor, ignore_errors): ''' MACs: List of MAC addresses. Also you can input your MACs to the STDIN, one per line. Example: $ macaddress-info -mV f4:0f:24:36:da:57 f4:0f:24:36:da:57 - Apple, Inc $ ''' client = ApiClient(api_key) if not isinstance(macs, tuple) or len(macs) == 0: macs = read_macs_from_stdin() count = 0 for mac in macs: if count >= limit and limit > 0: break count += 1 try: model = make_request(str(mac).strip(), client) except IgnorableError as error: if ignore_errors: continue else: exit(error.code) except FatalError as error: exit(error.code) if vendor: print_vendor(model, mac, separator, mac_with_vendor) else: print_full_info(model, mac, separator)
from maclookup import ApiClient from io import open import logging import os api_key = os.environ['API_KEY'] log_file = os.environ['LOG_FILENAME'] output_file = os.environ['OUTPUT_FILENAME'] client = ApiClient(api_key) logging.basicConfig(filename=log_file, level=logging.WARNING) csv_data = client.get_raw_data('08EA4026E5DE', 'csv') f = open(output_file, 'w', encoding='utf-8') f.write(csv_data)
def handler(q=False): if q is False: return False request = json.loads(q) if request.get('mac-address'): mac_address = request['mac-address'] else: return False if request.get('config') and request['config'].get('api_key'): api_key = request['config'].get('api_key') else: misperrors['error'] = 'Authorization required' return misperrors api_client = ApiClient(api_key) try: response = api_client.get(mac_address) except exceptions.EmptyResponseException: misperrors['error'] = 'Empty response' return misperrors except exceptions.UnparsableResponseException: misperrors['error'] = 'Unparsable response' return misperrors except exceptions.ServerErrorException: misperrors['error'] = 'Internal server error' return misperrors except exceptions.UnknownOutputFormatException: misperrors['error'] = 'Unknown output' return misperrors except exceptions.AuthorizationRequiredException: misperrors['error'] = 'Authorization required' return misperrors except exceptions.AccessDeniedException: misperrors['error'] = 'Access denied' return misperrors except exceptions.InvalidMacOrOuiException: misperrors['error'] = 'Invalid MAC or OUI' return misperrors except exceptions.NotEnoughCreditsException: misperrors['error'] = 'Not enough credits' return misperrors except Exception: misperrors['error'] = 'Unknown error' return misperrors date_created = \ response.block_details.date_created.strftime('%d %B %Y') if response.block_details.date_created else None date_updated = \ response.block_details.date_updated.strftime('%d %B %Y') if response.block_details.date_updated else None results = { 'results': [{ 'types': ['text'], 'values': { # Mac address details 'Valid MAC address': "True" if response.mac_address_details.is_valid else "False", 'Transmission type': response.mac_address_details.transmission_type, 'Administration type': response.mac_address_details.administration_type, # Vendor details 'OUI': response.vendor_details.oui, 'Vendor details are hidden': "True" if response.vendor_details.is_private else "False", 'Company name': response.vendor_details.company_name, 'Company\'s address': response.vendor_details.company_address, 'County code': response.vendor_details.country_code, # Block details 'Block found': "True" if response.block_details.block_found else "False", 'The left border of the range': response.block_details.border_left, 'The right border of the range': response.block_details.border_right, 'The total number of MAC addresses in this range': response.block_details.block_size, 'Assignment block size': response.block_details.assignment_block_size, 'Date when the range was allocated': date_created, 'Date when the range was last updated': date_updated } }] } return results
from maclookup import ApiClient import logging import os api_key = os.environ['API_KEY'] log_file = os.environ['LOG_FILENAME'] client = ApiClient(api_key) logging.basicConfig(filename=log_file, level=logging.WARNING) print(client.get_raw_data('08EA4026E5DE', 'csv')) print(client.get_vendor('08EA4026E5DE')) response = client.get('08EA4026E5DE') print(response.vendor_details.is_private) print(response.block_details.block_size)
from maclookup import ApiClient import logging client = ApiClient('at_kmyQbPqQZGvWMGFf3fLYGqdQM11DQ') logging.basicConfig(filename='myapp.log', level=logging.WARNING) mac = str(input("Pleas enter the MAC address: ")) print(client.get_vendor(mac))
from maclookup import ApiClient import logging import os api_key = os.environ['API_KEY'] log_file = os.environ['LOG_FILENAME'] client = ApiClient(api_key) logging.basicConfig(filename=log_file, level=logging.WARNING) print(client.get_vendor('08EA4026E5DE'))
import csv from maclookup import ApiClient import json import pandas as pd #import wifi data wigle_wifi = pd.read_csv('WigleWifi_all.csv', encoding='utf-8') df = pd.DataFrame(wigle_wifi) wifiList = list(df['MAC']) #establish client to maclookup client = ApiClient('at_vsEFrkTL6alaO3fzbu3JgaaWnb2j1') #create a dictionary to hold frequency of oui found dict = {} #process the csv, extract the mac for counter, value in enumerate(wifiList): #call maclookup using the mac mac = value print(f'Looking up {mac}') response = client.get(mac) oui = response.vendor_details.oui name = response.vendor_details.company_name #update the data frame by adding the meta data df.loc[:, 'OUI'] = oui df.loc[:, 'NAME'] = name #update dictionary
import sys import time import scapy.all as scapy import json import os from pymongo import MongoClient from maclookup import ApiClient # Mac lookup client - free for 1000 requests mac_client = ApiClient("at_JsS3YEzdvi4nFYAQBUF5oQMe9tAYb") # MongoDB connection client = MongoClient('localhost', 27017) db = client['deauth_attacks'] attacks = db.attacks # Router mac HARDCODED_ROUTER_MAC = "20:4e:7f:0e:df:46" # Monitor mode wifi card monitor_device = os.environ.get('monitorDevice') class DeauthenticationDetector: def __init__(self, *args, **kwargs): ''' All Arguments And Keywords Will Directly Passed To Python Scapy Sniff Function. ''' self.args = args
from maclookup import ApiClient import sys import json import os mykey = os.environ.get('MY_KEY') if mykey == None: mykey = "at_EYedF482zqmiTdQyerFKVsBKlFNfc" #Get the movie name mac_addr = sys.argv[1] if len(mac_addr) == 0: print("Mac address missing") sys.exit() client = ApiClient(mykey) try: #vendor = client.get_vendor(mac_addr) #print ("Mac address: {} is for vendor: {}".format(mac_addr, vendor)) response = client.get_raw_data(mac_addr, 'json') json_text = json.loads(response) vendor = json_text['vendorDetails']['companyName'] if (len(vendor) > 0): print("Mac address: {} is for vendor: {}".format(mac_addr, vendor)) else: print("Mac address: {} does not match to any vendor".format(mac_addr)) except Exception as e:
from maclookup import ApiClient import logging client = ApiClient('at_gVL2VUlnXzRjD9mkj70Avd6bqgdkm') logging.basicConfig(filename='myapp.log', level=logging.WARNING) print(client.get_raw_data('00A043AAAAAA', 'json')) print(client.get_vendor('BBA043AAAAAA')) print(client.get('BBA043AAAAAA')) response = client.get('00A043AAAAAA') print(response.vendor_details.is_private) print(response.block_details.date_created)
from maclookup import ApiClient import logging import sys mac_add = sys.argv[1] client = ApiClient('at_vUodAqdRDWPiGqHCiTu22Jlvc8Snq') logging.basicConfig(filename='myapp.log', level=logging.WARNING) company_name = client.get_vendor(mac_add) print "Company Name of MAC ID: ", mac_add, "is - ", company_name
from maclookup import ApiClient import json import sys, os api_key = os.environ['API_KEY'] client = ApiClient(api_key) try: macData = json.loads(client.get_raw_data(sys.argv[1], "json")) except: print "Not a valid MAC address" sys.exit(1) for key, val in macData.items(): print "-------", key, "-------" for skey, sval in val.items(): print skey, "=>", sval
import json import telepot from telepot.loop import MessageLoop from telepot.namedtuple import InlineQueryResultArticle, InputTextMessageContent from maclookup import ApiClient import pymongo from pymongo import MongoClient import analyser mac_client = ApiClient('APIKEY') bot = telepot.Bot('APIKEY') connection_params = { 'user': '******', 'password': '******', 'host': 'example.mlab.com', 'port': 54321, 'namespace': 'metadata', } connection = MongoClient( 'mongodb://{user}:{password}@{host}:' '{port}/{namespace}'.format(**connection_params) )
from maclookup import ApiClient import logging import sys macId=sys.argv[1] client = ApiClient('at_i71LdFJWTwrNovpdIN2hzcJhlKajw') logging.basicConfig(filename='myapp.log', level=logging.WARNING) response = client.get(macId) print(response.vendor_details.company_name)