mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 01:26:11 -08:00
✨Added filters to plugins
This commit is contained in:
@@ -28,6 +28,7 @@ CUR_PATH = str(pathlib.Path(__file__).parent.resolve())
|
|||||||
LOG_FILE = os.path.join(CUR_PATH, 'script.log')
|
LOG_FILE = os.path.join(CUR_PATH, 'script.log')
|
||||||
RESULT_FILE = os.path.join(CUR_PATH, 'last_result.log')
|
RESULT_FILE = os.path.join(CUR_PATH, 'last_result.log')
|
||||||
|
|
||||||
|
pluginName = 'ARPSCAN'
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
@@ -58,7 +59,7 @@ def main():
|
|||||||
userSubnetsParam = base64.b64decode(userSubnetsParamBase64).decode('ascii')
|
userSubnetsParam = base64.b64decode(userSubnetsParamBase64).decode('ascii')
|
||||||
|
|
||||||
# Print the decoded subnet information.
|
# Print the decoded subnet information.
|
||||||
mylog('verbose', ['[ARP Scan] userSubnetsParam: ', userSubnetsParam])
|
mylog('verbose', [f'[{pluginName}] userSubnetsParam: ', userSubnetsParam])
|
||||||
|
|
||||||
# Check if the decoded subnet information contains multiple subnets separated by commas.
|
# Check if the decoded subnet information contains multiple subnets separated by commas.
|
||||||
# If it does, split the string into a list of individual subnets.
|
# If it does, split the string into a list of individual subnets.
|
||||||
@@ -86,7 +87,7 @@ def main():
|
|||||||
watched2 = handleEmpty(device.get('hw', '')), # Vendor (assuming it's in the 'hw' field)
|
watched2 = handleEmpty(device.get('hw', '')), # Vendor (assuming it's in the 'hw' field)
|
||||||
watched3 = handleEmpty(device.get('interface', '')), # Add the interface
|
watched3 = handleEmpty(device.get('interface', '')), # Add the interface
|
||||||
watched4 = '',
|
watched4 = '',
|
||||||
extra = 'arp-scan',
|
extra = pluginName,
|
||||||
foreignKey = "")
|
foreignKey = "")
|
||||||
|
|
||||||
plugin_objects.write_result_file()
|
plugin_objects.write_result_file()
|
||||||
@@ -105,7 +106,7 @@ def execute_arpscan(userSubnets):
|
|||||||
|
|
||||||
arpscan_output = execute_arpscan_on_interface (interface)
|
arpscan_output = execute_arpscan_on_interface (interface)
|
||||||
|
|
||||||
mylog('verbose', ['[ARP Scan] arpscan_output: ', arpscan_output])
|
mylog('verbose', [f'[{pluginName}] arpscan_output: ', arpscan_output])
|
||||||
|
|
||||||
# Search IP + MAC + Vendor as regular expresion
|
# Search IP + MAC + Vendor as regular expresion
|
||||||
re_ip = r'(?P<ip>((2[0-5]|1[0-9]|[0-9])?[0-9]\.){3}((2[0-5]|1[0-9]|[0-9])?[0-9]))'
|
re_ip = r'(?P<ip>((2[0-5]|1[0-9]|[0-9])?[0-9]\.){3}((2[0-5]|1[0-9]|[0-9])?[0-9]))'
|
||||||
@@ -132,10 +133,10 @@ def execute_arpscan(userSubnets):
|
|||||||
unique_devices.append(device)
|
unique_devices.append(device)
|
||||||
|
|
||||||
# return list
|
# return list
|
||||||
mylog('verbose', ['[ARP Scan] Found: Devices without duplicates ', len(unique_devices) ])
|
mylog('verbose', [f'[{pluginName}] Found: Devices without duplicates ', len(unique_devices) ])
|
||||||
|
|
||||||
mylog('verbose', ["Devices List len:", len(devices_list)]) # Add this line to print devices_list
|
mylog('verbose', [f'[{pluginName}] Devices List len:', len(devices_list)])
|
||||||
mylog('verbose',["Devices List:", devices_list]) # Add this line to print devices_list
|
mylog('verbose', [f'[{pluginName}] Devices List:', devices_list])
|
||||||
|
|
||||||
return devices_list
|
return devices_list
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,15 @@
|
|||||||
"data_source": "script",
|
"data_source": "script",
|
||||||
"execution_order" : "Layer_3",
|
"execution_order" : "Layer_3",
|
||||||
"show_ui": true,
|
"show_ui": true,
|
||||||
|
"data_filters": [
|
||||||
|
{
|
||||||
|
"compare_column": "Object_PrimaryID",
|
||||||
|
"compare_operator": "==",
|
||||||
|
"compare_field_id": "txtMacFilter",
|
||||||
|
"compare_js_template": "'{value}'.toString()",
|
||||||
|
"compare_use_quotes": true
|
||||||
|
}
|
||||||
|
],
|
||||||
"localized": ["display_name", "description", "icon"],
|
"localized": ["display_name", "description", "icon"],
|
||||||
"display_name": [
|
"display_name": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,6 +6,15 @@
|
|||||||
"data_source": "script",
|
"data_source": "script",
|
||||||
"execution_order" : "Layer_3",
|
"execution_order" : "Layer_3",
|
||||||
"show_ui": true,
|
"show_ui": true,
|
||||||
|
"data_filters": [
|
||||||
|
{
|
||||||
|
"compare_column": "Object_PrimaryID",
|
||||||
|
"compare_operator": "==",
|
||||||
|
"compare_field_id": "txtMacFilter",
|
||||||
|
"compare_js_template": "'{value}'.toString()",
|
||||||
|
"compare_use_quotes": true
|
||||||
|
}
|
||||||
|
],
|
||||||
"localized": ["display_name", "description", "icon"],
|
"localized": ["display_name", "description", "icon"],
|
||||||
"display_name": [
|
"display_name": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,6 +6,15 @@
|
|||||||
"enabled": true,
|
"enabled": true,
|
||||||
"data_source": "script",
|
"data_source": "script",
|
||||||
"show_ui": true,
|
"show_ui": true,
|
||||||
|
"data_filters": [
|
||||||
|
{
|
||||||
|
"compare_column": "Object_PrimaryID",
|
||||||
|
"compare_operator": "==",
|
||||||
|
"compare_field_id": "txtMacFilter",
|
||||||
|
"compare_js_template": "'{value}'.toString()",
|
||||||
|
"compare_use_quotes": true
|
||||||
|
}
|
||||||
|
],
|
||||||
"localized": ["display_name", "description", "icon"],
|
"localized": ["display_name", "description", "icon"],
|
||||||
"display_name": [
|
"display_name": [
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user