From 7619ff9030c3c2ffbe6302f97b54955680b26321 Mon Sep 17 00:00:00 2001 From: DAProgs Date: Sat, 3 Oct 2026 15:41:38 -0400 Subject: [PATCH] 2610.1 adding logfile --- network-config.sh | 62 +++++++++++++++++++++++++++++++++++++++++++---- portspoof.log | 11 +++++++++ 2 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 portspoof.log diff --git a/network-config.sh b/network-config.sh index bff2302..e403486 100755 --- a/network-config.sh +++ b/network-config.sh @@ -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 diff --git a/portspoof.log b/portspoof.log new file mode 100644 index 0000000..e51ff5b --- /dev/null +++ b/portspoof.log @@ -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}