Skip to content

Instantly share code, notes, and snippets.

@szabacsik
Last active October 15, 2021 19:50
Show Gist options
  • Save szabacsik/fed21a0fe908306bcc3ee559a2bd4002 to your computer and use it in GitHub Desktop.
Save szabacsik/fed21a0fe908306bcc3ee559a2bd4002 to your computer and use it in GitHub Desktop.
Network Tools

run a basic port scan

nc -z -v 192.168.100.100 80

Connection to 192.168.100.100 80 port [tcp/http] succeeded!

run a basic port scan on ports between numbers 1 and 1000

netcat -z -v 192.168.100.100 1-1000

netcat: connect to 192.168.100.100 port 21 (tcp) failed: Connection refused
Connection to 192.168.100.100 22 port [tcp/ssh] succeeded!
netcat: connect to 192.168.100.100 port 23 (tcp) failed: Connection refused

https://www.digitalocean.com/community/tutorials/how-to-use-netcat-to-establish-and-test-tcp-and-udp-connections-on-a-vps
https://www.varonis.com/blog/netcat-commands/

check which process is using port 2375 on windows

netstat -aon | findstr 2375

TCP 127.0.0.1:2375 0.0.0.0:0 LISTENING 12808
TCP [::1]:2375 [::]:0 LISTENING 12808

find the process name using the given port

tasklist | findstr 12808

com.docker.proxy.exe 12808 Console 1 20,448 K

https://dzone.com/articles/how-to-check-which-process-is-using-port-8080-or-a
https://geekflare.com/netstat-command-usage-on-windows/

ssh into wsl from local machine

root@wsl:/# apt-get remove openssh-server --purge
root@wsl:/# apt-get install openssh-server
root@wsl:/# nano /etc/ssh/sshd_config
ListenAddress 0.0.0.0
PasswordAuthentication yes
PS C:\> wsl hostname -I
172.29.92.16
C:\>ssh user@172.29.92.16

port reservation by the OS

netsh interface ipv4 show excludedportrange protocol=tcp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment