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

@@ -79,9 +79,13 @@ Linux distributions.
- [Device Management instructions](docs/DEVICE_MANAGEMENT.md) - [Device Management instructions](docs/DEVICE_MANAGEMENT.md)
## Other useful info ## Other useful info
<!--- --------------------------------------------------------------------- ---> <!--- --------------------------------------------------------------------- --->
### Versions History
- [Versions History](docs/VERSIONS_HISTORY.md)
### Powered by: ### Powered by:
| Product | Objetive | | Product | Objetive |
| ------------ | -------------------------------------- | | ------------ | -------------------------------------- |

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env python #!/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 # Open Source Network Guard / WIFI & LAN intrusion detector
# #
# pialert.py - Back module. Network scanner # pialert.py - Back module. Network scanner
@@ -32,11 +32,15 @@ import csv
#=============================================================================== #===============================================================================
# CONFIG CONSTANTS # 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)): 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: 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 ('---------------------------------------------------------') print ('---------------------------------------------------------')
# Initialize global variables # Initialize global variables
# PIALERT_PATH = os.path.dirname(os.path.abspath(__file__))
log_timestamp = datetime.datetime.now() log_timestamp = datetime.datetime.now()
# DB # DB
@@ -254,7 +257,7 @@ def update_devices_MAC_vendors ():
# Update vendors DB (iab oui) # Update vendors DB (iab oui)
print ('\nUpdating 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) update_output = subprocess.check_output (update_args)
# DEBUG # DEBUG
# update_args = ['./vendors_db_update.sh'] # update_args = ['./vendors_db_update.sh']
@@ -1049,12 +1052,12 @@ def email_reporting ():
openDB() openDB()
# Open text Template # 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() mail_text = template_file.read()
template_file.close() template_file.close()
# Open html Template # 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() mail_html = template_file.read()
template_file.close() template_file.close()
@@ -1099,7 +1102,7 @@ def email_reporting ():
eventAlert['eve_EventType'], eventAlert['eve_DateTime'], eventAlert['eve_EventType'], eventAlert['eve_DateTime'],
eventAlert['eve_IP'], eventAlert['eve_AdditionalInfo']) eventAlert['eve_IP'], eventAlert['eve_AdditionalInfo'])
mail_html_Internet += html_line_template.format ( 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_EventType'], eventAlert['eve_DateTime'],
eventAlert['eve_IP'], eventAlert['eve_AdditionalInfo']) eventAlert['eve_IP'], eventAlert['eve_AdditionalInfo'])
@@ -1127,7 +1130,7 @@ def email_reporting ():
eventAlert['eve_IP'], eventAlert['dev_Name'], eventAlert['eve_IP'], eventAlert['dev_Name'],
eventAlert['eve_AdditionalInfo']) eventAlert['eve_AdditionalInfo'])
mail_html_new_devices += html_line_template.format ( 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['eve_DateTime'], eventAlert['eve_IP'],
eventAlert['dev_Name'], eventAlert['eve_AdditionalInfo']) eventAlert['dev_Name'], eventAlert['eve_AdditionalInfo'])
@@ -1154,7 +1157,7 @@ def email_reporting ():
eventAlert['eve_MAC'], eventAlert['eve_DateTime'], eventAlert['eve_MAC'], eventAlert['eve_DateTime'],
eventAlert['eve_IP'], eventAlert['dev_Name']) eventAlert['eve_IP'], eventAlert['dev_Name'])
mail_html_devices_down += html_line_template.format ( 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['eve_DateTime'], eventAlert['eve_IP'],
eventAlert['dev_Name']) eventAlert['dev_Name'])
@@ -1184,7 +1187,7 @@ def email_reporting ():
eventAlert['eve_IP'], eventAlert['eve_EventType'], eventAlert['eve_IP'], eventAlert['eve_EventType'],
eventAlert['dev_Name'], eventAlert['eve_AdditionalInfo']) eventAlert['dev_Name'], eventAlert['eve_AdditionalInfo'])
mail_html_events += html_line_template.format ( 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_DateTime'], eventAlert['eve_IP'],
eventAlert['eve_EventType'], eventAlert['dev_Name'], eventAlert['eve_EventType'], eventAlert['dev_Name'],
eventAlert['eve_AdditionalInfo']) eventAlert['eve_AdditionalInfo'])

