mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-06 17:15:38 -08:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9232f31778 | ||
|
|
9c324b1817 | ||
|
|
25b5db0e23 | ||
|
|
2af9d1dd38 | ||
|
|
040216ce3c | ||
|
|
99c29fe86b | ||
|
|
27afadfcdc | ||
|
|
4342f0f212 | ||
|
|
405331d177 | ||
|
|
ffe2851e4f | ||
|
|
6ade5a4f63 | ||
|
|
e39845afc0 |
@@ -374,7 +374,7 @@ def scan_network ():
|
||||
read_DHCP_leases ()
|
||||
|
||||
# Load current scan data
|
||||
print ('\nProcesising scan results...')
|
||||
print ('\nProcessing scan results...')
|
||||
print_log ('Save scanned devices')
|
||||
save_scanned_devices (arpscan_devices, cycle_interval)
|
||||
|
||||
@@ -586,16 +586,24 @@ def save_scanned_devices (p_arpscan_devices, p_cycle_interval):
|
||||
VALUES (?, 'Internet', ?, Null, 'queryDNS') """, (cycle, internet_IP) )
|
||||
|
||||
# #76 Add Local MAC of default local interface
|
||||
#local_mac_cmd = ["bash -lc ifconfig `ip route list default | awk {'print $5'}` | grep ether | awk '{print $2}'"]
|
||||
local_mac_cmd = ["/sbin/ifconfig `ip route list default | awk {'print $5'}` | grep ether | awk '{print $2}'"]
|
||||
local_mac = subprocess.Popen (local_mac_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0].strip()
|
||||
|
||||
local_ip_cmd = ["ip route list default | awk {'print $7'}"]
|
||||
local_ip = subprocess.Popen (local_ip_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0].strip()
|
||||
|
||||
sql.execute ("INSERT INTO CurrentScan (cur_ScanCycle, cur_MAC, cur_IP, cur_Vendor, cur_ScanMethod) "+
|
||||
"VALUES ( ?, ?, ?, Null, 'local_MAC') ", (cycle, local_mac, local_ip) )
|
||||
# BUGFIX #106 - Device that pialert is running
|
||||
# local_mac_cmd = ["bash -lc ifconfig `ip route list default | awk {'print $5'}` | grep ether | awk '{print $2}'"]
|
||||
# local_mac_cmd = ["/sbin/ifconfig `ip route list default | sort -nk11 | head -1 | awk {'print $5'}` | grep ether | awk '{print $2}'"]
|
||||
local_mac_cmd = ["/sbin/ifconfig `ip -o route get 1 | sed 's/^.*dev \\([^ ]*\\).*$/\\1/;q'` | grep ether | awk '{print $2}'"]
|
||||
local_mac = subprocess.Popen (local_mac_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0].decode().strip()
|
||||
|
||||
# local_dev_cmd = ["ip -o route get 1 | sed 's/^.*dev \\([^ ]*\\).*$/\\1/;q'"]
|
||||
# local_dev = subprocess.Popen (local_dev_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0].decode().strip()
|
||||
|
||||
# local_ip_cmd = ["ip route list default | awk {'print $7'}"]
|
||||
local_ip_cmd = ["ip -o route get 1 | sed 's/^.*src \\([^ ]*\\).*$/\\1/;q'"]
|
||||
local_ip = subprocess.Popen (local_ip_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0].decode().strip()
|
||||
|
||||
# Check if local mac has been detected with other methods
|
||||
sql.execute ("SELECT COUNT(*) FROM CurrentScan WHERE cur_ScanCycle = ? AND cur_MAC = ? ", (cycle, local_mac) )
|
||||
if sql.fetchone()[0] == 0 :
|
||||
sql.execute ("INSERT INTO CurrentScan (cur_ScanCycle, cur_MAC, cur_IP, cur_Vendor, cur_ScanMethod) "+
|
||||
"VALUES ( ?, ?, ?, Null, 'local_MAC') ", (cycle, local_mac, local_ip) )
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
def print_scan_stats ():
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
VERSION = '3.00'
|
||||
VERSION = '3.02'
|
||||
VERSION_YEAR = '2021'
|
||||
VERSION_DATE = '2021-04-21'
|
||||
VERSION_DATE = '2021-04-24'
|
||||
|
||||
@@ -16,11 +16,11 @@ Estimated time: 20'
|
||||
|
||||
## One-step Automated Install:
|
||||
<!--- --------------------------------------------------------------------- --->
|
||||
`curl -sSL https://github.com/pucherot/Pi.Alert/raw/main/install/pialert_install.sh | bash`
|
||||
#### `curl -sSL https://github.com/pucherot/Pi.Alert/raw/main/install/pialert_install.sh | bash`
|
||||
|
||||
## One-step Automated Update:
|
||||
<!--- --------------------------------------------------------------------- --->
|
||||
`curl -sSL https://github.com/pucherot/Pi.Alert/raw/main/install/pialert_update.sh | bash`
|
||||
#### `curl -sSL https://github.com/pucherot/Pi.Alert/raw/main/install/pialert_update.sh | bash`
|
||||
|
||||
## Uninstall process
|
||||
<!--- --------------------------------------------------------------------- --->
|
||||
@@ -93,7 +93,7 @@ Estimated time: 20'
|
||||
```
|
||||
or this one if have severals interfaces
|
||||
```
|
||||
ip -o route get 1 | sed -n 's/.*src \([0-9.]\+\).*/\1/p'
|
||||
ip -o route get 1 | sed 's/^.*src \([^ ]*\).*$/\1/;q'
|
||||
```
|
||||
|
||||
- http://192.168.1.x/admin/
|
||||
@@ -108,7 +108,7 @@ Estimated time: 20'
|
||||
```
|
||||
or this one if have severals interfaces
|
||||
```
|
||||
ip -o route get 1 | sed -n 's/.*src \([0-9.]\+\).*/\1/p'
|
||||
ip -o route get 1 | sed 's/^.*src \([^ ]*\).*$/\1/;q'
|
||||
```
|
||||
|
||||
- Pi-hole admin portal -> Local DNS -> DNS Records -> Add new domain /IP
|
||||
@@ -129,27 +129,37 @@ Estimated time: 20'
|
||||
If you have installed Pi.hole, lighttpd and PHP are already installed and this
|
||||
block is not necessary
|
||||
|
||||
3.1 - Install lighttpd
|
||||
3.1 - Install apt-utils
|
||||
```
|
||||
sudo apt-get install apt-utils -y
|
||||
```
|
||||
|
||||
3.2 - Install lighttpd
|
||||
```
|
||||
sudo apt-get install lighttpd -y
|
||||
```
|
||||
|
||||
3.2 - If Pi.Alert will be the only site available in this webserver, you can
|
||||
3.3 - 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
|
||||
3.4 - Install PHP
|
||||
```
|
||||
sudo apt-get install php php-cgi php-fpm php-sqlite3 -y
|
||||
```
|
||||
|
||||
3.4 - Activate PHP
|
||||
3.5 - Activate PHP
|
||||
```
|
||||
sudo lighttpd-enable-mod fastcgi-php
|
||||
sudo /etc/init.d/lighttpd restart
|
||||
sudo service lighttpd restart
|
||||
```
|
||||
|
||||
3.6 - Install sqlite3
|
||||
```
|
||||
sudo apt-get install sqlite3 -y
|
||||
```
|
||||
|
||||
|
||||
@@ -161,9 +171,9 @@ block is not necessary
|
||||
sudo arp-scan -l
|
||||
```
|
||||
|
||||
4.2 - Install dnsutils utility
|
||||
4.2 - Install dnsutils & net-tools utilities
|
||||
```
|
||||
sudo apt-get install dnsutils -y
|
||||
sudo apt-get install dnsutils net-tools -y
|
||||
```
|
||||
|
||||
4.3 - Test Python
|
||||
@@ -235,9 +245,11 @@ block is not necessary
|
||||
- If you want to use email reporting, configure this parameters
|
||||
```ini
|
||||
REPORT_MAIL = True
|
||||
REPORT_TO = 'user@gmail.com'
|
||||
SMTP_SERVER = 'smtp.gmail.com'
|
||||
SMTP_PORT = 587
|
||||
SMTP_USER = 'user@gmail.com'
|
||||
SMTP_PASS = 'password'
|
||||
REPORT_TO = 'user@gmail.com'
|
||||
```
|
||||
|
||||
- If you want to update your Dynamic DNS, configure this parameters
|
||||
@@ -303,7 +315,7 @@ block is not necessary
|
||||
```
|
||||
or this one if have severals interfaces
|
||||
```
|
||||
ip -o route get 1 | sed -n 's/.*src \([0-9.]\+\).*/\1/p'
|
||||
ip -o route get 1 | sed 's/^.*src \([^ ]*\).*$/\1/;q'
|
||||
```
|
||||
- Pi-hole admin portal -> Local DNS -> DNS Records -> Add new domain /IP
|
||||
- pi.alert 192.168.1.x
|
||||
|
||||
@@ -5,7 +5,7 @@ Estimated time: 5'
|
||||
|
||||
## One-step Automated Uninstall:
|
||||
<!--- --------------------------------------------------------------------- --->
|
||||
`curl -sSL https://github.com/pucherot/Pi.Alert/raw/main/install/pialert_uninstall.sh | bash`
|
||||
#### `curl -sSL https://github.com/pucherot/Pi.Alert/raw/main/install/pialert_uninstall.sh | bash`
|
||||
|
||||
## Uninstallation process (step by step)
|
||||
<!--- --------------------------------------------------------------------- --->
|
||||
|
||||
@@ -14,10 +14,22 @@
|
||||
| v2.50 | First public release |
|
||||
|
||||
|
||||
## Pi.Alert v3.02
|
||||
<!--- --------------------------------------------------------------------- --->
|
||||
**PENDING UPDATE DOC**
|
||||
- Fixed: UNIQUE constraint failed with Local MAC #114
|
||||
|
||||
|
||||
## Pi.Alert v3.01
|
||||
<!--- --------------------------------------------------------------------- --->
|
||||
**PENDING UPDATE DOC**
|
||||
- Fixed: Problem with local MAC & IP (raspberry) #106
|
||||
|
||||
|
||||
## Pi.Alert v3.00
|
||||
<!--- --------------------------------------------------------------------- --->
|
||||
**PENDING UPDATE DOC**
|
||||
- `arp-scan` config options: interface, several subnets. #101 #15
|
||||
- `arp-scan` config options: interface, several subnets. #101 #15
|
||||
- Next/previos button while editing devices #66 #37
|
||||
- Internet presence/sessions monitoring #63
|
||||
- Logical delete / archive / hide Device #93
|
||||
|
||||
@@ -519,7 +519,7 @@
|
||||
var parEventsRows = 'Front_Details_Events_Rows';
|
||||
var parEventsHide = 'Front_Details_Events_Hide';
|
||||
var period = '1 month';
|
||||
var tab = '#panDetails'
|
||||
var tab = 'tabDetails'
|
||||
var sessionsRows = 10;
|
||||
var eventsRows = 10;
|
||||
var eventsHide = true;
|
||||
@@ -674,9 +674,9 @@ function initializeiCheck () {
|
||||
activateSaveRestoreData();
|
||||
|
||||
// Ask skip notifications
|
||||
if (event.currentTarget.id == 'chkArchived' ) {
|
||||
askSkipNotifications();
|
||||
}
|
||||
// if (event.currentTarget.id == 'chkArchived' ) {
|
||||
// askSkipNotifications();
|
||||
// }
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
|
||||
LOG="pialert_install_`date +"%Y-%m-%d_%H-%M"`.log"
|
||||
|
||||
MAIN_IP=`ip -o route get 1 | sed -n 's/.*src \([0-9.]\+\).*/\1/p'`
|
||||
# MAIN_IP=`ip -o route get 1 | sed -n 's/.*src \([0-9.]\+\).*/\1/p'`
|
||||
MAIN_IP=`ip -o route get 1 | sed 's/^.*src \([^ ]*\).*$/\1/;q'`
|
||||
|
||||
PIHOLE_INSTALL=false
|
||||
PIHOLE_ACTIVE=false
|
||||
@@ -311,6 +312,9 @@ add_pialert_DNS() {
|
||||
install_lighttpd() {
|
||||
print_header "Lighttpd & PHP"
|
||||
|
||||
print_msg "- Installing apt-utils..."
|
||||
sudo apt-get install apt-utils -y 2>&1 >> "$LOG"
|
||||
|
||||
print_msg "- Installing lighttpd..."
|
||||
sudo apt-get install lighttpd -y 2>&1 >> "$LOG"
|
||||
|
||||
@@ -326,7 +330,11 @@ install_lighttpd() {
|
||||
fi
|
||||
|
||||
print_msg "- Restarting lighttpd..."
|
||||
sudo /etc/init.d/lighttpd restart 2>&1 >> "$LOG"
|
||||
sudo service lighttpd restart 2>&1 >> "$LOG"
|
||||
# sudo /etc/init.d/lighttpd restart 2>&1 >> "$LOG"
|
||||
|
||||
print_msg "- Installing sqlite3..."
|
||||
sudo apt-get install sqlite3 -y 2>&1 >> "$LOG"
|
||||
}
|
||||
|
||||
|
||||
@@ -342,8 +350,8 @@ install_arpscan() {
|
||||
print_msg "- Testing arp-scan..."
|
||||
sudo arp-scan -l | head -n -3 | tail +3 | tee -a "$LOG"
|
||||
|
||||
print_msg "- Installing dnsutils..."
|
||||
sudo apt-get install dnsutils -y 2>&1 >> "$LOG"
|
||||
print_msg "- Installing dnsutils & net-tools..."
|
||||
sudo apt-get install dnsutils net-tools -y 2>&1 >> "$LOG"
|
||||
}
|
||||
|
||||
|
||||
@@ -520,7 +528,7 @@ test_pialert() {
|
||||
if $FIRST_SCAN_KNOWN ; then
|
||||
echo ""
|
||||
print_msg "- Set devices as Known devices..."
|
||||
sqlite3 $PIALERT_HOME/db/pialert.db "UPDATE Devices SET dev_NewDevice=0, dev_AlertEvents=0" 2>&1 >> "$LOG"
|
||||
sqlite3 $PIALERT_HOME/db/pialert.db "UPDATE Devices SET dev_NewDevice=0, dev_AlertEvents=0 WHERE dev_NewDevice=1" 2>&1 >> "$LOG"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -573,7 +581,8 @@ publish_pialert() {
|
||||
sudo ln -s ../conf-available/pialert_front.conf "$LIGHTTPD_CONF_DIR/conf-enabled/pialert_front.conf" 2>&1 >> "$LOG"
|
||||
|
||||
print_msg "- Restarting lighttpd..."
|
||||
sudo /etc/init.d/lighttpd restart 2>&1 >> "$LOG"
|
||||
sudo sudo service lighttpd restart 2>&1 >> "$LOG"
|
||||
# sudo /etc/init.d/lighttpd restart 2>&1 >> "$LOG"
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
@@ -78,7 +78,7 @@ msgbox() {
|
||||
|
||||
END_DIALOG=false
|
||||
while ! $END_DIALOG ; do
|
||||
whiptail --title "Pi.Alert Installation" --msgbox "$LINE1\\n\\n$LINE2" $ROWS $COLS
|
||||
whiptail --title "Pi.Alert Uninstallation" --msgbox "$LINE1\\n\\n$LINE2" $ROWS $COLS
|
||||
BUTTON=$?
|
||||
ask_cancel
|
||||
ANSWER=true
|
||||
@@ -97,7 +97,7 @@ ask_yesno() {
|
||||
|
||||
END_DIALOG=false
|
||||
while ! $END_DIALOG ; do
|
||||
whiptail --title "Pi.Alert Installation" --yesno $DEF_BUTTON "$LINE1\\n\\n$LINE2" $ROWS $COLS
|
||||
whiptail --title "Pi.Alert Uninstallation" --yesno $DEF_BUTTON "$LINE1\\n\\n$LINE2" $ROWS $COLS
|
||||
BUTTON=$?
|
||||
ask_cancel
|
||||
done
|
||||
@@ -115,7 +115,7 @@ ask_option() {
|
||||
|
||||
END_DIALOG=false
|
||||
while ! $END_DIALOG ; do
|
||||
ANSWER=$(whiptail --title "Pi.Alert Installation" --menu "$1" $ROWS $COLS "${MENU_ARGS[@]}" 3>&2 2>&1 1>&3 )
|
||||
ANSWER=$(whiptail --title "Pi.Alert Uninstallation" --menu "$1" $ROWS $COLS "${MENU_ARGS[@]}" 3>&2 2>&1 1>&3 )
|
||||
BUTTON=$?
|
||||
ask_cancel CANCEL
|
||||
done
|
||||
@@ -127,7 +127,7 @@ ask_input() {
|
||||
|
||||
END_DIALOG=false
|
||||
while ! $END_DIALOG ; do
|
||||
ANSWER=$(whiptail --title "Pi.Alert Installation" --inputbox "$LINE1\\n\\n$LINE2" $ROWS $COLS "$3" 3>&2 2>&1 1>&3 )
|
||||
ANSWER=$(whiptail --title "Pi.Alert Uninstallation" --inputbox "$LINE1\\n\\n$LINE2" $ROWS $COLS "$3" 3>&2 2>&1 1>&3 )
|
||||
BUTTON=$?
|
||||
ask_cancel CANCEL
|
||||
|
||||
@@ -139,16 +139,16 @@ ask_input() {
|
||||
}
|
||||
|
||||
ask_cancel() {
|
||||
LINE0="Do you want to cancel the installation process"
|
||||
LINE0="Do you want to cancel the uninstallation process"
|
||||
LINE0=$(printf "\n\n%*s" $(((${#LINE0}+$COLS-5)/2)) "$LINE0")
|
||||
|
||||
if [ "$BUTTON" = "1" ] && [ "$1" = "CANCEL" ] ; then BUTTON="255"; fi
|
||||
|
||||
if [ "$BUTTON" = "255" ] ; then
|
||||
whiptail --title "Pi.Alert Installation" --yesno --defaultno "$LINE0" $ROWS $COLS
|
||||
whiptail --title "Pi.Alert Uninstallation" --yesno --defaultno "$LINE0" $ROWS $COLS
|
||||
|
||||
if [ "$?" = "0" ] ; then
|
||||
process_error "Installation Aborted by User"
|
||||
process_error "Uninstallation Aborted by User"
|
||||
fi
|
||||
else
|
||||
END_DIALOG=true
|
||||
|
||||
@@ -35,6 +35,7 @@ main() {
|
||||
move_files
|
||||
clean_files
|
||||
|
||||
check_packages
|
||||
download_pialert
|
||||
update_config
|
||||
update_db
|
||||
@@ -86,6 +87,21 @@ clean_files() {
|
||||
rm -r "$PIALERT_HOME/"*.md 2>/dev/null || :
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Check packages
|
||||
# ------------------------------------------------------------------------------
|
||||
check_packages() {
|
||||
print_msg "- Checking package apt-utils..."
|
||||
sudo apt-get install apt-utils -y 2>&1 >> "$LOG"
|
||||
|
||||
print_msg "- Checking package sqlite3..."
|
||||
sudo apt-get install sqlite3 -y 2>&1 >> "$LOG"
|
||||
|
||||
print_msg "- Checking packages dnsutils & net-tools..."
|
||||
sudo apt-get install dnsutils net-tools -y 2>&1 >> "$LOG"
|
||||
}
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Download and uncompress Pi.Alert
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
@@ -8,12 +8,10 @@
|
||||
# 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
|
||||
PIALERT_VERSION=`awk '$1=="VERSION" { print $3 }' pialert/config/version.conf | tr -d \'`
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
ls -l pialert/tar/pialert*.tar
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user