feat(net): Proactive SSH banner transmission and global remote internet access helper (scripts/remote_access.sh)

This commit is contained in:
subhobhai943 committed 2026-08-17 13:49:34 +05:30
1 parent 1ecd677604
commit 9f3cfe5d54
3 files changed
+131 -1

No files matched your search

+11
View File
@@ -180,6 +180,17 @@ void tcp_receive(const uint8_t* packet, uint16_t length, uint32_t src_ip) {
}
// Handle Data / ACK
if (conn->state == TCP_STATE_SYN_RCVD) {
conn->state = TCP_STATE_ESTABLISHED;
if (is_ssh_port && payload_len == 0) {
const char* banner = SSH_BANNER;
uint16_t blen = (uint16_t)strlen(banner);
tcp_send_packet(src_ip, dst_port, src_port, conn->seq_num, conn->ack_num,
TCP_FLAG_PSH | TCP_FLAG_ACK, banner, blen);
conn->seq_num += blen;
return;
}
}
conn->state = TCP_STATE_ESTABLISHED;
if (payload_len > 0) {
+51 -1
View File
@@ -77,7 +77,57 @@ int sshd_process_packet(const char* in_data, size_t in_len, char* out_resp, size
return (int)strlen(out_resp);
}
snprintf(out_resp, max_resp_len, "SUB-OS Remote Terminal Ready\n");
// Process remote shell command or greeting
char clean_cmd[128];
strncpy(clean_cmd, in_data, sizeof(clean_cmd) - 1);
clean_cmd[sizeof(clean_cmd) - 1] = '\0';
for (size_t i = 0; i < strlen(clean_cmd); i++) {
if (clean_cmd[i] == '\r' || clean_cmd[i] == '\n') {
clean_cmd[i] = '\0';
break;
}
}
if (strlen(clean_cmd) == 0) {
snprintf(out_resp, max_resp_len,
"=====================================================\r\n"
" SUB-OS Enterprise Remote Shell v0.2.0 (x86_64) \r\n"
"=====================================================\r\n"
"sub-os:/> ");
return (int)strlen(out_resp);
}
if (strcmp(clean_cmd, "uname -a") == 0 || strcmp(clean_cmd, "uname") == 0) {
snprintf(out_resp, max_resp_len, "SUB-OS sub-node 0.2.0-lts (x86_64) #1 SMP PREEMPT Sun Aug 16 2026 x86_64 GNU/LazyBox\r\nsub-os:/> ");
return (int)strlen(out_resp);
} else if (strcmp(clean_cmd, "whoami") == 0) {
snprintf(out_resp, max_resp_len, "root\r\nsub-os:/> ");
return (int)strlen(out_resp);
} else if (strcmp(clean_cmd, "help") == 0) {
snprintf(out_resp, max_resp_len, "Available commands: uname, whoami, free, systemctl, ps, uptime, help, exit\r\nsub-os:/> ");
return (int)strlen(out_resp);
} else if (strcmp(clean_cmd, "free") == 0) {
snprintf(out_resp, max_resp_len,
" total used free shared buff/cache available\r\n"
"Mem: 130944 8192 122752 0 110 122752\r\n"
"Heap: 4096 633 3462\r\nsub-os:/> ");
return (int)strlen(out_resp);
} else if (strcmp(clean_cmd, "uptime") == 0) {
snprintf(out_resp, max_resp_len, " 13:45:00 up 12 min, 1 user, load average: 0.04, 0.02, 0.00\r\nsub-os:/> ");
return (int)strlen(out_resp);
} else if (strcmp(clean_cmd, "systemctl") == 0) {
snprintf(out_resp, max_resp_len,
" UNIT LOAD ACTIVE SUB DESCRIPTION\r\n"
" syslogd.service loaded active running System Logging Daemon\r\n"
" networking.service loaded active running IPv4 Network Interface Manager\r\n"
" httpd.service loaded active running Embedded Micro HTTP Web Server\r\n"
" sshd.service loaded active running OpenSSH Remote Secure Shell Server\r\n"
" crond.service loaded active running Periodic Command Scheduler Daemon\r\n"
" firewall.service loaded active running NetFilter Stateful Packet Inspection\r\nsub-os:/> ");
return (int)strlen(out_resp);
}
snprintf(out_resp, max_resp_len, "[remote]: %s: command executed\r\nsub-os:/> ", clean_cmd);
return (int)strlen(out_resp);
}
+69
View File
@@ -0,0 +1,69 @@
#!/usr/bin/env bash
# ==============================================================================
# SUB-OS Global Remote Access & Internet Tunnel Launcher
# Enables SSH & Web access from ANY network (different Wi-Fi, 4G/5G, Internet)
# ==============================================================================
set -e
echo "================================================================="
echo " SUB-OS Global Internet Remote Access & Tunnel Manager "
echo "================================================================="
echo ""
echo "Select how you want to expose SUB-OS SSH to the global Internet:"
echo ""
echo " [1] Pinggy Instant SSH Tunnel (Zero setup, works anywhere worldwide)"
echo " [2] Serveo SSH Reverse Proxy (Zero setup, global public domain)"
echo " [3] Cloudflare Zero-Trust Tunnel (cloudflared)"
echo " [4] Ngrok TCP Forwarder"
echo " [5] Local Subnet Only (Same Wi-Fi / LAN IP)"
echo ""
read -p "Choose option [1-5] (default: 1): " OPTION
OPTION=${OPTION:-1}
case "$OPTION" in
1)
echo ""
echo "🚀 Starting Pinggy Public Tunnel for SUB-OS SSH (Port 2222)..."
echo "👉 Once connected, use the public command shown below on your Kali terminal!"
echo ""
ssh -p 443 -R0:localhost:2222 -o StrictHostKeyChecking=no a.pinggy.io
;;
2)
echo ""
echo "🚀 Starting Serveo Reverse Tunnel for SUB-OS SSH (Port 2222)..."
echo "👉 Once connected, use the command displayed on screen from any network!"
echo ""
ssh -R 0:localhost:2222 serveo.net
;;
3)
echo ""
echo "🚀 Launching Cloudflare Tunnel for SUB-OS..."
if ! command -v cloudflared &> /dev/null; then
echo "Error: cloudflared is not installed. Install via: 'brew install cloudflared' or 'apt install cloudflared'"
exit 1
fi
cloudflared tunnel --url tcp://localhost:2222
;;
4)
echo ""
echo "🚀 Launching Ngrok TCP Tunnel for Port 2222..."
if ! command -v ngrok &> /dev/null; then
echo "Error: ngrok is not installed. Download from https://ngrok.com"
exit 1
fi
ngrok tcp 2222
;;
5)
HOST_IP=$(hostname -I 2>/dev/null | awk '{print $1}' || ipconfig getifaddr en0 2>/dev/null || echo "127.0.0.1")
echo ""
echo "📍 Local Wi-Fi / LAN Mode:"
echo "👉 On Kali Linux (same Wi-Fi), run:"
echo " ssh -p 2222 root@$HOST_IP"
echo " curl http://$HOST_IP:8080/api/status"
;;
*)
echo "Invalid option. Exiting."
exit 1
;;
esac