Compare commits

...

29 Commits
v2.56 ... v2.60

Author SHA1 Message Date
pucherot
b1be970ff2 Update INSTALL.md 2021-01-19 23:28:36 +01:00
pucherot
581d9c1e9f Update README.md 2021-01-19 23:17:20 +01:00
pucherot
b38c2f5c16 Update VERSIONS_HISTORY.md 2021-01-19 23:16:18 +01:00
pucherot
d4b8f52138 v2.60 - Improved installation process 2021-01-19 23:11:01 +01:00
pucherot
b0138ef89f Doc 2021-01-18 22:42:27 +01:00
pucherot
d6a742c6da Update INSTALL.md 2021-01-18 22:23:10 +01:00
pucherot
43ed1376dc tar 2021-01-18 22:18:53 +01:00
pucherot
0a1ee8ba94 Merge branch 'main' of https://github.com/pucherot/Pi.Alert into main 2021-01-18 22:14:39 +01:00
pucherot
3501ebdf25 Update INSTALL.md 2021-01-18 22:12:40 +01:00
pucherot
9e45441bf5 index.html 2021-01-18 22:08:46 +01:00
pucherot
57105cb6a4 Separate install & tar folders 2021-01-18 21:38:18 +01:00
pucherot
df33d07915 separate tar and install folders 2021-01-18 19:41:02 +01:00
pucherot
9ab7e01255 Update INSTALL.md 2021-01-18 16:44:12 +01:00
pucherot
ecbd1a821a Update INSTALL.md 2021-01-18 16:36:37 +01:00
pucherot
5781bb5c71 Update INSTALL.md 2021-01-18 16:11:28 +01:00
pucherot
1c21a59a74 Update INSTALL.md 2021-01-18 16:09:34 +01:00
pucherot
9b73c3a424 Update INSTALL.md 2021-01-18 15:52:57 +01:00
pucherot
e5b3408377 Update INSTALL.md 2021-01-18 15:43:03 +01:00
pucherot
d3c2c8699f Update INSTALL.md 2021-01-18 12:54:07 +01:00
pucherot
b4acfff1b9 Code headers 2021-01-16 08:36:41 +01:00
pucherot
3d04cdbc57 Code headers 2021-01-16 08:32:39 +01:00
pucherot
e49dfc9c3d Update RAMDOM_MAC.md 2021-01-15 14:32:55 +01:00
pucherot
f3c8a5d407 Doc 2021-01-15 14:00:35 +01:00
pucherot
a2f23d37ec Update README.md 2021-01-15 13:19:54 +01:00
pucherot
cdb263e791 Update RAMDOM_MAC.md 2021-01-15 12:56:25 +01:00
pucherot
a983b374c9 Update INSTALL.md 2021-01-15 12:56:07 +01:00
pucherot
40844c721c Update DEVICE_MANAGEMENT.md 2021-01-15 12:55:36 +01:00
pucherot
90242c8f3b Update README.md 2021-01-15 12:54:19 +01:00
pucherot
5f73a286bb License 2021-01-15 12:44:37 +01:00
27 changed files with 433 additions and 191 deletions

View File

View File

@@ -36,16 +36,18 @@ Up to three scanning methods are used:
## Components ## Components
The system consists of two parts: The system consists of two parts:
- **Back**, in charge of: ### Back
In charge of:
- Scan the network searching connected devices using the scanning methods - Scan the network searching connected devices using the scanning methods
described described
- Store the information in the DB - Store the information in the DB
- Report the changes detected by e-mail - Report the changes detected by e-mail
| ![Report 1][report1] | ![Report 2][report2] | | ![Report 1][report1] | ![Report 2][report2] |
| -------------------- | -------------------- | | -------------------- | -------------------- |
- **Front**, a web frontal that allows: ### Front
A web frontal that allows:
- Manage the devices inventory and the characteristics - Manage the devices inventory and the characteristics
- Display in a visual way all the information collected by the back - Display in a visual way all the information collected by the back
- Sessions - Sessions
@@ -68,7 +70,7 @@ The system consists of two parts:
Initially designed to run on a Raspberry PI, probably it can run on many other Initially designed to run on a Raspberry PI, probably it can run on many other
Linux distributions. Linux distributions.
- [Installation instructions](docs/INSTALL.md) - [Installation Guide](docs/INSTALL.md)
## Device Management ## Device Management
@@ -77,9 +79,12 @@ Linux distributions.
- [Device Management instructions](docs/DEVICE_MANAGEMENT.md) - [Device Management instructions](docs/DEVICE_MANAGEMENT.md)
## Other useful info ## Other useful info
<!--- --------------------------------------------------------------------- ---> <!--- --------------------------------------------------------------------- --->
### [Versions History](docs/VERSIONS_HISTORY.md)
### Powered by: ### Powered by:
| Product | Objetive | | Product | Objetive |
| ------------ | -------------------------------------- | | ------------ | -------------------------------------- |
@@ -97,7 +102,7 @@ Linux distributions.
### License ### License
GPL 3.0 GPL 3.0
[Read more here](docs/LICENSE.txt) [Read more here](LICENSE.txt)
### Contact ### Contact
pi.alert.application@gmail.com pi.alert.application@gmail.com

View File

@@ -1,7 +0,0 @@
#
# Pi.Alert cron
#
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,8 +1,13 @@
#!/usr/bin/env python #!/usr/bin/env python
# #
# Pi.Alert v2.56 / 2021-01-15 #-------------------------------------------------------------------------------
# Puche 2021 # Pi.Alert v2.60 / 2021-01-20
# GNU GPLv3 # Open Source Network Guard / WIFI & LAN intrusion detector
#
# pialert.py - Back module. Network scanner
#-------------------------------------------------------------------------------
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3
#-------------------------------------------------------------------------------
#=============================================================================== #===============================================================================
@@ -27,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")
#=============================================================================== #===============================================================================
@@ -49,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
@@ -249,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']
@@ -1044,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()
@@ -1094,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'])
@@ -1122,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'])
@@ -1149,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'])
@@ -1179,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,3 +1,12 @@
<!-- ---------------------------------------------------------------------------
# Pi.Alert
# Open Source Network Guard / WIFI & LAN intrusion detector
#
# repot_template.html - Back module. Template to email reporting in HTML format
#-------------------------------------------------------------------------------
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3
#--------------------------------------------------------------------------- -->
<html> <html>
<head> <head>
@@ -101,9 +110,9 @@
<td> <td>
<table width=100% border=0 bgcolor=#70AD47 cellpadding=5px cellspacing=0 style="border-collapse: collapse; font-size: 12px; font-weight: bold; color:#385723"> <table width=100% border=0 bgcolor=#70AD47 cellpadding=5px cellspacing=0 style="border-collapse: collapse; font-size: 12px; font-weight: bold; color:#385723">
<tr> <tr>
<td width=25% style="text-align:Left"> Puche <PIALERT_YEAR></td> <td width=25% style="text-align:Left"> <span style="display:inline-block; transform: rotate(180deg)">&copy;</span> <PIALERT_YEAR> Puche</td>
<td width=50% style="text-align:center"> Pi.Alert <PIALERT_VERSION> &nbsp; / &nbsp; <PIALERT_VERSION_DATE> </td> <td width=50% style="text-align:center"> Pi.Alert <PIALERT_VERSION> &nbsp; &nbsp; (<PIALERT_VERSION_DATE>) </td>
<td width=25% style="text-align:right"> GNU GPLv3</td> <td width=25% style="text-align:right"> GNU GPLv3</td>
</tr> </tr>
</table> </table>
</td> </td>

View File

@@ -24,4 +24,4 @@ Events
<TABLE_EVENTS> <TABLE_EVENTS>
</SECTION_EVENTS> </SECTION_EVENTS>
---------------------------------------------------------------------- ----------------------------------------------------------------------
Puche <PIALERT_YEAR> Pi.Alert <PIALERT_VERSION> / <PIALERT_VERSION_DATE> GNU GPLv3 (?) <PIALERT_YEAR> Puche Pi.Alert <PIALERT_VERSION> (<PIALERT_VERSION_DATE>) GNU GPLv3