View File

@@ -1,5 +1,5 @@
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# Pi.Alert v2.56 / 2021-01-15 # Pi.Alert
# Open Source Network Guard / WIFI & LAN intrusion detector # Open Source Network Guard / WIFI & LAN intrusion detector
# #
# pialert.conf - Back module. Configuration file # pialert.conf - Back module. Configuration file
@@ -7,14 +7,10 @@
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3 # Puche 2021 pi.alert.application@gmail.com GNU GPLv3
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
VERSION = '2.56' PIALERT_PATH = '/home/pi/pialert'
VERSION_YEAR = '2021' DB_PATH = PIALERT_PATH + '/db/pialert.db'
VERSION_DATE = '2021-01-15' LOG_PATH = PIALERT_PATH + '/log'
DB_PATH = '/home/pi/pialert/db/pialert.db'
LOG_PATH = '/home/pi/pialert/log'
VENDORS_DB = '/usr/share/arp-scan/ieee-oui.txt' VENDORS_DB = '/usr/share/arp-scan/ieee-oui.txt'
PA_FRONT_URL = 'http://pi.alert/deviceDetails.php?mac='
PRINT_LOG = False PRINT_LOG = False
SMTP_SERVER = 'smtp.gmail.com' SMTP_SERVER = 'smtp.gmail.com'
@@ -25,6 +21,7 @@ SMTP_PASS = 'password'
REPORT_MAIL = False REPORT_MAIL = False
REPORT_FROM = 'Pi.Alert <' + SMTP_USER +'>' REPORT_FROM = 'Pi.Alert <' + SMTP_USER +'>'
REPORT_TO = 'user@gmail.com' REPORT_TO = 'user@gmail.com'
REPORT_DEVICE_URL = 'http://pi.alert/deviceDetails.php?mac='
# QUERY_MYIP_SERVER = 'https://diagnostic.opendns.com/myip' # QUERY_MYIP_SERVER = 'https://diagnostic.opendns.com/myip'
QUERY_MYIP_SERVER = 'http://ipv4.icanhazip.com' QUERY_MYIP_SERVER = 'http://ipv4.icanhazip.com'

3
config/version.conf Normal file
View File

@@ -0,0 +1,3 @@
VERSION = '2.60'
VERSION_YEAR = '2021'
VERSION_DATE = '2021-01-20'

View File

