🔌NBTSCAN plugin #693
Some checks are pending
docker / docker_dev (push) Waiting to run

This commit is contained in:
jokob-sk
2024-07-11 15:56:29 +10:00
parent d7d7306a85
commit 8e7e0afb1e
2 changed files with 61 additions and 7 deletions

View File

@@ -4,7 +4,7 @@ import subprocess
import conf
import os
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 const import vendorsPath, vendorsPathNewest, sql_generateGuid
@@ -426,6 +426,7 @@ def update_devices_names (db):
foundDig = 0
foundNsLookup = 0
foundNbtLookup = 0
foundPholus = 0
# Gen unknown devices
@@ -466,6 +467,14 @@ def update_devices_names (db):
if newName != nameNotFound:
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
if newName == nameNotFound:

View File

@@ -525,11 +525,11 @@ def get_device_name_nslookup(db, pMAC, pIP):
Object_PrimaryID = '{pMAC}'
"""
)
nslookupEntry = sql.fetchall()
nameEntry = sql.fetchall()
db.commitDB()
if len(nslookupEntry) != 0:
name = cleanDeviceName(nslookupEntry[0][0], False)
if len(nameEntry) != 0:
name = cleanDeviceName(nameEntry[0][0], False)
return name
@@ -542,11 +542,56 @@ def get_device_name_nslookup(db, pMAC, pIP):
Object_SecondaryID = '{pIP}'
"""
)
nslookupEntry = sql.fetchall()
nameEntry = sql.fetchall()
db.commitDB()
if len(nslookupEntry) != 0:
name = cleanDeviceName(nslookupEntry[0][0], True)
if len(nameEntry) != 0:
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