mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
vendor_update plugin
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
Plugin to run regular database cleanup tasks. It is strongly recommended to have an hourly or at least daily schedule running.
|
A plugin to retrieve a MAC and vendor database to identify vendors for devices.
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ logPath = pialertPath + '/front/log'
|
|||||||
apiPath = pialertPath + '/front/api/'
|
apiPath = pialertPath + '/front/api/'
|
||||||
fullConfPath = pialertPath + confPath
|
fullConfPath = pialertPath + confPath
|
||||||
fullDbPath = pialertPath + dbPath
|
fullDbPath = pialertPath + dbPath
|
||||||
vendorsPath = '/usr/share/arp-scan/ieee-oui.txt'
|
vendorsPath6 = '/usr/share/arp-scan/ieee-oui.txt'
|
||||||
|
vendorsPath9 = '/usr/share/arp-scan/ieee-iab.txt'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import re
|
|||||||
from helper import timeNowTZ, get_setting, get_setting_value,resolve_device_name_dig, resolve_device_name_pholus
|
from helper import timeNowTZ, get_setting, get_setting_value,resolve_device_name_dig, resolve_device_name_pholus
|
||||||
from scanners.internet import check_IP_format, get_internet_IP
|
from scanners.internet import check_IP_format, get_internet_IP
|
||||||
from logger import mylog, print_log
|
from logger import mylog, print_log
|
||||||
from const import vendorsPath
|
from const import vendorsPath6, vendorsPath9
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -328,14 +328,22 @@ def query_MAC_vendor (pMAC):
|
|||||||
return -2 # return -2 if ignored MAC
|
return -2 # return -2 if ignored MAC
|
||||||
|
|
||||||
# Search vendor in HW Vendors DB
|
# Search vendor in HW Vendors DB
|
||||||
mac_start_string = mac[0:6]
|
mac_start_string6 = mac[0:6]
|
||||||
|
mac_start_string9 = mac[0:9]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(vendorsPath, 'r') as f:
|
with open(vendorsPath6, 'r') as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
if line.startswith(mac_start_string):
|
if line.startswith(mac_start_string6):
|
||||||
vendor = line.split(' ', 1)[1].strip()
|
vendor = line.split(' ', 1)[1].strip()
|
||||||
mylog('debug', [f"[Vendor Check] Found '{vendor}' for '{pMAC}'"])
|
mylog('debug', [f"[Vendor Check] Found '{vendor}' for '{pMAC}' in {vendorsPath6}"])
|
||||||
|
return vendor
|
||||||
|
|
||||||
|
with open(vendorsPath9, 'r') as f:
|
||||||
|
for line in f:
|
||||||
|
if line.startswith(mac_start_string9):
|
||||||
|
vendor = line.split(' ', 1)[1].strip()
|
||||||
|
mylog('debug', [f"[Vendor Check] Found '{vendor}' for '{pMAC}' in {vendorsPath9}"])
|
||||||
return vendor
|
return vendor
|
||||||
|
|
||||||
return -1 # MAC address not found in the database
|
return -1 # MAC address not found in the database
|
||||||
|
|||||||
@@ -76,6 +76,9 @@ def importConfigs (db):
|
|||||||
# Header
|
# Header
|
||||||
updateState("Import config", showSpinner = True)
|
updateState("Import config", showSpinner = True)
|
||||||
|
|
||||||
|
# remove all plugin langauge strings
|
||||||
|
sql.execute("DELETE FROM Plugins_Language_Strings;")
|
||||||
|
|
||||||
mylog('debug', ['[Import Config] importing config file'])
|
mylog('debug', ['[Import Config] importing config file'])
|
||||||
conf.mySettings = [] # reset settings
|
conf.mySettings = [] # reset settings
|
||||||
conf.mySettingsSQLsafe = [] # same as above but safe to be passed into a SQL query
|
conf.mySettingsSQLsafe = [] # same as above but safe to be passed into a SQL query
|
||||||
|
|||||||
Reference in New Issue
Block a user