Skip to content

Instantly share code, notes, and snippets.

@liejuntao001
Created December 16, 2019 06:23
Show Gist options
  • Save liejuntao001/6d82534b6c02807f3d7e822c97c53778 to your computer and use it in GitHub Desktop.
Save liejuntao001/6d82534b6c02807f3d7e822c97c53778 to your computer and use it in GitHub Desktop.
Server side
# /etc/knockd.conf
[options]
UseSyslog
[openSSH]
sequence = 3000,4000,5000,6000
seq_timeout = 15
command = /sbin/iptables -I INPUT 1 -s %IP% -p tcp --dport 22 -j ACCEPT
tcpflags = syn
cmd_timeout = 10
stop_command = /sbin/iptables -D INPUT -s %IP% -p tcp --dport 22 -j ACCEPT
Client side
# Direct network access, knock
knock -v server_ip_address 3000 4000 5000 6000
# Direct network access, nmap
for x in 3000 4000 5000 6000; do nmap -n -Pn --host-timeout 1s --max-retries 0 -p $x server_ip_address; done
# Connect via a squid proxy, nc
for x in 3000 4000 5000 6000; do nc -x 127.0.0.1:3128 -X connect -w 1 server_ip_address $x; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment