arp-scan mylog

This commit is contained in:
Jokob-sk
2023-08-25 08:14:06 +10:00
parent 17c3dc4914
commit 8038fc9472
2 changed files with 16 additions and 10 deletions

View File

@@ -6,13 +6,14 @@
### Script based plugins ### Script based plugins
- [arp_scan (ARPSCAN)](/front/plugins/arp_scan/)
- [website_monitor (WEBMON)](/front/plugins/website_monitor/) - [website_monitor (WEBMON)](/front/plugins/website_monitor/)
- [dhcp_servers (DHCPSRVS)](/front/plugins/dhcp_servers/) - [dhcp_servers (DHCPSRVS)](/front/plugins/dhcp_servers/)
- [dhcp_leases (DHCPLSS)](/front/plugins/dhcp_leases/) - [dhcp_leases (DHCPLSS)](/front/plugins/dhcp_leases/)
- [unifi_import (UNFIMP)](/front/plugins/unifi_import/) - [unifi_import (UNFIMP)](/front/plugins/unifi_import/)
- [snmp_discovery (SNMPDSC)](/front/plugins/snmp_discovery/) - [snmp_discovery (SNMPDSC)](/front/plugins/snmp_discovery/)
- [undiscoverables (UNDIS)](/front/plugins/undiscoverables/) - [undiscoverables (UNDIS)](/front/plugins/undiscoverables/)
- [arp_scan (ARPSCAN)](/front/plugins/arp_scan/) - [pholus_scan (ARPSCAN)](/front/plugins/pholus_scan/)
- [set_password (SETPWD)](/front/plugins/set_password/) - [set_password (SETPWD)](/front/plugins/set_password/)
### SQL query based plugins ### SQL query based plugins

View File

@@ -10,8 +10,12 @@ import subprocess
from time import strftime from time import strftime
sys.path.append("/home/pi/pialert/front/plugins") sys.path.append("/home/pi/pialert/front/plugins")
sys.path.append('/home/pi/pialert/pialert')
from plugin_helper import Plugin_Object, Plugin_Objects from plugin_helper import Plugin_Object, Plugin_Objects
from logger import mylog
from helper import timeNowTZ
from const import logPath, pialertPath
CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) 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')
@@ -33,26 +37,27 @@ def main():
devices = Plugin_Objects(RESULT_FILE) devices = Plugin_Objects(RESULT_FILE)
# Print a message to indicate that the script is starting. # Print a message to indicate that the script is starting.
print('In script:') mylog('debug', ['[ARP Scan] In script '])
# Assuming 'values' is a dictionary or object that contains a key 'userSubnets' # Assuming 'values' is a dictionary or object that contains a key 'userSubnets'
# which holds a list of user-submitted subnets. # which holds a list of user-submitted subnets.
# Printing the userSubnets list to check its content. # Printing the userSubnets list to check its content.
print(values.userSubnets) mylog('debug', ['[ARP Scan] values.userSubnets: ', values.userSubnets])
# Extract the base64-encoded subnet information from the first element of the userSubnets list. # Extract the base64-encoded subnet information from the first element of the userSubnets list.
# The format of the element is assumed to be like 'userSubnets=b<base64-encoded-data>'. # The format of the element is assumed to be like 'userSubnets=b<base64-encoded-data>'.
userSubnetsParamBase64 = values.userSubnets[0].split('userSubnets=b')[1] userSubnetsParamBase64 = values.userSubnets[0].split('userSubnets=b')[1]
# Printing the extracted base64-encoded subnet information. # Printing the extracted base64-encoded subnet information.
print(userSubnetsParamBase64) mylog('debug', ['[ARP Scan] userSubnetsParamBase64: ', userSubnetsParamBase64])
# Decode the base64-encoded subnet information to get the actual subnet information in ASCII format. # Decode the base64-encoded subnet information to get the actual subnet information in ASCII format.
userSubnetsParam = base64.b64decode(userSubnetsParamBase64).decode('ascii') userSubnetsParam = base64.b64decode(userSubnetsParamBase64).decode('ascii')
# Print the decoded subnet information. # Print the decoded subnet information.
print('userSubnetsParam:') mylog('debug', ['[ARP Scan] userSubnetsParam: ', userSubnetsParam])
print(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.
@@ -94,7 +99,7 @@ def execute_arpscan(userSubnets):
arpscan_output = execute_arpscan_on_interface (interface) arpscan_output = execute_arpscan_on_interface (interface)
print(arpscan_output) mylog('debug', ['[ARP Scan] 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]))'
@@ -121,10 +126,10 @@ def execute_arpscan(userSubnets):
unique_devices.append(device) unique_devices.append(device)
# return list # return list
# mylog('debug', ['[ARP Scan] Found: Devices without duplicates ', len(unique_devices) ]) mylog('debug', ['[ARP Scan] Found: Devices without duplicates ', len(unique_devices) ])
print("Devices List len:", len(devices_list)) # Add this line to print devices_list mylog('debug', ["Devices List len:", len(devices_list)]) # Add this line to print devices_list
print("Devices List:", devices_list) # Add this line to print devices_list mylog('debug',["Devices List:", devices_list]) # Add this line to print devices_list
return devices_list return devices_list