View File

@@ -1,10 +1,18 @@
#!/bin/sh #!/bin/sh
# ------------------------------------------------------------------------------
# Pi.Alert
# Open Source Network Guard / WIFI & LAN intrusion detector
# #
# Update MAC Vendor DB # vendors_db_update.sh - Back module. IEEE Vendors db update
# # ------------------------------------------------------------------------------
# /usr/share/arp-scan # Puche 2021 pi.alert.application@gmail.com GNU GPLv3
# /usr/share/ieee-data # ------------------------------------------------------------------------------
# /var/lib/ieee-data
# ----------------------------------------------------------------------
# Main directories to update:
# /usr/share/arp-scan
# /usr/share/ieee-data
# /var/lib/ieee-data
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------

View File

@@ -1,11 +1,16 @@
VERSION = '2.56' #-------------------------------------------------------------------------------
VERSION_YEAR = '2021' # Pi.Alert
VERSION_DATE = '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
#-------------------------------------------------------------------------------
DB_PATH = '/home/pi/pialert/db/pialert.db' PIALERT_PATH = '/home/pi/pialert'
LOG_PATH = '/home/pi/pialert/log' DB_PATH = PIALERT_PATH + '/db/pialert.db'
LOG_PATH = PIALERT_PATH + '/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'
@@ -16,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

@@ -79,7 +79,7 @@ decides to change the MAC).
### License ### License
GPL 3.0 GPL 3.0
[Read more here](LICENSE.txt) [Read more here](../LICENSE.txt)
### Contact ### Contact
pi.alert.application@gmail.com pi.alert.application@gmail.com

View File

