2610.1 adding logfile

This commit is contained in:
DAProgs committed 2026-10-03 15:41:38 -04:00
1 parent 0f88c2769b
commit 7619ff9030
2 files changed
+68 -5

No files matched your search

+57 -5
View File
@@ -1,6 +1,8 @@
#!/bin/bash
INTERFACES_FILE="/etc/network/interfaces"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
LOG_FILE="$SCRIPT_DIR/portspoof.log"
# SHA256 hash of the shell access password.
# To change it: echo -n "yourpassword" | sha256sum
@@ -401,9 +403,54 @@ shell_access() {
read -rp "Press Enter to continue..."
}
# ── log viewer ────────────────────────────────────────────────────────────────
show_log_viewer() {
tput civis
trap 'tput cnorm; echo; return 1' INT
while true; do
clear
echo ""
echo "╔══════════════════════════════════════════════════════════════════════════╗"
printf "║ %-71s║\n" "Last 5 Events ── portspoof.log"
echo "╚══════════════════════════════════════════════════════════════════════════╝"
echo ""
printf " %-28s %-20s%s\n" "Timestamp" "Source IP" "Destination Port"
printf " %s %s %s\n" "────────────────────────────" "──────────────────────" "────────────────"
if [ -f "$LOG_FILE" ]; then
tail -n 5 "$LOG_FILE" | python3 -c '
import sys, json
for line in sys.stdin:
line = line.strip()
if not line:
continue
try:
e = json.loads(line)
except ValueError:
continue
ts = str(e.get("timestamp", "?"))
src = str(e.get("src_ip", "?"))
dst = str(e.get("dst_port", "?"))
print(f" {ts:<28} {src:<20} {dst}")
'
else
echo " Log file not found: $LOG_FILE"
fi
echo ""
echo " Auto-refresh: 1s — press any key to return to the menu"
if IFS= read -rsn1 -t 1 _; then
break # key pressed — back to menu
fi
done
tput cnorm
trap - INT
}
# ── main menu ─────────────────────────────────────────────────────────────────
MENU_ITEMS=("Refresh" "Set Static IP" "Set DHCP" "Shell" "Reboot" "Update")
MENU_ITEMS=("Refresh" "Log" "Set Static IP" "Set DHCP" "Shell" "Reboot" "Update")
main_menu() {
local choice
@@ -416,26 +463,31 @@ main_menu() {
0)
;; # Refresh — just redraw
1)
show_log_viewer
echo ""
read -rp "Press Enter to continue..."
;;
2)
if select_interface; then
set_static "$SELECTED_IFACE"
fi
echo ""
read -rp "Press Enter to continue..."
;;
2)
3)
if select_interface; then
set_dhcp "$SELECTED_IFACE"
fi
echo ""
read -rp "Press Enter to continue..."
;;
3)
4)
shell_access
;;
4)
5)
reboot_confirm
;;
5)
6)
run_update
;;
esac