mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
Merge branch 'main' of https://github.com/jokob-sk/Pi.Alert
This commit is contained in:
@@ -1,11 +1,16 @@
|
|||||||
<!-- ---------------------------------------------------------------------------
|
<!--
|
||||||
# Pi.Alert
|
#---------------------------------------------------------------------------------#
|
||||||
# Open Source Network Guard / WIFI & LAN intrusion detector
|
# Pi.Alert #
|
||||||
#
|
# Open Source Network Guard / WIFI & LAN intrusion detector #
|
||||||
# repot_template.html - Back module. Template to email reporting in HTML format
|
# #
|
||||||
#-------------------------------------------------------------------------------
|
# report_template.html - Back module. Template to email reporting in HTML format #
|
||||||
# Puche 2021 GNU GPLv3
|
#---------------------------------------------------------------------------------#
|
||||||
#--------------------------------------------------------------------------- -->
|
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3 #
|
||||||
|
# jokob-sk 2022 jokob.sk@gmail.com GNU GPLv3 #
|
||||||
|
# leiweibau 2022 https://github.com/leiweibau GNU GPLv3 #
|
||||||
|
# cvc90 2023 https://github.com/cvc90 GNU GPLv3 #
|
||||||
|
#---------------------------------------------------------------------------------#
|
||||||
|
-->
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
@@ -23,7 +28,7 @@
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<table width=100% border=0 bgcolor=#00c0ef cellpadding=5px cellspacing=0 style="border-collapse: collapse; font-size: 15px; text-align:center; color:#404040"> <tr>
|
<table width=100% border=0 bgcolor=#4b99d3 cellpadding=5px cellspacing=0 style="border-collapse: collapse; font-size: 15px; text-align:center; color:#ffffff"> <tr>
|
||||||
<td width=100%> Report Date: <b><REPORT_DATE></b> </td>
|
<td width=100%> Report Date: <b><REPORT_DATE></b> </td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -31,7 +36,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td bgcolor=#F5F5F5 height=200 valign=top style="padding: 10px">
|
<td bgcolor=#F1F5F5 height=200 valign=top style="padding: 10px">
|
||||||
|
|
||||||
<INTERNET_TABLE>
|
<INTERNET_TABLE>
|
||||||
<NEW_DEVICES_TABLE>
|
<NEW_DEVICES_TABLE>
|
||||||
@@ -39,14 +44,23 @@
|
|||||||
<EVENTS_TABLE>
|
<EVENTS_TABLE>
|
||||||
<PORTS_TABLE>
|
<PORTS_TABLE>
|
||||||
<PLUGINS_TABLE>
|
<PLUGINS_TABLE>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<table width=100% bgcolor=#46802e cellpadding=5px cellspacing=0 style="font-size: 13px; font-weight: bold; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px;">
|
<table width=100% bgcolor=#3c8dbc cellpadding=5px cellspacing=0 style="font-size: 13px; font-weight: bold; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px;">
|
||||||
<tr>
|
<tr>
|
||||||
<td width=50% style="text-align:center"> Pi.Alert - <SERVER_NAME></td>
|
<td width=50% style="text-align:center;color: white;">
|
||||||
|
<a href="https://github.com/jokob-sk/Pi.Alert" target="_blank" style="color: white">Pi.Alert</a>
|
||||||
|
<a href=".." target="_blank" style="color: white"> (<SERVER_NAME>)</a>
|
||||||
|
<br><span style="display:inline-block;color: white; transform: rotate(180deg)">©</span>2020 Puche (2022+
|
||||||
|
<a style="color: white" href="mailto:jokob@duck.com?subject=PiAlert">jokob-sk</a>) | <b>Built on: <BUILD_PIALERT> </b> | <b> Version: <VERSION_PIALERT> </b> |
|
||||||
|
<a href="https://github.com/jokob-sk/Pi.Alert/tree/main/docs" target="_blank" style="color: white">
|
||||||
|
<span>Docs <i class="fa fa-circle-question"></i>
|
||||||
|
</a><span>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</td>
|
</td>
|
||||||
@@ -54,4 +68,4 @@
|
|||||||
</table>
|
</table>
|
||||||
</font>
|
</font>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
<!-- ---------------------------------------------------------------------------
|
<!--
|
||||||
# Pi.Alert
|
#---------------------------------------------------------------------------------#
|
||||||
# Open Source Network Guard / WIFI & LAN intrusion detector
|
# Pi.Alert #
|
||||||
#
|
# Open Source Network Guard / WIFI & LAN intrusion detector #
|
||||||
# repot_template.html - Back module. Template to email reporting in HTML format
|
# #
|
||||||
#-------------------------------------------------------------------------------
|
# report_template.html - Back module. Template to email reporting in HTML format #
|
||||||
# Puche 2021 GNU GPLv3
|
#---------------------------------------------------------------------------------#
|
||||||
#--------------------------------------------------------------------------- -->
|
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3 #
|
||||||
|
# jokob-sk 2022 jokob.sk@gmail.com GNU GPLv3 #
|
||||||
|
# leiweibau 2022 https://github.com/leiweibau GNU GPLv3 #
|
||||||
|
# cvc90 2023 https://github.com/cvc90 GNU GPLv3 #
|
||||||
|
#---------------------------------------------------------------------------------#
|
||||||
|
-->
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
@@ -20,14 +25,10 @@
|
|||||||
Pi.Alert Report
|
Pi.Alert Report
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td bgcolor=#2656f1 width=100% align=center style="padding: 20px 10px 10px 10px; font-size: 20px; font-weight: bold; color:#ffffff; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2)">
|
|
||||||
<a style="color:#ffffff;cursor:pointer;" href="https://github.com/jokob-sk/Pi.Alert/releases">🆕 New version available 🆕</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<table width=100% border=0 bgcolor=#00c0ef cellpadding=5px cellspacing=0 style="border-collapse: collapse; font-size: 15px; text-align:center; color:#404040"> <tr>
|
<table width=100% border=0 bgcolor=#4b99d3 cellpadding=5px cellspacing=0 style="border-collapse: collapse; font-size: 15px; text-align:center; color:#ffffff"> <tr>
|
||||||
<td width=100%> Report Date: <b><REPORT_DATE></b> </td>
|
<td width=100%> Report Date: <b><REPORT_DATE></b> </td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -35,27 +36,36 @@
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td bgcolor=#F5F5F5 height=200 valign=top style="padding: 10px">
|
<td bgcolor=#F1F5F5 height=200 valign=top style="padding: 10px">
|
||||||
|
|
||||||
<INTERNET_TABLE>
|
<INTERNET_TABLE>
|
||||||
<NEW_DEVICES_TABLE>
|
<NEW_DEVICES_TABLE>
|
||||||
<DOWN_DEVICES_TABLE>
|
<DOWN_DEVICES_TABLE>
|
||||||
<EVENTS_TABLE>
|
<EVENTS_TABLE>
|
||||||
<PORTS_TABLE>
|
<PORTS_TABLE>
|
||||||
<PLUGINS_TABLE>
|
<PLUGINS_TABLE>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<table width=100% bgcolor=#46802e cellpadding=5px cellspacing=0 style="font-size: 13px; font-weight: bold; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px;">
|
<table width=100% bgcolor=#3c8dbc cellpadding=5px cellspacing=0 style="font-size: 13px; font-weight: bold; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px;">
|
||||||
<tr>
|
<tr>
|
||||||
<td width=50% style="text-align:center"> Pi.Alert - <SERVER_NAME></td>
|
<td width=50% style="text-align:center;color: white;">
|
||||||
|
<a href="https://github.com/jokob-sk/Pi.Alert" target="_blank" style="color: white">Pi.Alert</a>
|
||||||
|
<a href=".." target="_blank" style="color: white"> (<SERVER_NAME>)</a>
|
||||||
|
<br><span style="display:inline-block;color: white; transform: rotate(180deg)">©</span>2020 Puche (2022+
|
||||||
|
<a style="color: white" href="mailto:jokob@duck.com?subject=PiAlert">jokob-sk</a>) | <b>Built on: <BUILD_PIALERT> </b> | <b> Version: <VERSION_PIALERT> </b> |
|
||||||
|
<a href="https://github.com/jokob-sk/Pi.Alert/tree/main/docs" target="_blank" style="color: white">
|
||||||
|
<span>Docs <i class="fa fa-circle-question"></i>
|
||||||
|
</a><span>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</font>
|
</font>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
21
front/php/templates/build.php
Normal file
21
front/php/templates/build.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
#---------------------------------------------------------------------------------#
|
||||||
|
# Pi.Alert #
|
||||||
|
# Open Source Network Guard / WIFI & LAN intrusion detector #
|
||||||
|
# #
|
||||||
|
# build.php - Templates module Template to display the current build version #
|
||||||
|
#---------------------------------------------------------------------------------#
|
||||||
|
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3 #
|
||||||
|
# jokob-sk 2022 jokob.sk@gmail.com GNU GPLv3 #
|
||||||
|
# leiweibau 2022 https://github.com/leiweibau GNU GPLv3 #
|
||||||
|
# cvc90 2023 https://github.com/cvc90 GNU GPLv3 #
|
||||||
|
#---------------------------------------------------------------------------------#
|
||||||
|
|
||||||
|
$file = "/home/pi/pialert/front/buildtimestamp.txt";
|
||||||
|
if (file_exists($file)) {
|
||||||
|
echo date("Y-m-d", ((int)file_get_contents($file)));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo "File not found";
|
||||||
|
}
|
||||||
|
?>
|
||||||
21
front/php/templates/version.php
Normal file
21
front/php/templates/version.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
#---------------------------------------------------------------------------------#
|
||||||
|
# Pi.Alert #
|
||||||
|
# Open Source Network Guard / WIFI & LAN intrusion detector #
|
||||||
|
# #
|
||||||
|
# version.php - Templates module Template to display the current version #
|
||||||
|
#---------------------------------------------------------------------------------#
|
||||||
|
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3 #
|
||||||
|
# jokob-sk 2022 jokob.sk@gmail.com GNU GPLv3 #
|
||||||
|
# leiweibau 2022 https://github.com/leiweibau GNU GPLv3 #
|
||||||
|
# cvc90 2023 https://github.com/cvc90 GNU GPLv3 #
|
||||||
|
#---------------------------------------------------------------------------------#
|
||||||
|
|
||||||
|
$filename = "/home/pi/pialert/.VERSION";
|
||||||
|
if(file_exists($filename)) {
|
||||||
|
echo file_get_contents($filename);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
echo "File not found";
|
||||||
|
}
|
||||||
|
?>
|
||||||
@@ -1,4 +1,14 @@
|
|||||||
|
#---------------------------------------------------------------------------------#
|
||||||
|
# Pi.Alert #
|
||||||
|
# Open Source Network Guard / WIFI & LAN intrusion detector #
|
||||||
|
# #
|
||||||
|
# reporting.py - Pialert Back module. Template to email reporting in HTML format #
|
||||||
|
#---------------------------------------------------------------------------------#
|
||||||
|
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3 #
|
||||||
|
# jokob-sk 2022 jokob.sk@gmail.com GNU GPLv3 #
|
||||||
|
# leiweibau 2022 https://github.com/leiweibau GNU GPLv3 #
|
||||||
|
# cvc90 2023 https://github.com/cvc90 GNU GPLv3 #
|
||||||
|
#---------------------------------------------------------------------------------#
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
@@ -11,6 +21,7 @@ from json2table import convert
|
|||||||
|
|
||||||
# pialert modules
|
# pialert modules
|
||||||
import conf
|
import conf
|
||||||
|
import const
|
||||||
from const import pialertPath, logPath, apiPath
|
from const import pialertPath, logPath, apiPath
|
||||||
from helper import noti_struc, generate_mac_links, removeDuplicateNewLines, timeNowTZ, hide_email, updateState, get_file_content, write_file
|
from helper import noti_struc, generate_mac_links, removeDuplicateNewLines, timeNowTZ, hide_email, updateState, get_file_content, write_file
|
||||||
from logger import logResult, mylog, print_log
|
from logger import logResult, mylog, print_log
|
||||||
@@ -47,8 +58,8 @@ def construct_notifications(db, sqlQuery, tableTitle, skipText = False, supplied
|
|||||||
return noti_struc("", "", "")
|
return noti_struc("", "", "")
|
||||||
|
|
||||||
table_attributes = {"style" : "border-collapse: collapse; font-size: 12px; color:#70707", "width" : "100%", "cellspacing" : 0, "cellpadding" : "3px", "bordercolor" : "#C0C0C0", "border":"1"}
|
table_attributes = {"style" : "border-collapse: collapse; font-size: 12px; color:#70707", "width" : "100%", "cellspacing" : 0, "cellpadding" : "3px", "bordercolor" : "#C0C0C0", "border":"1"}
|
||||||
headerProps = "width='120px' style='color:blue; font-size: 16px;' bgcolor='#909090' "
|
headerProps = "width='120px' style='color:white; font-size: 16px;' bgcolor='#64a0d6' "
|
||||||
thProps = "width='120px' style='color:#F0F0F0' bgcolor='#909090' "
|
thProps = "width='120px' style='color:#F0F0F0' bgcolor='#64a0d6' "
|
||||||
|
|
||||||
build_direction = "TOP_TO_BOTTOM"
|
build_direction = "TOP_TO_BOTTOM"
|
||||||
text_line = '{}\t{}\n'
|
text_line = '{}\t{}\n'
|
||||||
@@ -139,14 +150,25 @@ def send_notifications (db):
|
|||||||
mail_html = template_file.read()
|
mail_html = template_file.read()
|
||||||
template_file.close()
|
template_file.close()
|
||||||
|
|
||||||
# Report Header & footer
|
# Report "REPORT_DATE" in Header & footer
|
||||||
timeFormated = timeNowTZ().strftime ('%Y-%m-%d %H:%M')
|
timeFormated = timeNowTZ().strftime ('%Y-%m-%d %H:%M')
|
||||||
mail_text = mail_text.replace ('<REPORT_DATE>', timeFormated)
|
mail_text = mail_text.replace ('<REPORT_DATE>', timeFormated)
|
||||||
mail_html = mail_html.replace ('<REPORT_DATE>', timeFormated)
|
mail_html = mail_html.replace ('<REPORT_DATE>', timeFormated)
|
||||||
|
|
||||||
|
# Report "SERVER_NAME" in Header & footer
|
||||||
mail_text = mail_text.replace ('<SERVER_NAME>', socket.gethostname() )
|
mail_text = mail_text.replace ('<SERVER_NAME>', socket.gethostname() )
|
||||||
mail_html = mail_html.replace ('<SERVER_NAME>', socket.gethostname() )
|
mail_html = mail_html.replace ('<SERVER_NAME>', socket.gethostname() )
|
||||||
|
|
||||||
|
# Report "VERSION" in Header & footer
|
||||||
|
VERSIONFILE = subprocess.check_output(['php', pialertPath + '/front/php/templates/version.php']).decode('utf-8')
|
||||||
|
mail_text = mail_text.replace ('<VERSION_PIALERT>', VERSIONFILE)
|
||||||
|
mail_html = mail_html.replace ('<VERSION_PIALERT>', VERSIONFILE)
|
||||||
|
|
||||||
|
# Report "BUILD" in Header & footer
|
||||||
|
BUILDFILE = subprocess.check_output(['php', pialertPath + '/front/php/templates/build.php']).decode('utf-8')
|
||||||
|
mail_text = mail_text.replace ('<BUILD_PIALERT>', BUILDFILE)
|
||||||
|
mail_html = mail_html.replace ('<BUILD_PIALERT>', BUILDFILE)
|
||||||
|
|
||||||
mylog('verbose', ['[Notification] included sections: ', conf.INCLUDED_SECTIONS ])
|
mylog('verbose', ['[Notification] included sections: ', conf.INCLUDED_SECTIONS ])
|
||||||
|
|
||||||
if 'internet' in conf.INCLUDED_SECTIONS :
|
if 'internet' in conf.INCLUDED_SECTIONS :
|
||||||
@@ -530,4 +552,4 @@ def handle_test(testType):
|
|||||||
if testType == 'REPORT_PUSHSAFER':
|
if testType == 'REPORT_PUSHSAFER':
|
||||||
send_pushsafer (sample_msg)
|
send_pushsafer (sample_msg)
|
||||||
|
|
||||||
mylog('minimal', ['[Test Publishers] END Test: ', testType])
|
mylog('minimal', ['[Test Publishers] END Test: ', testType])
|
||||||
|
|||||||
Reference in New Issue
Block a user