TL;dr

Bash Snippets

1
2
3
4
# quietly add a user without password
adduser --quiet --disabled-password --shell /bin/bash --home /home/newuser --gecos "User" newuser
# set password
echo "newuser:newpassword" | chpasswd
1
2
3
4
5
sudo pipinstall ngxtop

sudo yum install -y libpcap libpcap-devel
sudo yum install -y epel-release
sudo yum install -y nethogs nload
1
2
3
4
5
/usr/bin/ncat --listen -4 -vvv --keep-open --wait 50 --sh-exec "cat -n | tee -a ./out.txt" 8080
/usr/bin/ncat --listen -4 --verbose --keep-open --wait 50 --sh-exec "cat -n | tee -a ./out.txt" 9090

/usr/bin/nping -4 --verbose -c 1 -p 9090 localhost

1
2
3
4
python3 -c "import socket;print([(s.connect(('8.8.8.8', 53)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1])"

ip a |grep <ip> |awk '{print $NF}'
ip r |grep <ip> |cut -d " " -f 3

ref