http://www.perlmonks.org?node_id=11104302


in reply to Re^6: Querying program port
in thread Querying program port

Well, 333networks.com resolves to 54.236.6.225 here, but I get no responses, not even to ping, from that address. I have tried connecting with TCP to port 27900 with no response to the connection attempt. I have tried sending UDP packets with both "status\n" and "status\r\n" with no response, not even an ICMP error.

Of course I have all the terminals I want here... but if that server refuses to talk to me, that is a bit of a problem... wait a minute...

You keep putting backslashes around "status"... (echo -ne '\status\'; sleep 1) | socat STDIO UDP4:333networks.com:27900 produces

\gamename\333networks\gamever\MS-perl 2.4.3\location\0\queryid\41.1\ho +stname\master.errorist.tk (The Errorist Network Master Server)\hostpo +rt\28900\gametype\MasterServer\mapname\333networks\numplayers\14\maxp +layers\2965\gamemode\openplaying\queryid\41.2\mutators\333networks sy +nchronization, UCC Master applet synchronization, Server Status Check +er\AdminName\Syntax-Error\AdminEMail\syntax@errorist.tk\queryid\41.3\ +final\

It is using UDP. And the first thing you need to study is "quoting".

The server is firewalled: an incorrect packet or a packet sent to the wrong port elicits no response at all, while '\status\' sent to the correct port produces that response. I have a bone to pick with whomever designed that atrocity of a protocol, but I think I can make a simple "shotgun query" tool. As a proof of concept, here is a simple solution at the shell:

(for port in `seq 27895 1 27905`; do (echo -ne '\status\'; sleep 1) | socat STDIO UDP4:333networks.com:${port} & done; sleep 1; echo '')

Paste that into a terminal and observe the results. That one does not tell you which port responded, only the response that was received, but the returned "hostport" happens to be 1000 higher than the port that produces the response. Writing this in Perl will be a fun exercise.

Note that I am deliberately designing this in a way that will set off alarms and get you caught if you try to use it as a system cracking tool.

2019-08-12 Athanasius fixed long line.

2019-08-12 jcb concurs with this edit to his node and thanks Athanasius. Let us see if I remember how to fix this the next time I need it...

Replies are listed 'Best First'.
Re^8: Querying program port
by CougarXR7 (Acolyte) on Aug 12, 2019 at 01:10 UTC
    Sir, I am no hacker/cracker/internet punk!

    I pasted in terminal, (for port in `seq 27895 1 27905`; do (echo -ne '\status\'; sleep 1) | socat STDIO UDP4:333networks.com:${port} & done; sleep 1; echo '') , it returned nothing.

    In my previous post I told you it was TCP. Jetfighter game port 8181 is UDP, I tried it first, no response, tried TCP port 8182 and got a response.
    Pasting this, nc 333networks.com 27900 -u into a terminal, enter, followed by \status\ , enter
    should of gave you a return/reply. Since it was a UDP port, my bad I am learning this as I go.
    You have a pm.

      Apologies, but we have had such unsavory characters seek to abuse the Monastery in the past, and your initial request seemed somewhat fishy. You were making a round-about request for a "port scanner", which can have legitimate uses like yours, but is also a well-known cracker tool. Later interactions have cleared up my suspicions.

      The command you gave uses netcat to exchange UDP packets (the -u selects UDP) with port 27900 on 333networks.com. I have socat installed, which is a similar, but somewhat more advanced (and complex) program. It is possible there may be some portability issues between our shells or other system weirdness. The Perl version should have solved that problem.