Skip to content

Instantly share code, notes, and snippets.

@kizzx2
Last active November 14, 2023 03:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kizzx2/25caaa5c6582bf63627271df804cbb8e to your computer and use it in GitHub Desktop.
Save kizzx2/25caaa5c6582bf63627271df804cbb8e to your computer and use it in GitHub Desktop.
Bash one line port scanner using nc
# Creates 993 nc processes. Returns in about 1 minute max
ip=127.0.0.1
b(){ for i in {0..992};do nc $ip -w1 -vz $((i*66+1))-$((i*66+66>65535?65535:i*66+66)) 2>&1|egrep 'open|succeed'&done;wait;} 2>/dev/null;b
@kizzx2
Copy link
Author

kizzx2 commented Nov 14, 2023

Caveats:

  • 1 second timeout, if a legitimate port takes >1s to return leads to false negative
  • 1000 nc processes created, you can tweak 992 and 66 above to wait longer with less processes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment