Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Querying program port

by CougarXR7 (Acolyte)
on Aug 09, 2019 at 22:05 UTC ( #11104238=perlquestion: print w/replies, xml ) Need Help??

CougarXR7 has asked for the wisdom of the Perl Monks concerning the following question:

I have 2 PCs, my main (OS: Win10) will run a program.

While the program is running on my main PC, my 2nd PC, (with the Ubuntu OS) will run a Query terminal.

I need a script to do the following, (IP and starting port shown are examples):

The script runs 12.345.67.890:25000 querying that program.

That IP and Port gets entered followed by \status\ .

Once those 2 inputs are done and there is no return/reply from that program, then it does this.

Same ip address but this time the port "inc +1".


It keeps doing that port "inc" until there is a return/reply from the program.

Once the program has sent a return/reply, that script stops, leaving that information on screen in Terminal.

Is this even possible to do?

I need this script! I hope it can be done!

If need be, I would gladly pay someone for this!


Replies are listed 'Best First'.
Re: Querying program port
by jcb (Parson) on Aug 11, 2019 at 00:39 UTC

    This is very possible, and I could probably adapt some code from one of my (currently untested) hobby projects for this, but first I have some questions:

    • What, exactly, is the purpose of this program you ask of the Monastery?

      Are you trying to determine which "random" port a known program has chosen for a particular session? What program are we trying to extract information from? If this is a protocol that several programs use, does it have a name? What is at least one program using this?

      Why is there not some directory we can query for these ephemeral servers? Why do we have to search like this?

    • What, exactly, do you need done?

      Does this need to send a string "$addr:$port status\n" to multiple ports until one answers? Do we expect all other ports to be closed entirely? Is this using TCP or UDP or something else? Are they all on the same host or are we gathering status information from some kind of cluster? Or is a single host "fronting" for some kind of cluster?

    This sounds very much like a common system cracker tool, although there are legitimate uses for this type of functionality as well. I want to be sure that you have a legitimate use before I even think about giving you code for this.

    Answering all of these questions will go a long way towards establishing your legitimacy. Having worked in systems administration at a small Internet-dependent business, where kicking script kiddies out of the aging PHP-heavy infrastructure that management did not want to upgrade was a large part of my job, I have no desire to help that kind of nonsense along.

      My friend is a game server admin. He is trying to get player stats from his game server, "Deaths, Kills, ect., ect..., but cannot because the ports he has tried does not query his game server.

      All I am trying to do is help my friend discover which port will return his game's server player stats.

      Protocol is UDP

      example: 12.345.67.890:25000

      Ip Address:port /enter

      \status\ enter

      Returned reply, YES, exit script, log return player stats

      Returned reply, NO, continue with script

      ip address stays the same. The port inc by 1

      now its 12.345.67.890:25001/enter

      \status\ enter

      Script keeps running until there is a return. With printing info on terminal, to make sure script is still running.

      Sir, I have no idea what "kiddie scripts or even PHP is about, You lost me at kiddie scripts!

      If I failed to answer you, please let me know!

      I have a dislike for hackers, they can ruin it for everyone!

        Has your friend tried the netstat command, probably as netstat -a to check listening ports, to confirm that the game server is listening at all? (Run that on the same machine as the server.) It has been a long time since I have used Windows, so you may want to check the output of netstat /? or netstat -? for other hints on using that command.

        Your descriptions sound suspiciously like a series of keystrokes entered at some prompt. What are you typing those keystrokes into? The best solution here may involve Expect rather than Perl if you are trying to automate interacting with a simple shell program. Perl will work much better if you are wanting to actually send network packets directly.

Re: Querying program port
by stevieb (Canon) on Aug 09, 2019 at 22:27 UTC
    "If need be, I would gladly pay someone for this!"

    It can definitely be done. Although this is a good place to get information, you'd want to go over to the Perl Jobs site to post a job/contract position.

    I think though, that if you can provide more information and details, we might be able to help you here. For example, can you show us the actual data you're using?

      What more information needed? I have no more code or details.

      It's simple really, the script keeps running with the same ip yet the port keeps "inc+1" after each run. Until the program response/replies.

      The script stops once a response/reply is received.

      Any more information concerning this, ask.

      If I need to pay someone, how much should I pay for this script?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://11104238]
Approved by Athanasius
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2021-04-18 00:16 GMT
Find Nodes?
    Voting Booth?

    No recent polls found