Author Topic: Determine MAC vendor with online API  (Read 2942 times)

0 Members and 1 Guest are viewing this topic.

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Determine MAC vendor with online API
« on: July 28, 2020, 07:03:25 am »
Getting tired of censoring my API key so I'm leaving it in again. Here is some code you can use to find the vendor for any MAC address using CURL. Please be good sports and go to macvendors.com and get your own API keys before you run tons of requests, though.

Code: QB64: [Select]
  1. PRINT "MAC Vendor: "; MACVendor("AB-CD-EF-GH-IJ-KL")
  2.  
  3. FUNCTION MACVendor$ (MAC AS STRING)
  4.     DIM URL AS STRING
  5.     DIM URLFile AS STRING
  6.     URLFile = "macvendorrequest"
  7.     SHELL _HIDE "curl -G " + CHR$(34) + "https://api.macvendors.com/v1/lookup/" + MAC + CHR$(34) + " -H " + CHR$(34) + "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiIsImp0aSI6IjllMmQ0YzYwLTU3NmQtNDI2OC04NDdkLWIyYTUwNGEyM2ZhMCJ9.eyJpc3MiOiJtYWN2ZW5kb3JzIiwiYXVkIjoibWFjdmVuZG9ycyIsImp0aSI6IjllMmQ0YzYwLTU3NmQtNDI2OC04NDdkLWIyYTUwNGEyM2ZhMCIsImlhdCI6MTU5NTkzMzc1OSwiZXhwIjoxOTEwNDI5NzU5LCJzdWIiOiI3NTkyIiwidHlwIjoiYWNjZXNzIn0.9MTN3PlkFxHAokvIKFFtF1aJYdXwjFpC2etMejJ-V4l9NCbT_qhqF-BpNv25h9kpDfntyGWCMXvqs6s9ShEbkw" + CHR$(34) + " -H " + CHR$(34) + "Accept: text/plain" + CHR$(34) + " -o " + URLFile
  8.     DIM U AS INTEGER
  9.     U = FREEFILE
  10.     OPEN URLFile FOR BINARY AS #U
  11.     IF LOF(U) <> 0 THEN
  12.         DIM macvendorrequest AS STRING
  13.         macvendorrequest = SPACE$(LOF(U))
  14.         GET #U, , macvendorrequest
  15.     ELSE
  16.         CLOSE #U
  17.         KILL URLFile
  18.         MACVendor = ""
  19.         EXIT FUNCTION
  20.     END IF
  21.     CLOSE #U
  22.     KILL URLFile
  23.     MACVendor = macvendorrequest
« Last Edit: July 28, 2020, 07:57:22 am by SpriggsySpriggs »
Shuwatch!