Jump to content

Any way to get source TCP port


Recommended Posts

Hey everyone,

I can't figure out a way to get the source TCP port of a connection. Here's the order of operations that I MUST follow due to interaction with another software:

1. Open connection (Source opens on a random high TCP port)

2. Send client name and class

3. Close socket so a FIN,ACK is generated

4. Open a listening socket on the same source port as the original socket

5. Receive information on connection

The server only sends its information if the socket is closed so it sees a FIN, ACK TCP sequence. I tried using TCPRecv after TCPSend, but that sends a RST, not a FIN, so it won't work. So how can I get the TCP source port that my original socket was sending on?

Thanks for any help. This one has me stuck.

Edited by skreien
Link to comment
Share on other sites

I only can offer you this, because i don`t have any idea about that.

A link to an UDF this will help you... and if i was you i will the search in other places like this MSDN Search there a lot of exaples in other languajes, and you have a lot of useful info.

Edited by monoscout999
Link to comment
Share on other sites

I'm not finding much of anything that (at the risk of sounding lazy) I can use without a whole lot of work. I really don't want to re-engineer a new tcpsend.

I had thought about parsing the output from netstat to find the port number, but that seems awfully heavy and unreliable.

Link to comment
Share on other sites

Thanks for the info monoscout999. I found something else that gave me what I was looking for but I don't think it's going to help.

I did find this link to that I tried, and it's giving me the correct port. However, the TCPReceive isn't working because the information that's coming back from the server really isn't on a new connection like what I'm expecting in AutoIt. Here's the sequence:

SYN

SYN ACK

ACK

send my client data now

FIN ACK

ACK

server sends data back

FIN ACK

Anyone know how I can match this cadence with AutoIt and receive the data? I've been playing with it for over a week, I still am stumped. Maybe it's not possible.

Edited by skreien
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...