@@ -1,4 +1,4 @@
# Pi.Alert Installation # Pi.Alert Installation Guide
<!--- --------------------------------------------------------------------- ---> <!--- --------------------------------------------------------------------- --->
Initially designed to run on a Raspberry PI, probably it can run on many other Initially designed to run on a Raspberry PI, probably it can run on many other
Linux distributions. Linux distributions.
@@ -17,188 +17,272 @@ Estimated time: 20'
# Installation process # Installation process
<!--- --------------------------------------------------------------------- ---> <!--- --------------------------------------------------------------------- --->
## Raspberry Setup ## Raspberry Setup
<!--- --------------------------------------------------------------------- ---> <!--- --------------------------------------------------------------------- --->
1 - Install 'Raspberry Pi OS' 1.1 - Install 'Raspberry Pi OS'
- Instructions https://www.raspberrypi.org/documentation/installation/installing-images/ - Instructions https://www.raspberrypi.org/documentation/installation/installing-images/
- *Lite version (without Descktop) is enough for Pi.Alert* - *Lite version (without Descktop) is enough for Pi.Alert*
2 - Activate ssh 1.2 - Activate ssh
- Create a empty file with name 'ssh' in the boot partition of the SD - Create a empty file with name 'ssh' in the boot partition of the SD
3 - Start the raspberry 1.3 - Start the raspberry
4 - Login to the system with pi user 1.4 - Login to the system with pi user
``` ```
user: pi user: pi
password: raspberry password: raspberry
``` ```
5 - Change the default password of pi user 1.5 - Change the default password of pi user
``` ```
passwd passwd
``` ```
6 - Setup the basic configuration 1.6 - Setup the basic configuration
``` ```
sudo raspi-config sudo raspi-config
``` ```
7 - Optionally, configure a static IP in raspi-config 1.7 - Optionally, configure a static IP in raspi-config
8 - Update the OS 1.8 - Update the OS
``` ```
sudo apt-get update sudo apt-get update
sudo apt-get upgrade sudo apt-get upgrade
sudo reboot sudo shutdown -r now
``` ```
## Pi-hole Setup
## Pi-hole Setup (optional)
<!--- --------------------------------------------------------------------- ---> <!--- --------------------------------------------------------------------- --->
1- Links & Doc 2.1 - Links & Doc
- https://pi-hole.net/ - https://pi-hole.net/
- https://github.com/pi-hole/pi-hole - https://github.com/pi-hole/pi-hole
- https://github.com/pi-hole/pi-hole/#one-step-automated-install - https://github.com/pi-hole/pi-hole/#one-step-automated-install
2 - Login to the system with pi user 2.2 - Login to the system with pi user
3 - Install Pi-hole 2.3 - Install Pi-hole
``` ```
curl -sSL https://install.pi-hole.net | bash curl -sSL https://install.pi-hole.net | bash
``` ```
- Mark "Install web admin interface" - Select "Install web admin interface"
- Mark "Install web server lighttpd" - Select "Install web server lighttpd"
4 - Configure Pi-hole admin password 2.4 - Configure Pi-hole admin password
``` ```
pihole -a -p PASSWORD pihole -a -p PASSWORD
``` ```
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*)
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"
7 - Add pi.alert DNS Record 2.7 - Add pi.alert DNS Record
- Pi-hole -> Local DNS -> DNS Records -> Add new domain /IP ```
hostname -I
```
- Pi-hole admin portal -> Local DNS -> DNS Records -> Add new domain /IP
- 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*)
8 - Deactivate your current DHCP Server (*Normaly at your router or AP*) 2.8 - Deactivate your current DHCP Server (*Normaly at your router or AP*)
9 - Renew your computer IP to unsure you are using the new DHCP and DNS server 2.9 - Renew your computer IP to unsure you are using the new DHCP and DNS server
- Windows: cmd -> ipconfig /renew - Windows: cmd -> ipconfig /renew
- Linux: shell -> sudo dhclient -r; sudo dhclient - Linux: shell -> sudo dhclient -r; sudo dhclient
- Mac: Apple menu -> System Preferences -> Network -> Select the network -> - Mac: Apple menu -> System Preferences -> Network -> Select the network
Advanced -> TCP/IP -> Renew DHCP Lease -> Advanced -> TCP/IP -> Renew DHCP Lease
## Lighttpd & PHP
<!--- --------------------------------------------------------------------- --->
If you have installed Pi.hole, lighttpd and PHP are already installed and this
block is not necessary
3.1 - Install lighttpd
```
sudo apt-get install lighttpd -y
```
3.2 - If Pi.Alert will be the only site available in this webserver, you can
redirect the default server page to pialert subfolder
```
sudo mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.html.old
sudo ln -s ~/pialert/install/index.html /var/www/html/index.html
```
3.3 - Install PHP
```
sudo apt-get install php php-cgi php-fpm php-sqlite3 -y
```
3.4 - Activate PHP
```
sudo lighttpd-enable-mod fastcgi-php
sudo /etc/init.d/lighttpd restart
```
## arp-scan & Python ## arp-scan & Python
<!--- --------------------------------------------------------------------- ---> <!--- --------------------------------------------------------------------- --->
1 - Install arp-scan utility and test 4.1 - Install arp-scan utility and test
``` ```
sudo apt-get install arp-scan sudo apt-get install arp-scan -y
sudo arp-scan -l sudo arp-scan -l
``` ```
2 - Install Python & packages 4.2 - Test Python
```
sudo apt-get install python-setuptools
sudo apt install python-pip
pip install netaddr New versions of 'Raspberry Pi OS' includes Python. You can check that
pip install dpkt Python is installed with the command:
pip install MacLookup ```
``` python -V
```
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:
```
sudo apt-get install python
```
Or this one if you prefer Python 3:
```
sudo apt-get install python3
```
## Pi.Alert ## Pi.Alert
<!--- --------------------------------------------------------------------- ---> <!--- --------------------------------------------------------------------- --->
1- Download Pi.Alert and uncompress 5.1 - Download Pi.Alert and uncompress
``` ```
curl -LO https://github.com/pucherot/Pi.Alert/raw/main/install/pialert_latest.tar cd
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
``` ```
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
``` ```
3 - Update lighttpd config 5.3 - Configure web server redirection
```
sudo sh -c "printf '\n\n\$HTTP[\"host\"] == \"pi.alert\" {\n server.document-root = \"/var/www/html/pialert/\"\n}\n' >> /etc/lighttpd/external.conf" If you have configured your DNS server (Pi.hole or other) to resolve pi.alert
with the IP of 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 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
``` ```
4 - If you want to use email reporting with gmail 5.4 - If you want to use email reporting with gmail
- Go to your Google Account https://myaccount.google.com/ - Go to your Google Account https://myaccount.google.com/
- On the left navigation panel, click Security - On the left navigation panel, click Security
- On the bottom of the page, in the Less secure app access panel, - On the bottom of the page, in the Less secure app access panel,
click Turn on access click Turn on access
- Click Save button - Click Save button
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
REPORT_MAIL = True REPORT_MAIL = True
SMTP_USER = 'user@gmail.com' SMTP_USER = 'user@gmail.com'
SMTP_PASS = 'password' SMTP_PASS = 'password'
REPORT_TO = 'user@gmail.com' REPORT_TO = 'user@gmail.com'
``` ```
- If you want to update your Dynamic DNS, configure this parameters - If you want to update your Dynamic DNS, configure this parameters
``` ```ini
DDNS_ACTIVE = True DDNS_ACTIVE = True
DDNS_DOMAIN = 'your_domain.freeddns.org' DDNS_DOMAIN = 'your_domain.freeddns.org'
DDNS_USER = 'dynu_user' DDNS_USER = 'dynu_user'
DDNS_PASSWORD = 'A0000000B0000000C0000000D0000000' DDNS_PASSWORD = 'A0000000B0000000C0000000D0000000'
DDNS_UPDATE_URL = 'https://api.dynu.com/nic/update?' DDNS_UPDATE_URL = 'https://api.dynu.com/nic/update?'
``` ```
- If you have installed Pi.hole and DHCP, activate this parameters - If you have installed Pi.hole and DHCP, activate this parameters
``` ```ini
PIHOLE_ACTIVE = True PIHOLE_ACTIVE = True
DHCP_ACTIVE = True DHCP_ACTIVE = True
``` ```
6 - Update vendors DB 5.6 - Update vendors DB
``` ```
python ~/pialert/back/pialert.py update_vendors python ~/pialert/back/pialert.py update_vendors
``` ```
or
```
python3 ~/pialert/back/pialert.py update_vendors
```
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
```
python3 ~/pialert/back/pialert.py internet_IP
python3 ~/pialert/back/pialert.py 1
```
8 - Add crontab jobs 5.8 - Update crontab template with python3
```
(crontab -l 2>/dev/null; cat ~/pialert/back/pialert.cron) | crontab -
```
9 - Add permissions to the web-server user 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
sudo chgrp -R www-data ~/pialert/back ~/pialert/back/pialert.conf ~/pialert/front ~/pialert/db `python`
chmod -R 770 ~/pialert/back ~/pialert/back/pialert.conf ~/pialert/front ~/pialert/db ```
``` sed -i 's/python/python3/g' ~/pialert/install/pialert.cron
```
10 - Check DNS record por pi.alert (explained in point 7 of Pi.hole installing) 5.9 - Add crontab jobs
- Add pi.alert DNS Record ```
- Pi-hole -> Local DNS -> DNS Records -> Add new domain /IP (crontab -l 2>/dev/null; cat ~/pialert/install/pialert.cron) | crontab -
- pi.alert 192.168.1.x ```
- (*replace 192.168.1.x with your Raspberry IP*)
11 - Use admin panel to configure the devices 5.10 - Add permissions to the web-server user
- http://pi.alert/ ```
- http://192.168.1.x/pialert/ sudo chgrp -R www-data ~/pialert/db
- (*replace 192.168.1.x with your Raspberry IP*) chmod -R 770 ~/pialert/db
```
5.11 - Check DNS record for pi.alert (explained in point 2.7 of Pi.hole
installation)
- Add pi.alert DNS Record
```
hostname -I
```
- Pi-hole admin portal -> Local DNS -> DNS Records -> Add new domain /IP
- pi.alert 192.168.1.x
- (*replace 192.168.1.x with your Raspberry IP*)
5.12 - Use admin panel to configure the devices
- http://pi.alert/
- http://192.168.1.x/pialert/
- (*replace 192.168.1.x with your Raspberry IP*)
## Device Management ## Device Management
@@ -209,7 +293,7 @@ Estimated time: 20'
### License ### License
GPL 3.0 GPL 3.0
[Read more here](LICENSE.txt) [Read more here](../LICENSE.txt)
### Contact ### Contact
pi.alert.application@gmail.com pi.alert.application@gmail.com

View File

@@ -16,12 +16,12 @@ WIFI's**, in this way, Pi.Alert will be able to identify the device, and it
will not identify it as a new device every so often (every time IOS or Android will not identify it as a new device every so often (every time IOS or Android
decides to change the MAC). decides to change the MAC).
### IOS ## IOS
![ios][ios] ![ios][ios]
- [Use private Wi-Fi addresses in iOS 14](https://support.apple.com/en-us/HT211227) - [Use private Wi-Fi addresses in iOS 14](https://support.apple.com/en-us/HT211227)
### Android ## Android
![Android][Android] ![Android][Android]
- [How to Disable MAC Randomization in Android 10](https://support.boingo.com/s/article/How-to-Disable-MAC-Randomization-in-Android-10-Android-Q) - [How to Disable MAC Randomization in Android 10](https://support.boingo.com/s/article/How-to-Disable-MAC-Randomization-in-Android-10-Android-Q)
@@ -30,7 +30,7 @@ decides to change the MAC).
### License ### License
GPL 3.0 GPL 3.0
[Read more here](LICENSE.txt) [Read more here](../LICENSE.txt)
### Contact ### Contact
pi.alert.application@gmail.com pi.alert.application@gmail.com

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 installed with 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

@@ -1,3 +1,12 @@
<!-- ---------------------------------------------------------------------------
# Pi.Alert
# Open Source Network Guard / WIFI & LAN intrusion detector
#
# repot_sample.html - Back module. Sample email reporting in HTML format
#-------------------------------------------------------------------------------
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3
#--------------------------------------------------------------------------- -->
<html> <html>
<head> <head>

View File

@@ -1,3 +1,12 @@
<!-- ---------------------------------------------------------------------------
# Pi.Alert
# Open Source Network Guard / WIFI & LAN intrusion detector
#
# repot_sample.html - Back module. Sample email reporting in HTML format
#-------------------------------------------------------------------------------
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3
#--------------------------------------------------------------------------- -->
<html> <html>
<head> <head>

View File

Before

Width:  |  Height:  |  Size: 139 KiB

After

Width:  |  Height:  |  Size: 139 KiB

View File

@@ -1,3 +1,11 @@
<!-- ---------------------------------------------------------------------------
# Pi.Alert
# Open Source Network Guard / WIFI & LAN intrusion detector
#
# footer.php - Front module. Common footer to all the front pages
#-------------------------------------------------------------------------------
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3
#--------------------------------------------------------------------------- -->
<!-- Main Footer --> <!-- Main Footer -->
<footer class="main-footer"> <footer class="main-footer">
@@ -7,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';
?> ?>
@@ -16,12 +24,12 @@
<div class="pull-right no-hidden-xs"> <div class="pull-right no-hidden-xs">
<!-- <!--
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>';
?> ?>
</div> </div>
</footer> </footer>

View File

@@ -1,9 +1,18 @@
<!-- ---------------------------------------------------------------------------
# Pi.Alert
# Open Source Network Guard / WIFI & LAN intrusion detector
#
# header.php - Front module. Common header to all the front pages
#-------------------------------------------------------------------------------
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3
#--------------------------------------------------------------------------- -->
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Pi.alert</title> <title>Pi.Alert</title>
<!-- Tell the browser to be responsive to screen width --> <!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"> <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- Bootstrap 3.3.7 --> <!-- Bootstrap 3.3.7 -->
@@ -21,7 +30,7 @@
<link rel="stylesheet" href="lib/AdminLTE/dist/css/skins/skin-yellow-light.min.css"> <link rel="stylesheet" href="lib/AdminLTE/dist/css/skins/skin-yellow-light.min.css">
<!-- Pi.alert CSS --> <!-- Pi.Alert CSS -->
<link rel="stylesheet" href="css/pialert.css"> <link rel="stylesheet" href="css/pialert.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
@@ -40,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">
@@ -52,7 +61,7 @@
<!-- mini logo for sidebar mini 50x50 pixels --> <!-- mini logo for sidebar mini 50x50 pixels -->
<span class="logo-mini">P<b>a</b></span> <span class="logo-mini">P<b>a</b></span>
<!-- logo for regular state and mobile devices --> <!-- logo for regular state and mobile devices -->
<span class="logo-lg">Pi<b>.alert</b></span> <span class="logo-lg">Pi<b>.Alert</b></span>
</a> </a>
<!-- Header Navbar --> <!-- Header Navbar -->
@@ -73,14 +82,14 @@
<!-- Menu Toggle Button --> <!-- Menu Toggle Button -->
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">
<!-- The user image in the navbar--> <!-- The user image in the navbar-->
<img src="img/pialertLogoWhite.png" class="user-image" style="border-radius: initial" alt="Pi.alert Logo"> <img src="img/pialertLogoWhite.png" class="user-image" style="border-radius: initial" alt="Pi.Alert Logo">
<!-- hidden-xs hides the username on small devices so only the image appears. --> <!-- hidden-xs hides the username on small devices so only the image appears. -->
<span class="hidden-xs">Pi.alert</span> <span class="hidden-xs">Pi.Alert</span>
</a> </a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<!-- The user image in the menu --> <!-- The user image in the menu -->
<li class="user-header"> <li class="user-header">
<img src="img/pialertLogoWhite.png" class="img-circle" alt="Pi.alert Logo" style="border-color:transparent"> <img src="img/pialertLogoWhite.png" class="img-circle" alt="Pi.Alert Logo" style="border-color:transparent">
<p> <p>
Open Source Network Guard Open Source Network Guard
@@ -91,15 +100,14 @@
<li class="user-body"> <li class="user-body">
<div class="row"> <div class="row">
<div class="col-xs-4 text-center"> <div class="col-xs-4 text-center">
<a target="_blank" href="https://github.com/pucherot/Pi.Alert">GitHub Pi.Alert</a>
</div> </div>
<div class="col-xs-4 text-center"> <div class="col-xs-4 text-center">
<a href="https://github.com/pucherot/Pi.Alert">GitHub</a> <a href="mailto:pi.alert.application@gmail.com">email Support</a>
</div> </div>
<!--
<div class="col-xs-4 text-center"> <div class="col-xs-4 text-center">
<a href="https://github.com/pucherot/Pi.Alert">Pi.Alert</a> <a target="_blank" href="https://github.com/pucherot/Pi.Alert/blob/main/LICENSE.txt">GNU GPLv3</a>
</div> </div>
-->
<!-- <!--
<div class="col-xs-4 text-center"> <div class="col-xs-4 text-center">
<a href="#">Updates</a> <a href="#">Updates</a>
@@ -123,11 +131,11 @@
<!-- Sidebar user panel (optional) --> <!-- Sidebar user panel (optional) -->
<div class="user-panel"> <div class="user-panel">
<a href="/" class="logo"> <a href="/" class="logo">
<img src="img/pialertLogoGray80.png" class="img-responsive" alt="Pi.alert Logo"/> <img src="img/pialertLogoGray80.png" class="img-responsive" alt="Pi.Alert Logo"/>
</a> </a>
<div class="pull-left image"> <div class="pull-left image">
<!-- <!--
<br><img src="img/pialertLogoBlack.png" class="img-responsive" alt="Pi.alert Logo" style="display: table; table-layout: fixed;" /> <br><img src="img/pialertLogoBlack.png" class="img-responsive" alt="Pi.Alert Logo" style="display: table; table-layout: fixed;" />
--> -->
</div> </div>

View File

@@ -1,18 +0,0 @@
#
PIALERT_VERSION=`awk '$1=="VERSION" { print $3 }' ../back/pialert.conf | tr -d \'`
PIALERT_DEV_PATH=/media/WD_4TB/dev
cd $PIALERT_DEV_PATH
pwd
ls -l pialert/install/pialert*.tar
tar tvf pialert/install/pialert_latest.tar | wc -l
rm pialert/install/pialert_*.tar
tar cvf pialert/install/pialert_$PIALERT_VERSION.tar --exclude="pialert/install" --exclude="pialert/.git" pialert | wc -l
ln -s pialert_$PIALERT_VERSION.tar pialert/install/pialert_latest.tar
ls -l pialert/install/pialert*.tar

