Skip to content

Instantly share code, notes, and snippets.

@ovntatar
Last active April 8, 2022 12:02
Show Gist options
  • Save ovntatar/d3b29b4e989a1e02e7c4ab43765829e0 to your computer and use it in GitHub Desktop.
Save ovntatar/d3b29b4e989a1e02e7c4ab43765829e0 to your computer and use it in GitHub Desktop.
Python one line access remote port
python -c "import socket; socket.setdefaulttimeout(2); print('Port is up √') if 0 == socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect_ex(('google.com',4413)) else print('Port is down †')"
@ovntatar
Copy link
Author

ovntatar commented Apr 8, 2022

timeout 1 bash -c 'cat < /dev/null > /dev/tcp/google.com/80'
echo $?

@ovntatar
Copy link
Author

ovntatar commented Apr 8, 2022

timeout 2 bash -c "</dev/tcp/canyouseeme.org/809"; echo $?

@ovntatar
Copy link
Author

ovntatar commented Apr 8, 2022

</dev/tcp/google.de/80 && echo Port open. || echo Port closed.

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