From 77c39586c80ad259a3ed5f8c012b1dc007d63d62 Mon Sep 17 00:00:00 2001 From: DAProgs Date: Sat, 3 Oct 2026 17:01:05 -0400 Subject: [PATCH] Update network-config.sh --- network-config.sh | 162 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 134 insertions(+), 28 deletions(-) diff --git a/network-config.sh b/network-config.sh index 45ae6f2..26bfe1f 100755 --- a/network-config.sh +++ b/network-config.sh @@ -2,7 +2,7 @@ INTERFACES_FILE="/etc/network/interfaces" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -LOG_FILE="var/log/portspoof.log" +LOG_FILE="$SCRIPT_DIR/portspoof.log" # SHA256 hash of the shell access password. # To change it: echo -n "yourpassword" | sha256sum @@ -88,15 +88,13 @@ arrow_menu() { # ── status box ──────────────────────────────────────────────────────────────── -show_status() { - clear - echo "" +status_box() { echo " ╔══════════════════════════════════════════════════════════════════════════╗" echo " ║ DAProgs HoneyPot Server. ║" echo " ╠══════════════════════════════════════════════════════════════════════════╣" echo " ║ Network Interface Status ║" echo " ╠══════════════════════════════════════════════════════════════════════════╣" - echo " ║ v0.10 ║" + echo " ║ v0.11 ║" local ifaces mapfile -t ifaces < <(get_interfaces) @@ -131,6 +129,12 @@ show_status() { fi echo " ╚══════════════════════════════════════════════════════════════════════════╝" +} + +show_status() { + clear + echo "" + status_box echo "" echo " Use ↑ ↓ to navigate, Enter to select, Ctrl+C to exit" echo "" @@ -403,6 +407,40 @@ shell_access() { read -rp "Press Enter to continue..." } +# ── log helpers ─────────────────────────────────────────────────────────────── +# Prints the last 5 log events (always exactly 5 lines): timestamp, src_ip, dst_port. + +log_last5() { + if [ ! -f "$LOG_FILE" ]; then + echo " (log file not found)" + return + fi + tail -n 5 "$LOG_FILE" | python3 -c ' +import sys, json +out = [] +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", "?")) + out.append(f" {ts:<34} {src:<18} {dst}") +while len(out) < 5: + out.append("") +print("\n".join(out)) +' +} + +log_columns() { + printf " %-34s %-18s%s\n" "Timestamp" "Source IP" "Destination Port" + printf " %s %s %s\n" "──────────────────────────────────" "──────────────────" "──────────────────" +} + # ── log viewer ──────────────────────────────────────────────────────────────── show_log_viewer() { @@ -416,27 +454,8 @@ show_log_viewer() { 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 + log_columns + log_last5 echo "" echo " Auto-refresh: 1s — press any key to return to the menu" if IFS= read -rsn1 -t 1 _; then @@ -448,6 +467,94 @@ for line in sys.stdin: trap - INT } +# ── main screen: status + menu + live log (1s refresh) ──────────────────────── +# Fixed geometry, measured up from the hint line at the bottom: +# 1 blank + 5 log data lines + 5 log header lines + 1 blank + $count menu lines + +main_screen() { + local -n _res="$1" + local cur=0 + local count=${#MENU_ITEMS[@]} + local key esc + + local status log_lines + status=$(status_box) + + print_menu_lines() { + local i + for (( i=0; i