11
install/index.html Normal file
View File

@@ -0,0 +1,11 @@
<!-- ---------------------------------------------------------------------------
# Pi.Alert
# Open Source Network Guard / WIFI & LAN intrusion detector
#
# index.html - Redirect file to pialert subdirectory
#-------------------------------------------------------------------------------
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3
#--------------------------------------------------------------------------- -->
<meta http-equiv="refresh" content="0; url=pialert"/>
<meta http-equiv="Cache-Control" content="no-store" />

13
install/pialert.cron Normal file
View File

@@ -0,0 +1,13 @@
#-------------------------------------------------------------------------------
# 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

@@ -0,0 +1,12 @@
# ------------------------------------------------------------------------------
# Pi.Alert
# Open Source Network Guard / WIFI & LAN intrusion detector
#
# index.html - Redirect file to pialert subdirectory
# ------------------------------------------------------------------------------
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3
# ------------------------------------------------------------------------------
$HTTP["host"] == "pi.alert" {
server.document-root = "/var/www/html/pialert/"
}

View File

@@ -1 +1,10 @@
#-------------------------------------------------------------------------------
# Pi.Alert
# Open Source Network Guard / WIFI & LAN intrusion detector
#
# IP_changes.log - Back module. Logfile for Internet IP changes
#-------------------------------------------------------------------------------
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3
#-------------------------------------------------------------------------------
2021-01-01 00:00:00 0.0.0.0 2021-01-01 00:00:00 0.0.0.0

