From ae7533cec06c427b431f13a981e149547f6ee483 Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Sun, 22 Oct 2023 09:41:38 +1100 Subject: [PATCH] =?UTF-8?q?Feature=20request=20-=20configurable=20arp-scan?= =?UTF-8?q?=20args=20#486=20=F0=9F=8E=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/plugins/arp_scan/config.json | 22 ++++++++++++++++++++++ front/plugins/arp_scan/script.py | 11 +++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/front/plugins/arp_scan/config.json b/front/plugins/arp_scan/config.json index dd55f51a..1071eec3 100755 --- a/front/plugins/arp_scan/config.json +++ b/front/plugins/arp_scan/config.json @@ -322,6 +322,28 @@ "string": "Wann Benachrichtigungen gesendet werden sollen." } ] + }, + { + "function": "ARGS", + "type": "text", + "default_value": "sudo arp-scan --ignoredups --retry=6", + "options": [], + "localized": [ + "name", + "description" + ], + "name": [ + { + "language_code": "en_us", + "string": "Arguments" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "Arguments to run arps-scan with. Recommended and tested only with the setting sudo arp-scan --ignoredups --retry=6." + } + ] } ], "database_column_definitions": [ diff --git a/front/plugins/arp_scan/script.py b/front/plugins/arp_scan/script.py index fc7f79c5..2ffa2e33 100755 --- a/front/plugins/arp_scan/script.py +++ b/front/plugins/arp_scan/script.py @@ -12,9 +12,11 @@ from time import strftime sys.path.append("/home/pi/pialert/front/plugins") sys.path.append('/home/pi/pialert/pialert') +# pialert modules +from database import DB from plugin_helper import Plugin_Object, Plugin_Objects, handleEmpty from logger import mylog, append_line_to_file -from helper import timeNowTZ +from helper import timeNowTZ, get_setting_value from const import logPath, pialertPath CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) @@ -62,6 +64,11 @@ def main(): subnets_list = userSubnetsParam.split(',') else: subnets_list = [userSubnetsParam] + + + # Create a database connection + db = DB() # instance of class DB + db.open() # Execute the ARP scanning process on the list of subnets (whether it's one or multiple subnets). # The function 'execute_arpscan' is assumed to be defined elsewhere in the code. @@ -132,7 +139,7 @@ def execute_arpscan(userSubnets): def execute_arpscan_on_interface(interface): # Prepare command arguments - arpscan_args = ['sudo', 'arp-scan', '--ignoredups', '--retry=6'] + interface.split() + arpscan_args = get_setting_value('ARPSCAN_ARGS').split() + interface.split() # Execute command try: