diff --git a/README.md b/README.md index 9afc86b4..4d3016f3 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ A web frontal that allows: With the work of [jokob-sk/Pi.Alert](https://github.com/jokob-sk/Pi.Alert) and own extensions, the new maintenance page was added with various possibilities for maintenance and settings: - Status Infos (active scans, database size, backup counter) - Theme Selection (blue, red, green, yellow, black, purple) - - Language Selection (english, german) + - Language Selection (english, german, spanish) - Light/Dark-Mode Switch - Pause arp-scan - DB maintenance tools diff --git a/back/pialert.py b/back/pialert.py index 7fc7ecef..7b8308f7 100644 --- a/back/pialert.py +++ b/back/pialert.py @@ -458,7 +458,7 @@ def execute_arpscan (pRetries): # arp-scan for larger Networks like /16 # otherwise the system starts multiple processes. the 15min cronjob isn't necessary. # the scan is about 4min on a /16 network - arpscan_args = ['sudo', 'arp-scan', '--ignoredups', '--bandwidth=512k', '--retry=2', SCAN_SUBNETS] + arpscan_args = ['sudo', 'arp-scan', '--ignoredups', '--bandwidth=512k', '--retry=3', SCAN_SUBNETS] # Default arp-scan # arpscan_args = ['sudo', 'arp-scan', SCAN_SUBNETS, '--ignoredups', '--retry=' + str(pRetries)] @@ -1223,21 +1223,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{}\t{}\t{}\n' + text_line_template = '{} \t{}\t{}\t{}\n' html_line_template = '\n'+ \ ' {} \n {} \n'+ \ ' {} \n'+ \ @@ -1264,7 +1264,7 @@ def email_reporting (): mail_section_new_devices = False mail_text_new_devices = '' mail_html_new_devices = '' - text_line_template = ' {}\t{}\t{}\t{}\t{}\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' @@ -1277,9 +1277,8 @@ def email_reporting (): for eventAlert in sql : mail_section_new_devices = True mail_text_new_devices += text_line_template.format ( - eventAlert['eve_MAC'], eventAlert['eve_DateTime'], - eventAlert['eve_IP'], eventAlert['dev_Name'], - 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'], @@ -1292,7 +1291,7 @@ def email_reporting (): mail_section_devices_down = False mail_text_devices_down = '' mail_html_devices_down = '' - text_line_template = ' {}\t{}\t{}\t{}\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' @@ -1305,8 +1304,8 @@ def email_reporting (): for eventAlert in sql : mail_section_devices_down = True mail_text_devices_down += text_line_template.format ( - eventAlert['eve_MAC'], eventAlert['eve_DateTime'], - eventAlert['eve_IP'], eventAlert['dev_Name']) + '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'], @@ -1319,7 +1318,7 @@ def email_reporting (): mail_section_events = False mail_text_events = '' mail_html_events = '' - text_line_template = ' {}\t{}\t{}\t{}\t{}\t{}\n' + text_line_template = '{}\t{}\n\t{}\t{}\n\t{}\t{}\n\t{}\t{}\n\t{}\t{}\n\t{}\t{}\n\n' html_line_template = '\n '+ \ ' {} \n {} \n'+ \ ' {} \n {} \n {} \n'+ \ @@ -1334,9 +1333,9 @@ def email_reporting (): for eventAlert in sql : mail_section_events = True mail_text_events += text_line_template.format ( - eventAlert['eve_MAC'], eventAlert['eve_DateTime'], - eventAlert['eve_IP'], eventAlert['eve_EventType'], - eventAlert['dev_Name'], 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'], @@ -1359,13 +1358,14 @@ def email_reporting (): send_email (mail_text, mail_html) else : print (' Skip mail...') + if REPORT_PUSHSAFER : + print (' Sending report by PUSHSAFER...') + send_pushsafer (mail_text) + else : + print (' Skip PUSHSAFER...') else : print (' No changes to report...') - if REPORT_PUSHSAFER : - print (' Sending report by PUSHSAFER...') - send_pushsafer (mail_text) - else : - print (' Skip PUSHSAFER...') + # Clean Pending Alert Events @@ -1389,7 +1389,7 @@ def send_pushsafer (_Text): url = 'https://www.pushsafer.com/api' post_fields = { "t" : 'Pi.Alert Message', - "m" : 'Something has changed', + "m" : _Text, "s" : 11, "v" : 3, "i" : 148, @@ -1474,12 +1474,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.html b/back/report_template.html index 0bc0ecc0..e6b340ad 100644 --- a/back/report_template.html +++ b/back/report_template.html @@ -14,20 +14,19 @@ - +
- @@ -36,9 +35,9 @@
+ Pi.Alert Report
- - - - - +
Report Date: Scan Cycle: Server:
+ + +
Report Date: Scan Cycle:
-

Internet:

+

Internet:

- +
@@ -53,11 +52,11 @@ -

New Devices:

+

New Devices:

-
Event Type Datetime
+
- + @@ -71,9 +70,9 @@ -

Devices Down:

+

Devices Down:

-
MAC MAC Datetime IP Device Name
+
@@ -88,9 +87,9 @@ -

Events:

+

Events:

-
MAC Datetime
+
@@ -108,11 +107,10 @@ @@ -120,4 +118,4 @@
MAC Datetime
- +
- + -
© Puche Pi.Alert - Pi.Alert     () GNU GPLv3
- + \ No newline at end of file diff --git a/back/report_template.txt b/back/report_template.txt index 0d777f57..9a2d72e3 100644 --- a/back/report_template.txt +++ b/back/report_template.txt @@ -1,27 +1,21 @@ -======================================== - Pi.Alert Report -======================================== - - Report Date: - Scan Cycle: - Server: +Report Date: +Scan Cycle: +Server: Internet ----------------------------------------------------------------------- +---------------------- New Devices ----------------------------------------------------------------------- +---------------------- Devices Down ----------------------------------------------------------------------- +---------------------- Events ----------------------------------------------------------------------- +---------------------- ----------------------------------------------------------------------- -(?) Puche Pi.Alert () GNU GPLv3 diff --git a/config/pialert.conf b/config/pialert.conf index d58f0f3d..7c6f8043 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 dcdea723..f0033d05 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 99e15650..b43ffdfa 100644 --- a/front/maintenance.php +++ b/front/maintenance.php @@ -1,4 +1,12 @@ -

Status

-
+
@@ -207,19 +214,40 @@ if (submit && isset($_POST['langselector_set'])) {
-
-
-
-
-

:

-
-
-
+ +
+
+
+ +
@@ -375,7 +351,6 @@ if (submit && isset($_POST['langselector_set'])) { diff --git a/front/php/templates/header.php b/front/php/templates/header.php index 0da855d7..cc4395cb 100644 --- a/front/php/templates/header.php +++ b/front/php/templates/header.php @@ -146,9 +146,9 @@ function show_pia_servertime() { diff --git a/front/php/templates/language/de_de.php b/front/php/templates/language/de_de.php index e2e9f256..5a32a942 100644 --- a/front/php/templates/language/de_de.php +++ b/front/php/templates/language/de_de.php @@ -176,8 +176,12 @@ $pia_lang['Maintenance_lang_selector_lable'] = 'Sprachauswahl'; $pia_lang['Maintenance_lang_selector_empty'] = 'Sprache wählen'; $pia_lang['Maintenance_lang_en_us'] = 'Englisch (US)'; $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'; @@ -190,6 +194,9 @@ $pia_lang['Maintenance_Tool_del_empty_macs'] = 'Alle Geräte ohne MAC löschen'; $pia_lang['Maintenance_Tool_del_empty_macs_text'] = 'Machen Sie ein Backup, bevor Sie diese Funk­tion nutzen. Der Vor­gang kann ohne Back­up nicht rück­gängig gemacht werden. Alle Geäte ohne MAC-Adresse werden aus der Datenbank ge­löscht.'; $pia_lang['Maintenance_Tool_del_empty_macs_noti'] = 'Geräte löschen'; $pia_lang['Maintenance_Tool_del_empty_macs_noti_text'] = 'Sind Sie sicher, dass Sie alle Geräte ohne MAC-Adresse löschen wollen?
(Vielleicht bevorzugenn Sie eine Archivierung.)'; +$pia_lang['Maintenance_Tool_upgrade_database_noti'] = 'Aktualisiere Datenbank'; +$pia_lang['Maintenance_Tool_upgrade_database_text'] = 'Mit dieser Schaltfläche wird die Datenbank aktualisiert, um das Diagramm der Netzwerkaktivitäten der letzten 12 Stunden zu aktivieren. Bitte sichern Sie Ihre Datenbank, falls Probleme auftreten.'; +$pia_lang['Maintenance_Tool_upgrade_database_noti_text'] = 'Machen Sie ein Backup, bevor Sie diese Funk­tion nutzen.'; $pia_lang['Maintenance_Tool_del_alldev'] = 'Alle Geräte löschen'; $pia_lang['Maintenance_Tool_del_alldev_text'] = 'Machen Sie ein Backup, bevor Sie diese Funk­tion nutzen. Der Vor­gang kann ohne Back­up nicht rück­gängig gemacht werden. Alle Geräte werden in der Datenbank ge­löscht.'; $pia_lang['Maintenance_Tool_del_alldev_noti'] = 'Geräte löschen'; @@ -233,5 +240,7 @@ $pia_lang['BackDevices_DBTools_DelDevError_a'] = 'Fehler beim Löschen des Gerä $pia_lang['BackDevices_DBTools_DelDevError_b'] = 'Fehler beim Löschen der Geräte'; $pia_lang['BackDevices_DBTools_UpdDev'] = 'Gerät erfolgreich aktualisiert'; $pia_lang['BackDevices_DBTools_UpdDevError'] = 'Fehler beim Aktualisieren des Gerätes'; +$pia_lang['BackDevices_DBTools_Upgrade'] = 'Datenbank erfolgreich aktualisiert'; +$pia_lang['BackDevices_DBTools_UpgradeError'] = 'Fehler beim Aktualisieren der Datenbank'; ?> diff --git a/front/php/templates/language/en_us.php b/front/php/templates/language/en_us.php index b560ba4b..97d84430 100644 --- a/front/php/templates/language/en_us.php +++ b/front/php/templates/language/en_us.php @@ -176,8 +176,12 @@ $pia_lang['Maintenance_lang_selector_lable'] = 'Select Language'; $pia_lang['Maintenance_lang_selector_empty'] = 'Choose Language'; $pia_lang['Maintenance_lang_en_us'] = 'English (US)'; $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'; @@ -190,6 +194,9 @@ $pia_lang['Maintenance_Tool_del_empty_macs'] = 'Delete Devices with empty MACs'; $pia_lang['Maintenance_Tool_del_empty_macs_text'] = 'Before using this function, please make a backup. The deletion cannot be undone. All devices without MAC will be deleted from the database.'; $pia_lang['Maintenance_Tool_del_empty_macs_noti'] = 'Delete Devices'; $pia_lang['Maintenance_Tool_del_empty_macs_noti_text'] = 'Are you sure you want to delete all devices with empty MAC addresses?
(maybe you prefer to archive it)'; +$pia_lang['Maintenance_Tool_upgrade_database_noti'] = 'Upgrade database'; +$pia_lang['Maintenance_Tool_upgrade_database_text'] = 'This button will upgrade the database to enable the Network activity over last 12 hours chart. Please backup your database in case of issues.'; +$pia_lang['Maintenance_Tool_upgrade_database_noti_text'] = 'Are you sure you want to upgrade the database?
(maybe you prefer to archive it)'; $pia_lang['Maintenance_Tool_del_alldev'] = 'Delete all Devices'; $pia_lang['Maintenance_Tool_del_alldev_text'] = 'Before using this function, please make a backup. The deletion cannot be undone. All devices will be deleted from the database.'; $pia_lang['Maintenance_Tool_del_alldev_noti'] = 'Delete Devices'; @@ -233,5 +240,7 @@ $pia_lang['BackDevices_DBTools_DelDevError_a'] = 'Error deleting Device'; $pia_lang['BackDevices_DBTools_DelDevError_b'] = 'Error deleting Devices'; $pia_lang['BackDevices_DBTools_UpdDev'] = 'Device updated successfully'; $pia_lang['BackDevices_DBTools_UpdDevError'] = 'Error updating device'; +$pia_lang['BackDevices_DBTools_Upgrade'] = 'Database upgraded successfully'; +$pia_lang['BackDevices_DBTools_UpgradeError'] = 'Database upgrade failed'; ?> diff --git a/front/presence.php b/front/presence.php index 5ab20310..0f2b61ab 100644 --- a/front/presence.php +++ b/front/presence.php @@ -8,6 +8,14 @@ #--------------------------------------------------------------------------- -->