Jump to content

When Sending a UDP Message, using UDPOpen() and UDPSend(), can I get the Source Port that was Used?


Recommended Posts

Posted (edited)

Hi all

I am sending a UDP Message using UDPOpen() and UDPSend().

I am specifying the Target_IP and Target_Port,
and would like to ask if AutoIt somehow enables me to get the Source_Port that was used for sending that UDP Message.

Thank you

Edited by Zohar
Posted
7 hours ago, Zohar said:

Hi all

I am sending a UDP Message using UDPOpen() and UDPSend().

I am specifying the Target_IP and Target_Port,
and would like to ask if AutoIt somehow enables me to get the Source_Port that was used for sending that UDP Message.

Thank you

As per what Nine has said.  It returns IP and Port in the array. Note that the port used to send is a dynamic port selected at random from the ephemeral (dynamic) port range as dictated by the sending PC.

The Ephemeral port range On Windows (using netsh)

  1. View current range: netsh int ipv4 show dynamicportrange tcp.
  2. Or netsh int ipv4 show dynamicportrange udp
  3. Set range (persistent after reboot): netsh int ipv4 set dynamicport tcp start=1025 num=64510 (sets range 1025-65535).
  4. Or netsh int ipv4 set dynamicport udp start=1025 num=64510 (sets range 1025-65535)
  5. Apply changes: A reboot is often required for persistence.
  6. Troubleshooting: Restarting the winnat service (net stop winnat then net start winnat) can sometimes free up port

Ephemeral (dynamic) ports exist to allow multiple simultaneous outbound connections so that a single outbound port is not blocked up and used single file. Widening the range prevents port exhaustion. Note: 1025-65535 is the widest range possible.

More info here: https://learn.microsoft.com/en-us/troubleshoot/windows-client/networking/tcp-ip-port-exhaustion-troubleshooting

Posted
5 minutes ago, Nine said:

Is that an AI answer ?  Looks like it as it does not provide useful information for AutoIt programmers.

There must be a reason Zohar is asking to find the outbound UDP port and it will be related to networking, not isolated AutoIT use.  I doubt it is for idle curiosity, so I thought I would add a context.

If you are referring to my answer, no, it is my answer, but with some text from Google, to avoid typing it out long hand.  Actually I am an AutoIT programmer, and have written dozens of Autoit exes to both detect and alter ranges, and track ip and port use in general, as part of an MSP application, and also trying to solve other engineers issues, such as slow bulk mail sending because of port exhaustion.

And I also make use of that data for programming Cisco IOS routers and creating of Dynamic Firewalling on said routers.

Autoit is also very useful for programmatically setting Windows firewall rules, as well as creating and using syslog and a whole bunch of other process, all created with AutoIT.

And I use daily a program originally written by trancexx - NETWORK CONNECTIONS VIEWER, to look at outbound TCP and UDP connections.  I took that code and rewrote for internal use.

Posted (edited)
24 minutes ago, Nine said:

Ok your last answer is not coming from any AI.  But I still believe the previous one is from AI.  Anyhow not that I disgrace using AI, but I still trust HI to be better.  Have a good night ;)

I do not use AI per se. 🙂 The answer was from Google (which seems to use AI, and thus unavoidable), which agreed with my understanding, so copied and edited by me, simply to avoid me digging out all my notes.  I have a very Dim view of AI, and blog accordingly, and outspoken on other forums.

Over the last 15 years I found searching google quicker to find answers about AutoIT and users solutions for AutoIT, but am becoming frequently disturbed by Google AI trying to be an expert at everything. I've always done my own research. I don't trust AI one bit. 

I work in Cyber security so even Cloud, the source of most hacks, is off limits where ever possible.  AutoIT is a god-send in being able to maintain off-Cloud resources for clients.

 

 

 

Edited by Festerini

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...