v2.60 - Improved installation process

This commit is contained in:
pucherot
2021-01-19 23:11:01 +01:00
parent 9eee7f156e
commit a850eb4269
13 changed files with 111 additions and 42 deletions

View File

@@ -1,40 +0,0 @@
#-------------------------------------------------------------------------------
# Pi.Alert v2.56 / 2021-01-15
# Open Source Network Guard / WIFI & LAN intrusion detector
#
# pialert.conf - Back module. Configuration file
#-------------------------------------------------------------------------------
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3
#-------------------------------------------------------------------------------
VERSION = '2.56'
VERSION_YEAR = '2021'
VERSION_DATE = '2021-01-15'
DB_PATH = '/home/pi/pialert/db/pialert.db'
LOG_PATH = '/home/pi/pialert/log'
VENDORS_DB = '/usr/share/arp-scan/ieee-oui.txt'
PA_FRONT_URL = 'http://pi.alert/deviceDetails.php?mac='
PRINT_LOG = False
SMTP_SERVER = 'smtp.gmail.com'
SMTP_PORT = 587
SMTP_USER = 'user@gmail.com'
SMTP_PASS = 'password'
REPORT_MAIL = False
REPORT_FROM = 'Pi.Alert <' + SMTP_USER +'>'
REPORT_TO = 'user@gmail.com'
# QUERY_MYIP_SERVER = 'https://diagnostic.opendns.com/myip'
QUERY_MYIP_SERVER = 'http://ipv4.icanhazip.com'
DDNS_ACTIVE = False
DDNS_DOMAIN = 'your_domain.freeddns.org'
DDNS_USER = 'dynu_user'
DDNS_PASSWORD = 'A0000000B0000000C0000000D0000000'
DDNS_UPDATE_URL = 'https://api.dynu.com/nic/update?'
PIHOLE_ACTIVE = False
PIHOLE_DB = '/etc/pihole/pihole-FTL.db'
DHCP_ACTIVE = False
DHCP_LEASES = '/etc/pihole/dhcp.leases'

View File

@@ -1,13 +0,0 @@
#-------------------------------------------------------------------------------
# Pi.Alert
# Open Source Network Guard / WIFI & LAN intrusion detector
#
# pialert.cron - Back module. Crontab jobs
#-------------------------------------------------------------------------------
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3
#-------------------------------------------------------------------------------
0 3 * * 1 python ~/pialert/back/pialert.py update_vendors >~/pialert/log/pialert.vendors.log 2>&1
*/1 * * * * python ~/pialert/back/pialert.py internet_IP >~/pialert/log/pialert.IP.log 2>&1
*/5 * * * * python ~/pialert/back/pialert.py 1 >~/pialert/log/pialert.1.log 2>&1
*/15 * * * * python ~/pialert/back/pialert.py 15 >~/pialert/log/pialert.15.log 2>&1

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env python
#
#-------------------------------------------------------------------------------
# Pi.Alert v2.56 / 2021-01-15
# Pi.Alert v2.60 / 2021-01-20
# Open Source Network Guard / WIFI & LAN intrusion detector
#
# pialert.py - Back module. Network scanner
@@ -32,11 +32,15 @@ import csv
#===============================================================================
# CONFIG CONSTANTS
#===============================================================================
PIALERT_PATH = os.path.dirname(os.path.abspath(__file__))
PIALERT_BACK_PATH = os.path.dirname(os.path.abspath(__file__))
PIALERT_PATH = PIALERT_BACK_PATH + "/.."
if (sys.version_info > (3,0)):
exec(open(PIALERT_PATH + "/pialert.conf").read())
exec(open(PIALERT_PATH + "/config/version.conf").read())
exec(open(PIALERT_PATH + "/config/pialert.conf").read())
else:
execfile (PIALERT_PATH + "/pialert.conf")
execfile (PIALERT_PATH + "/config/version.conf")
execfile (PIALERT_PATH + "/config/pialert.conf")
#===============================================================================
@@ -54,7 +58,6 @@ def main ():
print ('---------------------------------------------------------')
# Initialize global variables
# PIALERT_PATH = os.path.dirname(os.path.abspath(__file__))
log_timestamp = datetime.datetime.now()
# DB
@@ -254,7 +257,7 @@ def update_devices_MAC_vendors ():
# Update vendors DB (iab oui)
print ('\nUpdating vendors DB (iab & oui)...')
update_args = ['sh', PIALERT_PATH + '/vendors_db_update.sh']
update_args = ['sh', PIALERT_BACK_PATH + '/vendors_db_update.sh']
update_output = subprocess.check_output (update_args)
# DEBUG
# update_args = ['./vendors_db_update.sh']
@@ -1049,12 +1052,12 @@ def email_reporting ():
openDB()
# Open text Template
template_file = open(PIALERT_PATH + '/report_template.txt', 'r')
template_file = open(PIALERT_BACK_PATH + '/report_template.txt', 'r')
mail_text = template_file.read()
template_file.close()
# Open html Template
template_file = open(PIALERT_PATH + '/report_template.html', 'r')
template_file = open(PIALERT_BACK_PATH + '/report_template.html', 'r')
mail_html = template_file.read()
template_file.close()
@@ -1099,7 +1102,7 @@ def email_reporting ():
eventAlert['eve_EventType'], eventAlert['eve_DateTime'],
eventAlert['eve_IP'], eventAlert['eve_AdditionalInfo'])
mail_html_Internet += html_line_template.format (
PA_FRONT_URL, eventAlert['eve_MAC'],
REPORT_DEVICE_URL, eventAlert['eve_MAC'],
eventAlert['eve_EventType'], eventAlert['eve_DateTime'],
eventAlert['eve_IP'], eventAlert['eve_AdditionalInfo'])
@@ -1127,7 +1130,7 @@ def email_reporting ():
eventAlert['eve_IP'], eventAlert['dev_Name'],
eventAlert['eve_AdditionalInfo'])
mail_html_new_devices += html_line_template.format (
PA_FRONT_URL, eventAlert['eve_MAC'], eventAlert['eve_MAC'],
REPORT_DEVICE_URL, eventAlert['eve_MAC'], eventAlert['eve_MAC'],
eventAlert['eve_DateTime'], eventAlert['eve_IP'],
eventAlert['dev_Name'], eventAlert['eve_AdditionalInfo'])
@@ -1154,7 +1157,7 @@ def email_reporting ():
eventAlert['eve_MAC'], eventAlert['eve_DateTime'],
eventAlert['eve_IP'], eventAlert['dev_Name'])
mail_html_devices_down += html_line_template.format (
PA_FRONT_URL, eventAlert['eve_MAC'], eventAlert['eve_MAC'],
REPORT_DEVICE_URL, eventAlert['eve_MAC'], eventAlert['eve_MAC'],
eventAlert['eve_DateTime'], eventAlert['eve_IP'],
eventAlert['dev_Name'])
@@ -1184,7 +1187,7 @@ def email_reporting ():
eventAlert['eve_IP'], eventAlert['eve_EventType'],
eventAlert['dev_Name'], eventAlert['eve_AdditionalInfo'])
mail_html_events += html_line_template.format (
PA_FRONT_URL, eventAlert['eve_MAC'], eventAlert['eve_MAC'],
REPORT_DEVICE_URL, eventAlert['eve_MAC'], eventAlert['eve_MAC'],
eventAlert['eve_DateTime'], eventAlert['eve_IP'],
eventAlert['eve_EventType'], eventAlert['dev_Name'],
eventAlert['eve_AdditionalInfo'])