mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
This commit is contained in:
@@ -4,7 +4,7 @@ import subprocess
|
|||||||
import conf
|
import conf
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from helper import timeNowTZ, get_setting, get_setting_value, list_to_where, resolve_device_name_dig, resolve_device_name_pholus, get_device_name_nslookup, check_IP_format
|
from helper import timeNowTZ, get_setting, get_setting_value, list_to_where, resolve_device_name_dig, resolve_device_name_pholus, get_device_name_nbtlookup, get_device_name_nslookup, check_IP_format
|
||||||
from logger import mylog, print_log
|
from logger import mylog, print_log
|
||||||
from const import vendorsPath, vendorsPathNewest, sql_generateGuid
|
from const import vendorsPath, vendorsPathNewest, sql_generateGuid
|
||||||
|
|
||||||
@@ -426,6 +426,7 @@ def update_devices_names (db):
|
|||||||
|
|
||||||
foundDig = 0
|
foundDig = 0
|
||||||
foundNsLookup = 0
|
foundNsLookup = 0
|
||||||
|
foundNbtLookup = 0
|
||||||
foundPholus = 0
|
foundPholus = 0
|
||||||
|
|
||||||
# Gen unknown devices
|
# Gen unknown devices
|
||||||
@@ -466,6 +467,14 @@ def update_devices_names (db):
|
|||||||
if newName != nameNotFound:
|
if newName != nameNotFound:
|
||||||
foundNsLookup += 1
|
foundNsLookup += 1
|
||||||
|
|
||||||
|
# Resolve device name with NSLOOKUP plugin data
|
||||||
|
if newName == nameNotFound:
|
||||||
|
newName = get_device_name_nbtlookup(db, device['dev_MAC'], device['dev_LastIP'])
|
||||||
|
|
||||||
|
if newName != nameNotFound:
|
||||||
|
foundNbtLookup += 1
|
||||||
|
|
||||||
|
|
||||||
# Resolve with Pholus
|
# Resolve with Pholus
|
||||||
if newName == nameNotFound:
|
if newName == nameNotFound:
|
||||||
|
|
||||||
|
|||||||
@@ -525,11 +525,11 @@ def get_device_name_nslookup(db, pMAC, pIP):
|
|||||||
Object_PrimaryID = '{pMAC}'
|
Object_PrimaryID = '{pMAC}'
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
nslookupEntry = sql.fetchall()
|
nameEntry = sql.fetchall()
|
||||||
db.commitDB()
|
db.commitDB()
|
||||||
|
|
||||||
if len(nslookupEntry) != 0:
|
if len(nameEntry) != 0:
|
||||||
name = cleanDeviceName(nslookupEntry[0][0], False)
|
name = cleanDeviceName(nameEntry[0][0], False)
|
||||||
|
|
||||||
return name
|
return name
|
||||||
|
|
||||||
@@ -542,11 +542,56 @@ def get_device_name_nslookup(db, pMAC, pIP):
|
|||||||
Object_SecondaryID = '{pIP}'
|
Object_SecondaryID = '{pIP}'
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
nslookupEntry = sql.fetchall()
|
nameEntry = sql.fetchall()
|
||||||
db.commitDB()
|
db.commitDB()
|
||||||
|
|
||||||
if len(nslookupEntry) != 0:
|
if len(nameEntry) != 0:
|
||||||
name = cleanDeviceName(nslookupEntry[0][0], True)
|
name = cleanDeviceName(nameEntry[0][0], True)
|
||||||
|
|
||||||
|
return name
|
||||||
|
|
||||||
|
return name
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
def get_device_name_nbtlookup(db, pMAC, pIP):
|
||||||
|
|
||||||
|
nameNotFound = "(name not found)"
|
||||||
|
|
||||||
|
sql = db.sql
|
||||||
|
|
||||||
|
name = nameNotFound
|
||||||
|
|
||||||
|
# get names from the NBTSCAN plugin entries vased on MAC
|
||||||
|
sql.execute(
|
||||||
|
f"""
|
||||||
|
SELECT Watched_Value2 FROM Plugins_Objects
|
||||||
|
WHERE
|
||||||
|
Plugin = 'NBTSCAN' AND
|
||||||
|
Object_PrimaryID = '{pMAC}'
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
nameEntry = sql.fetchall()
|
||||||
|
db.commitDB()
|
||||||
|
|
||||||
|
if len(nameEntry) != 0:
|
||||||
|
name = cleanDeviceName(nameEntry[0][0], False)
|
||||||
|
|
||||||
|
return name
|
||||||
|
|
||||||
|
# get names from the NSLOOKUP plugin entries based on IP
|
||||||
|
sql.execute(
|
||||||
|
f"""
|
||||||
|
SELECT Watched_Value2 FROM Plugins_Objects
|
||||||
|
WHERE
|
||||||
|
Plugin = 'NBTSCAN' AND
|
||||||
|
Object_SecondaryID = '{pIP}'
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
nameEntry = sql.fetchall()
|
||||||
|
db.commitDB()
|
||||||
|
|
||||||
|
if len(nameEntry) != 0:
|
||||||
|
name = cleanDeviceName(nameEntry[0][0], True)
|
||||||
|
|
||||||
return name
|
return name
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user