View File

@@ -1,3 +1,12 @@
<!-- ---------------------------------------------------------------------------
# Pi.Alert
# Open Source Network Guard / WIFI & LAN intrusion detector
#
# repot_template.html - Back module. Template to email reporting in HTML format
#-------------------------------------------------------------------------------
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3
#--------------------------------------------------------------------------- -->
<html> <html>
<head> <head>

28
tar/create_tar.sh Normal file
View File

@@ -0,0 +1,28 @@
#!/bin/sh
# ------------------------------------------------------------------------------
# Pi.Alert
# Open Source Network Guard / WIFI & LAN intrusion detector
#
# create_tar.sh - Create the installation file
# ------------------------------------------------------------------------------
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3
# ------------------------------------------------------------------------------
PIALERT_VERSION=`awk '$1=="VERSION" { print $3 }' ../config/version.conf | tr -d \'`
PIALERT_DEV_PATH=/media/WD_4TB/dev
# ------------------------------------------------------------------------------
cd $PIALERT_DEV_PATH
pwd
# ------------------------------------------------------------------------------
ls -l pialert/tar/pialert*.tar
tar tvf pialert/tar/pialert_latest.tar | wc -l
rm pialert/tar/pialert_*.tar
# ------------------------------------------------------------------------------
tar cvf pialert/tar/pialert_$PIALERT_VERSION.tar --exclude="pialert/tar" --exclude="pialert/.git" pialert | wc -l
ln -s pialert_$PIALERT_VERSION.tar pialert/tar/pialert_latest.tar
ls -l pialert/tar/pialert*.tar

View File

Binary file not shown.

View File

Binary file not shown.