2610.1 adding logfile
This commit is contained in:
1 parent
0f88c2769b
commit
7619ff9030
2 files changed
+68
-5
No files matched your search
+57
-5
@@ -1,6 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
INTERFACES_FILE="/etc/network/interfaces"
|
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.
|
# SHA256 hash of the shell access password.
|
||||||
# To change it: echo -n "yourpassword" | sha256sum
|
# To change it: echo -n "yourpassword" | sha256sum
|
||||||
@@ -401,9 +403,54 @@ shell_access() {
|
|||||||
read -rp "Press Enter to continue..."
|
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 ─────────────────────────────────────────────────────────────────
|
# ── 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() {
|
main_menu() {
|
||||||
local choice
|
local choice
|
||||||
@@ -416,26 +463,31 @@ main_menu() {
|
|||||||
0)
|
0)
|
||||||
;; # Refresh — just redraw
|
;; # Refresh — just redraw
|
||||||
1)
|
1)
|
||||||
|
show_log_viewer
|
||||||
|
echo ""
|
||||||
|
read -rp "Press Enter to continue..."
|
||||||
|
;;
|
||||||
|
2)
|
||||||
if select_interface; then
|
if select_interface; then
|
||||||
set_static "$SELECTED_IFACE"
|
set_static "$SELECTED_IFACE"
|
||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
read -rp "Press Enter to continue..."
|
read -rp "Press Enter to continue..."
|
||||||
;;
|
;;
|
||||||
2)
|
3)
|
||||||
if select_interface; then
|
if select_interface; then
|
||||||
set_dhcp "$SELECTED_IFACE"
|
set_dhcp "$SELECTED_IFACE"
|
||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
read -rp "Press Enter to continue..."
|
read -rp "Press Enter to continue..."
|
||||||
;;
|
;;
|
||||||
3)
|
4)
|
||||||
shell_access
|
shell_access
|
||||||
;;
|
;;
|
||||||
4)
|
5)
|
||||||
reboot_confirm
|
reboot_confirm
|
||||||
;;
|
;;
|
||||||
5)
|
6)
|
||||||
run_update
|
run_update
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{"timestamp": "2025-06-01T14:32:07.841203+00:00", "src_ip": "198.51.100.10", "src_port": 54312, "dst_port": 443, "banner_hex": "485454502f312e31203230300d0a", "banner_len": 14}
|
||||||
|
{"timestamp": "2025-06-01T14:32:09.841203+00:00", "src_ip": "198.51.100.11", "src_port": 54312, "dst_port": 443, "banner_hex": "485454502f312e31203230300d0a", "banner_len": 14}
|
||||||
|
{"timestamp": "2025-06-01T14:32:10.841203+00:00", "src_ip": "198.51.100.12", "src_port": 54312, "dst_port": 443, "banner_hex": "485454502f312e31203230300d0a", "banner_len": 14}
|
||||||
|
{"timestamp": "2025-06-01T14:32:12.841203+00:00", "src_ip": "198.51.100.13", "src_port": 54312, "dst_port": 443, "banner_hex": "485454502f312e31203230300d0a", "banner_len": 14}
|
||||||
|
{"timestamp": "2025-06-01T14:32:15.841203+00:00", "src_ip": "198.51.100.14", "src_port": 54312, "dst_port": 443, "banner_hex": "485454502f312e31203230300d0a", "banner_len": 14}
|
||||||
|
{"timestamp": "2025-06-01T14:32:16.841203+00:00", "src_ip": "198.51.100.15", "src_port": 54312, "dst_port": 443, "banner_hex": "485454502f312e31203230300d0a", "banner_len": 14}
|
||||||
|
{"timestamp": "2025-06-01T14:32:17.841203+00:00", "src_ip": "198.51.100.16", "src_port": 54312, "dst_port": 443, "banner_hex": "485454502f312e31203230300d0a", "banner_len": 14}
|
||||||
|
{"timestamp": "2025-06-01T14:32:19.841203+00:00", "src_ip": "198.51.100.17", "src_port": 54312, "dst_port": 443, "banner_hex": "485454502f312e31203230300d0a", "banner_len": 14}
|
||||||
|
{"timestamp": "2025-06-01T14:32:21.841203+00:00", "src_ip": "198.51.100.18", "src_port": 54312, "dst_port": 443, "banner_hex": "485454502f312e31203230300d0a", "banner_len": 14}
|
||||||
|
{"timestamp": "2025-06-01T14:32:23.841203+00:00", "src_ip": "198.51.100.19", "src_port": 54312, "dst_port": 443, "banner_hex": "485454502f312e31203230300d0a", "banner_len": 14}
|
||||||
|
{"timestamp": "2025-06-01T14:32:31.841203+00:00", "src_ip": "198.51.100.20", "src_port": 54312, "dst_port": 443, "banner_hex": "485454502f312e31203230300d0a", "banner_len": 14}
|
||||||
Reference in new issue
Block a user