@@ -77,11 +77,14 @@ Estimated time: 20'
``` ```
2.5 - Connect to web admin panel 2.5 - Connect to web admin panel
```
hostname -I
```
- http://192.168.1.x/admin/ - http://192.168.1.x/admin/
- (*replace 192.168.1.x with your Raspberry IP*) - (*replace 192.168.1.x with your Raspberry IP*)
2.6 - Activate DHCP server 2.6 - Activate DHCP server
- Pi-hole -> Settings -> DHCP -> Mark "DHCP server enabled" - Pi-hole admin portal -> Settings -> DHCP -> Mark "DHCP server enabled"
2.7 - Add pi.alert DNS Record 2.7 - Add pi.alert DNS Record
``` ```
@@ -114,7 +117,7 @@ block is not necessary
the default server page to pialert subfolder the default server page to pialert subfolder
``` ```
sudo mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.html.old sudo mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.html.old
sudo ln -s /home/pi/pialert/install/index.html /var/www/html/index.html sudo ln -s ~/pialert/install/index.html /var/www/html/index.html
``` ```
3.3 - Install PHP 3.3 - Install PHP
@@ -144,17 +147,29 @@ block is not necessary
python -V python -V
``` ```
4.3 - If python is not installed in your system, you can install it with this New versions of Ubuntu includes Python 3. You can choose between use `python3`
command or to install Python 2 (that includes `python` command).
If you prefer to use Python 3, in the next installation block, you must update
`pialert.cron` file with the correct command: `python3` instead of `python`.
```
python3 -V
```
4.3 - If Python is not installed in your system, you can install it with this
command: command:
``` ```
sudo apt-get install python sudo apt-get install python
``` ```
Or this one if you prefer Python 3:
```
sudo apt-get install python3
```
## Pi.Alert ## Pi.Alert
<!--- --------------------------------------------------------------------- ---> <!--- --------------------------------------------------------------------- --->
5.1 - Download Pi.Alert and uncompress 5.1 - Download Pi.Alert and uncompress
``` ```
cd
curl -LO https://github.com/pucherot/Pi.Alert/raw/main/tar/pialert_latest.tar curl -LO https://github.com/pucherot/Pi.Alert/raw/main/tar/pialert_latest.tar
tar xvf pialert_latest.tar tar xvf pialert_latest.tar
rm pialert_latest.tar rm pialert_latest.tar
@@ -162,14 +177,15 @@ block is not necessary
5.2 - Public the front portal 5.2 - Public the front portal
``` ```
sudo ln -s /home/pi/pialert/front /var/www/html/pialert sudo ln -s ~/pialert/front /var/www/html/pialert
``` ```
5.3 - If you have configured your DNS server (Pi.hole or other) to resolve 5.3 - Configure web server redirection
the pi.alert to your raspberry, youy must configure lighttpd to redirect If you have configured your DNS server (Pi.hole or other) to resolve pi.alert
these requests to the correct pialert web folder to your raspberry, youy must configure lighttpd to redirect these requests to
the correct pialert web folder
``` ```
sudo cp pialert/install/pialert_front.conf /etc/lighttpd/conf-available sudo cp ~/pialert/install/pialert_front.conf /etc/lighttpd/conf-available
sudo ln -s ../conf-available/pialert_front.conf /etc/lighttpd/conf-enabled/pialert_front.conf sudo ln -s ../conf-available/pialert_front.conf /etc/lighttpd/conf-enabled/pialert_front.conf
sudo /etc/init.d/lighttpd restart sudo /etc/init.d/lighttpd restart
``` ```
@@ -183,13 +199,14 @@ block is not necessary
5.5 - Config Pialert parameters 5.5 - Config Pialert parameters
``` ```
nano ~/pialert/back/pialert.conf sed -i "s,'/home/pi/pialert','$HOME/pialert'," ~/pialert/config/pialert.conf
nano ~/pialert/config/pialert.conf
``` ```
- If you want to use email reporting, configure this parameters - If you want to use email reporting, configure this parameters
```ini ```ini
REPORT_MAIL = True REPORT_MAIL = True
SMTP_USER = 'user@gmail.com' SMTP_USER = 'user@gmail.com'
SMTP_PASS = 'password' SMTP_PASS = 'password' vi
REPORT_TO = 'user@gmail.com' REPORT_TO = 'user@gmail.com'
``` ```
@@ -212,26 +229,43 @@ block is not necessary
``` ```
python ~/pialert/back/pialert.py update_vendors python ~/pialert/back/pialert.py update_vendors
``` ```
or
```
python3 ~/pialert/back/pialert.py update_vendors
```
5.7 - Test Pi.Alert Scan 5.7 - Test Pi.Alert Scan
``` ```
python ~/pialert/back/pialert.py internet_IP python ~/pialert/back/pialert.py internet_IP
python ~/pialert/back/pialert.py 1 python ~/pialert/back/pialert.py 1
``` ```
or
5.8 - Add crontab jobs
``` ```
(crontab -l 2>/dev/null; cat ~/pialert/back/pialert.cron) | crontab - python3 ~/pialert/back/pialert.py internet_IP
python3 ~/pialert/back/pialert.py 1
``` ```
5.9 - Add permissions to the web-server user 5.8 - Update crontab template with python3
If you prefer to use Python 3 (installed in the previous block), you must
update `pialert.cron` file with the correct command: `python3` instead of
`python`
```
sed -i 's/python/python3/g' ~/pialert/install/pialert.cron
```
5.9 - Add crontab jobs
```
(crontab -l 2>/dev/null; cat ~/pialert/install/pialert.cron) | crontab -
```
5.10 - Add permissions to the web-server user
``` ```
sudo chgrp -R www-data ~/pialert/db sudo chgrp -R www-data ~/pialert/db
chmod -R 770 ~/pialert/db chmod -R 770 ~/pialert/db
``` ```
5.10 - Check DNS record for pi.alert (explained in point 2.7 of Pi.hole 5.11 - Check DNS record for pi.alert (explained in point 2.7 of Pi.hole
installation) installation)
- Add pi.alert DNS Record - Add pi.alert DNS Record
``` ```
hostname -I hostname -I
@@ -240,7 +274,7 @@ block is not necessary
- pi.alert 192.168.1.x - pi.alert 192.168.1.x
- (*replace 192.168.1.x with your Raspberry IP*) - (*replace 192.168.1.x with your Raspberry IP*)
5.11 - Use admin panel to configure the devices 5.12 - Use admin panel to configure the devices
- http://pi.alert/ - http://pi.alert/
- http://192.168.1.x/pialert/ - http://192.168.1.x/pialert/
- (*replace 192.168.1.x with your Raspberry IP*) - (*replace 192.168.1.x with your Raspberry IP*)

