diff --git a/back/pialert.py b/back/pialert.py index 268aa023..fd75d943 100644 --- a/back/pialert.py +++ b/back/pialert.py @@ -1230,21 +1230,21 @@ def email_reporting (): mail_text = mail_text.replace ('', socket.gethostname() ) mail_html = mail_html.replace ('', socket.gethostname() ) - mail_text = mail_text.replace ('', VERSION ) - mail_html = mail_html.replace ('', VERSION ) + # mail_text = mail_text.replace ('', VERSION ) + # mail_html = mail_html.replace ('', VERSION ) - mail_text = mail_text.replace ('', VERSION_DATE ) - mail_html = mail_html.replace ('', VERSION_DATE ) + # mail_text = mail_text.replace ('', VERSION_DATE ) + # mail_html = mail_html.replace ('', VERSION_DATE ) - mail_text = mail_text.replace ('', VERSION_YEAR ) - mail_html = mail_html.replace ('', VERSION_YEAR ) + # mail_text = mail_text.replace ('', VERSION_YEAR ) + # mail_html = mail_html.replace ('', VERSION_YEAR ) # Compose Internet Section print (' Formating report...') mail_section_Internet = False mail_text_Internet = '' mail_html_Internet = '' - text_line_template = '{}\t{}\n{}\t{}\n{}\t{}\n{}\t{}\n\n' + text_line_template = '{} \t{}\t{}\t{}\n' html_line_template = '\n'+ \ ' {} \n {} \n'+ \ ' {} \n'+ \ @@ -1273,7 +1273,7 @@ def email_reporting (): mail_section_new_devices = False mail_text_new_devices = '' mail_html_new_devices = '' - text_line_template = '{}\t{}\n\t{}\t{}\n\t{}\t{}\n\t{}\t{}\n\t{}\t{}\n\n' + text_line_template = '{}\t{}\n\t{}\t{}\n\t{}\t{}\n\t{}\t{}\n\t{}\t{}\n\n' html_line_template = '\n'+ \ ' {} \n {} \n'+\ ' {} \n {} \n {} \n\n' @@ -1286,8 +1286,8 @@ def email_reporting (): for eventAlert in sql : mail_section_new_devices = True mail_text_new_devices += text_line_template.format ( - 'Name:', eventAlert['dev_Name'], 'MAC:', eventAlert['eve_MAC'], 'IP:', eventAlert['eve_IP'], - 'Time:', eventAlert['eve_DateTime'], 'More Info:', eventAlert['eve_AdditionalInfo']) + 'Name: ', eventAlert['dev_Name'], 'MAC: ', eventAlert['eve_MAC'], 'IP: ', eventAlert['eve_IP'], + 'Time: ', eventAlert['eve_DateTime'], 'More Info: ', eventAlert['eve_AdditionalInfo']) mail_html_new_devices += html_line_template.format ( REPORT_DEVICE_URL, eventAlert['eve_MAC'], eventAlert['eve_MAC'], eventAlert['eve_DateTime'], eventAlert['eve_IP'], @@ -1300,7 +1300,7 @@ def email_reporting (): mail_section_devices_down = False mail_text_devices_down = '' mail_html_devices_down = '' - text_line_template = '{}\t{}\n\t{}\t{}\n\t{}\t{}\n\t{}\t{}\n\n' + text_line_template = '{}\t{}\n\t{}\t{}\n\t{}\t{}\n\t{}\t{}\n\n' html_line_template = '\n'+ \ ' {} \n {} \n'+ \ ' {} \n {} \n\n' @@ -1313,8 +1313,8 @@ def email_reporting (): for eventAlert in sql : mail_section_devices_down = True mail_text_devices_down += text_line_template.format ( - 'Name:', eventAlert['dev_Name'], 'MAC:', eventAlert['eve_MAC'], - 'Time:', eventAlert['eve_DateTime'],'IP:', eventAlert['eve_IP']) + 'Name: ', eventAlert['dev_Name'], 'MAC: ', eventAlert['eve_MAC'], + 'Time: ', eventAlert['eve_DateTime'],'IP: ', eventAlert['eve_IP']) mail_html_devices_down += html_line_template.format ( REPORT_DEVICE_URL, eventAlert['eve_MAC'], eventAlert['eve_MAC'], eventAlert['eve_DateTime'], eventAlert['eve_IP'], @@ -1342,9 +1342,9 @@ def email_reporting (): for eventAlert in sql : mail_section_events = True mail_text_events += text_line_template.format ( - 'Name:', eventAlert['dev_Name'],'Event:', eventAlert['eve_EventType'], - 'MAC:', eventAlert['eve_MAC'], 'IP:', eventAlert['eve_IP'], - 'Time:', eventAlert['eve_DateTime'],'More Info:', eventAlert['eve_AdditionalInfo']) + 'Name: ', eventAlert['dev_Name'], 'MAC: ', eventAlert['eve_MAC'], + 'IP: ', eventAlert['eve_IP'],'Time: ', eventAlert['eve_DateTime'], + 'Event: ', eventAlert['eve_EventType'],'More Info: ', eventAlert['eve_AdditionalInfo']) mail_html_events += html_line_template.format ( REPORT_DEVICE_URL, eventAlert['eve_MAC'], eventAlert['eve_MAC'], eventAlert['eve_DateTime'], eventAlert['eve_IP'], @@ -1372,8 +1372,14 @@ def email_reporting (): send_ntfy (mail_text) else : print (' Skip NTFY...') + if REPORT_PUSHSAFER : + print (' Sending report by PUSHSAFER...') + send_pushsafer (mail_text) + else : + print (' Skip PUSHSAFER...') else : print (' No changes to report...') + # Clean Pending Alert Events @@ -1400,6 +1406,26 @@ def send_ntfy (_Text): "Priority": "urgent", "Tags": "warning" }) + +def send_pushsafer (_Text): + url = 'https://www.pushsafer.com/api' + post_fields = { + "t" : 'Pi.Alert Message', + "m" : _Text, + "s" : 11, + "v" : 3, + "i" : 148, + "c" : '#ef7f7f', + "d" : 'a', + "u" : REPORT_DASHBOARD_URL, + "ut" : 'Open Pi.Alert', + "k" : PUSHSAFER_TOKEN, + } + + request = Request(url, urlencode(post_fields).encode()) + json = urlopen(request).read().decode() + # print(json) + #------------------------------------------------------------------------------- def format_report_section (pActive, pSection, pTable, pText, pHTML): global mail_text @@ -1470,12 +1496,22 @@ def send_email (pText, pHTML): # Send mail smtp_connection = smtplib.SMTP (SMTP_SERVER, SMTP_PORT) smtp_connection.ehlo() - smtp_connection.starttls() - smtp_connection.ehlo() - smtp_connection.login (SMTP_USER, SMTP_PASS) +# smtp_connection.starttls() +# smtp_connection.ehlo() +# smtp_connection.login (SMTP_USER, SMTP_PASS) + if not SafeParseGlobalBool("SMTP_SKIP_TLS"): + smtp_connection.starttls() + smtp_connection.ehlo() + if not SafeParseGlobalBool("SMTP_SKIP_LOGIN"): + smtp_connection.login (SMTP_USER, SMTP_PASS) smtp_connection.sendmail (REPORT_FROM, REPORT_TO, msg.as_string()) smtp_connection.quit() +#------------------------------------------------------------------------------- +def SafeParseGlobalBool(boolVariable): + if boolVariable in globals(): + return eval(boolVariable) + return False #=============================================================================== # DB diff --git a/back/report_template.txt b/back/report_template.txt index a2943c63..9a2d72e3 100644 --- a/back/report_template.txt +++ b/back/report_template.txt @@ -4,18 +4,18 @@ Server: Internet ---------------------- +---------------------- New Devices ---------------------- +---------------------- Devices Down ---------------------- +---------------------- Events ---------------------- +---------------------- diff --git a/config/pialert.conf b/config/pialert.conf index d5897392..cfc056c3 100644 --- a/config/pialert.conf +++ b/config/pialert.conf @@ -12,11 +12,14 @@ DB_PATH = PIALERT_PATH + '/db/pialert.db' LOG_PATH = PIALERT_PATH + '/log' VENDORS_DB = '/usr/share/arp-scan/ieee-oui.txt' PRINT_LOG = False +PIALERT_WEB_PASSWORD = '8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92' SMTP_SERVER = 'smtp.gmail.com' SMTP_PORT = 587 SMTP_USER = 'user@gmail.com' SMTP_PASS = 'password' +SMTP_SKIP_TLS = False +SMTP_SKIP_LOGIN = False REPORT_MAIL = False REPORT_FROM = 'Pi.Alert <' + SMTP_USER +'>' diff --git a/config/reset_password.sh b/config/reset_password.sh new file mode 100644 index 00000000..a7f933ee --- /dev/null +++ b/config/reset_password.sh @@ -0,0 +1,7 @@ +cp pialert.conf pialert.conf.bak +PIA_PASS=$1 +echo "The password '$1' is hashed" +PIA_PASS_HASH=$(echo -n $PIA_PASS | sha256sum | awk '{print $1}') +echo "The hashed password is: $PIA_PASS_HASH" +sed -i "/PIALERT_WEB_PASSWORD/c\PIALERT_WEB_PASSWORD = '$PIA_PASS_HASH'" pialert.conf +echo "The hash was saved in the configuration file" \ No newline at end of file diff --git a/front/deviceDetails.php b/front/deviceDetails.php index b5b11762..aefd7542 100644 --- a/front/deviceDetails.php +++ b/front/deviceDetails.php @@ -8,6 +8,14 @@ #--------------------------------------------------------------------------- --> diff --git a/front/devices.php b/front/devices.php index 91b2326d..071f0c02 100644 --- a/front/devices.php +++ b/front/devices.php @@ -8,6 +8,14 @@ #--------------------------------------------------------------------------- --> diff --git a/front/events.php b/front/events.php index 0655c08a..597cca30 100644 --- a/front/events.php +++ b/front/events.php @@ -8,6 +8,14 @@ #--------------------------------------------------------------------------- --> diff --git a/front/index.php b/front/index.php index a1338922..6c4a1c74 100644 --- a/front/index.php +++ b/front/index.php @@ -1,5 +1,136 @@ + + + + + + + + + + Pi-Alert | Log in + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/front/maintenance.php b/front/maintenance.php index 95761ad1..5488d999 100644 --- a/front/maintenance.php +++ b/front/maintenance.php @@ -1,4 +1,12 @@
diff --git a/front/php/templates/header.php b/front/php/templates/header.php index 146e66cf..10bd3eb5 100644 --- a/front/php/templates/header.php +++ b/front/php/templates/header.php @@ -152,9 +152,9 @@ function show_pia_servertime() { diff --git a/front/php/templates/language/de_de.php b/front/php/templates/language/de_de.php index a7dafeaa..6949e106 100644 --- a/front/php/templates/language/de_de.php +++ b/front/php/templates/language/de_de.php @@ -178,6 +178,9 @@ $pia_lang['Maintenance_lang_de_de'] = 'Deutsch (DE)'; $pia_lang['Maintenance_lang_es_es'] = 'Spanisch (ES)'; $pia_lang['Maintenance_lang_selector_text'] = 'Die Änderung findet serverseitig statt, betrifft also alle verwendeten Geräte.'; $pia_lang['Maintenance_lang_selector_apply'] = 'Übernehmen'; +$pia_lang['Maintenance_Tools_Tab_Settings'] = 'Einstellungen'; +$pia_lang['Maintenance_Tools_Tab_Tools'] = 'Werkzeuge'; +$pia_lang['Maintenance_Tools_Tab_BackupRestore'] = 'Sicherg. / Wiederherstellg.'; $pia_lang['Maintenance_Tool_darkmode'] = 'Darstellungswechsel (Dunkel/Hell)'; $pia_lang['Maintenance_Tool_darkmode_text'] = 'Wechselt zwischen der hellen und der dunklen Darstellung. Wenn der Wechsel nicht richtig funktionieren sollte, versuchen Sie den Browsercache zu löschen. Die Änderung findet serverseitig statt, betrifft also alle verwendeten Geräte.'; $pia_lang['Maintenance_Tool_darkmode_noti'] = 'Darstellungswechsel'; diff --git a/front/php/templates/language/en_us.php b/front/php/templates/language/en_us.php index 046eb4c5..e1112faa 100644 --- a/front/php/templates/language/en_us.php +++ b/front/php/templates/language/en_us.php @@ -178,6 +178,9 @@ $pia_lang['Maintenance_lang_de_de'] = 'German (DE)'; $pia_lang['Maintenance_lang_es_es'] = 'Spanish (ES)'; $pia_lang['Maintenance_lang_selector_text'] = 'The change takes place on the server side, so it affects all devices in use.'; $pia_lang['Maintenance_lang_selector_apply'] = 'Apply'; +$pia_lang['Maintenance_Tools_Tab_Settings'] = 'Settings'; +$pia_lang['Maintenance_Tools_Tab_Tools'] = 'Tools'; +$pia_lang['Maintenance_Tools_Tab_BackupRestore'] = 'Backup / Restore'; $pia_lang['Maintenance_Tool_darkmode'] = 'Toggle Modes (Dark/Light)'; $pia_lang['Maintenance_Tool_darkmode_text'] = 'Toggle between dark mode and light mode. If the switch does not work properly, try to clear the browser cache. The change takes place on the server side, so it affects all devices in use.'; $pia_lang['Maintenance_Tool_darkmode_noti'] = 'Toggle Modes'; diff --git a/front/php/templates/language/es_es.php b/front/php/templates/language/es_es.php index 4c7c7419..376c5373 100644 --- a/front/php/templates/language/es_es.php +++ b/front/php/templates/language/es_es.php @@ -1,19 +1,19 @@ - diff --git a/front/presence.php b/front/presence.php index e90ed99c..e5af11d9 100644 --- a/front/presence.php +++ b/front/presence.php @@ -8,6 +8,14 @@ #--------------------------------------------------------------------------- -->