Live data from Hacker News

Testing if a port can be reached, using built-in tools other than ol' telnet

carehart.org

31–40 of 87 posts

Re: Testing if a port can be reached, using built-in tools other than ol' telnet

#31
post #16

I sometimes wonder why we still use port numbers. Wouldn't it make much more sense to use strings to name ports?

There are some attempts at doing that, such as https://en.m.wikipedia.org/wiki/SRV_record and https://datatracker.ietf.org/doc/draft-ietf-dnsop-svcb-https...

I wish SRV records were more widely adopted, but they are still just a (string -> integer) mapping process above the 16-bit integer values on the wire. Different layers.

Re: Testing if a port can be reached, using built-in tools other than ol' telnet

#32
post #2

Not sure if I'd like to send anything into tested port just to tell if it is open. I'd rather stick with telnet or whatever is available. Also worth mentioning that bash also has network capabilities, you can check port like this: :

> Not sure if I'd like to send anything into tested port just to tell if it is open.

can you elaborate? From a stealth perspective, probing for a port will always reveal to the other side that they are being probed

Re: Testing if a port can be reached, using built-in tools other than ol' telnet

#33

I’ve never used ‘curl host:port’ but use ‘curl -v telnet://host:port’ all the time on Linux boxes that don’t happen to have telnet installed. Perhaps he omits the telnet on the curl because I believe the windows curl doesn’t support it..

Most developers will have git and git bash installed nowadays which support standard cURL (along with all the basic useful bash utilities (sed, find, grep, tr, sort, uniq, etc.) We’ve given up on writing anything windows specific at work as the format and options are pretty limited. The most we will do is call setx or similar if we need to setup a user environment variable in our scripts. It has saved so much of our sanity and time as bash scripts are so much easier to write and maintain.

Re: Testing if a port can be reached, using built-in tools other than ol' telnet

#34
post #32
post #2

Not sure if I'd like to send anything into tested port just to tell if it is open. I'd rather stick with telnet or whatever is available. Also worth mentioning that bash also has network capabilities, you can check port like this: :

> Not sure if I'd like to send anything into tested port just to tell if it is open. can you elaborate? From a stealth perspective, probing for a port will always reveal to the other side that they are being probed

Could crash the server if it's badly written

Re: Testing if a port can be reached, using built-in tools other than ol' telnet

#36

Ha! This was probably the first serious problem I ever tackled with an open source contribution! The year was 2002, the 2.4 Linux kernel had just been released and I was making money on the side building monitoring software for a few thousand (mostly Solaris) hosts owned by a large German car manufacturer. Everything was built in parallel ksh code, “deployed” to Solaris 8 on Sun E10Ks, and mostly kicked off by cron.…

Awesome, I think I had the same book in 1990s. Things were so simple back then, when the default approach to anything was to start writing some C code with socket calls.

Re: Testing if a port can be reached, using built-in tools other than ol' telnet

#37
post #29

Earlier quoted context omitted.

The reason this hasn't been done is that it would require changes to the headers of TCP and UDP, which would be a massive undertaking (for similar reasons to why IPv4 -> IPv6 is such a pain). Would both the source and destination ports both be strings? Normally, for a client->server packet, the source port is meaningless, so what string would you use? Or would your new protocol support both string ports and integer p…

Couldn't the port string be mapped to a temporary port number when the TCP connection is initiated? It'd still be necessary for UDP though. It'd still be a massive undertaking though.

Yes, and there's already mechanisms for doing just that - look up DNS SRV records: https://en.m.wikipedia.org/wiki/SRV_record

Re: Testing if a port can be reached, using built-in tools other than ol' telnet

#38
post #2

Not sure if I'd like to send anything into tested port just to tell if it is open. I'd rather stick with telnet or whatever is available. Also worth mentioning that bash also has network capabilities, you can check port like this: :

This is what I was trying to remember, I've seen this before but never understood it. What does the colon do?

: is a special built-in that always succeeds and always returns an exit of 0. You typically use it when you need a command for syntax reasons, but don't actually need/want to run a command.

Re: Testing if a port can be reached, using built-in tools other than ol' telnet

#40
post #2

Not sure if I'd like to send anything into tested port just to tell if it is open. I'd rather stick with telnet or whatever is available. Also worth mentioning that bash also has network capabilities, you can check port like this: :

This is what I was trying to remember, I've seen this before but never understood it. What does the colon do?

it's equivalent to 'true'. It returns a successful value
Post reply on HN