28
docs/VERSIONS_HISTORY.md Normal file
View File

@@ -0,0 +1,28 @@
# Pi.Alert Version History
<!--- --------------------------------------------------------------------- --->
| Version | Description |
| ------- | --------------------------------------------------------------- |
| v2.60 | Improved the compability of installation process (Ubuntu) |
| v2.56 | Bug fixing |
| v2.55 | Bug fixing |
| v2.52 | Bug fixing |
| v2.51 | Bug fixing |
| v2.50 | First public release |
## Pi.Alert v2.60
<!--- --------------------------------------------------------------------- --->
- `pialert.conf` moved from back to config folder
- `pialert.conf` splitted in two files: `pialert.conf` and `version.conf`
- Added compatibility with Python 3 (default version in Ubuntu)
- Added compatibility in the Installation guide with Ubuntu server
- Eliminated some unnecessary packages from the installation
### License
GPL 3.0
[Read more here](../LICENSE.txt)
### Contact
pi.alert.application@gmail.com

View File

Before

Width:  |  Height:  |  Size: 139 KiB

After

Width:  |  Height:  |  Size: 139 KiB

View File

@@ -15,7 +15,7 @@
&copy; 2020 Puche &copy; 2020 Puche
--> -->
<?php <?php
$conf_file = '../back/pialert.conf'; $conf_file = '../config/version.conf';
$conf_data = parse_ini_file($conf_file); $conf_data = parse_ini_file($conf_file);
echo '<span style="display:inline-block; transform: rotate(180deg)">&copy;</span> '. $conf_data['VERSION_YEAR'] .' Puche'; echo '<span style="display:inline-block; transform: rotate(180deg)">&copy;</span> '. $conf_data['VERSION_YEAR'] .' Puche';
?> ?>
@@ -27,7 +27,7 @@
Pi.Alert&nbsp&nbsp2.50&nbsp&nbsp<small>(2019-12-30)</small> Pi.Alert&nbsp&nbsp2.50&nbsp&nbsp<small>(2019-12-30)</small>
--> -->
<?php <?php
$conf_file = '../back/pialert.conf'; $conf_file = '../config/version.conf';
$conf_data = parse_ini_file($conf_file); $conf_data = parse_ini_file($conf_file);
echo 'Pi.Alert&nbsp&nbsp'. $conf_data['VERSION'] .'&nbsp&nbsp<small>('. $conf_data['VERSION_DATE'] .')</small>'; echo 'Pi.Alert&nbsp&nbsp'. $conf_data['VERSION'] .'&nbsp&nbsp<small>('. $conf_data['VERSION_DATE'] .')</small>';
?> ?>

View File

@@ -49,7 +49,7 @@
</head> </head>
<!-- Layout Boxed Yellow --> <!-- Layout Boxed Yellow -->
<body class="hold-transition skin-yellow-light layout-boxed sidebar-mini" style="background-image: url('img/backgroud.png');"> <body class="hold-transition skin-yellow-light layout-boxed sidebar-mini" style="background-image: url('img/background.png');">
<!-- Site wrapper --> <!-- Site wrapper -->
<div class="wrapper"> <div class="wrapper">

View File

@@ -8,7 +8,7 @@
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3 # Puche 2021 pi.alert.application@gmail.com GNU GPLv3
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
PIALERT_VERSION=`awk '$1=="VERSION" { print $3 }' ../back/pialert.conf | tr -d \'` PIALERT_VERSION=`awk '$1=="VERSION" { print $3 }' ../config/version.conf | tr -d \'`
PIALERT_DEV_PATH=/media/WD_4TB/dev PIALERT_DEV_PATH=/media/WD_4TB/dev
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------

Binary file not shown.