Sign in to follow this  
Followers 0
Lemures

Quickly find open port?

11 posts in this topic

I'm currently working with a program (http://web.me.com/cwakamo/Connor_Wakamos_Software/Balance.html) that exports data by hosting it on iPhone. When you hit export, it hosts the raw data at http://<ip>:<port>/BalanceData.txt. I would like to write a program that I can run on my computer that grabs this data, parses it appropriately, and appends it to an excel spreadsheet. However, the ports are randomly assigned and are between 49152 and 65535. Any of the available open port scanners I can find on these forums take a good half a second minimum per port. This means it could take longer than two hours to find and grab the data, which is, of course, unacceptable. Are there any easier ways to do this?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I'm currently working with a program (http://web.me.com/cwakamo/Connor_Wakamos_Software/Balance.html) that exports data by hosting it on iPhone. When you hit export, it hosts the raw data at http://<ip>:<port>/BalanceData.txt. I would like to write a program that I can run on my computer that grabs this data, parses it appropriately, and appends it to an excel spreadsheet. However, the ports are randomly assigned and are between 49152 and 65535. Any of the available open port scanners I can find on these forums take a good half a second minimum per port. This means it could take longer than two hours to find and grab the data, which is, of course, unacceptable. Are there any easier ways to do this?

For $i = 49152 To 65535 Step 1
    If INetGet("http://123.123.122.123:" & $i & "/BalanceData.txt") Then ExitLoop
Next

MsgBox(0, "Port Number", "Port: " & $i)

Try the above and see if it accomplishes what you're looking for.

Edit01: This may take a while as well, but it will eventually get the job done. How long does it take for this text file to be deleted? I also assume this way you may get someone else's data? So you should be very careful.

Regards,

Jarvis

Edited by JSThePatriot

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

I've tried the INetGet command exactly as you've described, and it takes nearly a second per port. Way too long. I'll be the only one on the network, so I'm not worried about grabbing others' data. The easiest way, I think, is to scan for open ports. I'm considering just setting up a batch file with nmap, having it drop all of the open ports to a txt file, then reading in that txt file. *shrug*. Not sure yet. Everything is just too slow. Yes, I could manually type in the port, but I want this to be as automated as possible.

Share this post


Link to post
Share on other sites

Maybe you can use a multi-process approach? I.e. calling the InetGet as an parameter to the autoit exe. This would logically make the entire process take ~0.5 seconds.


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

I'm not certain if I want to run 16,000+ processes at the same time... :-\

Share this post


Link to post
Share on other sites

I'm not certain if I want to run 16,000+ processes at the same time... :-\

Ok, reasonable thought.

How long does a simple TCPConnect take?


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

Maybe something like this?

Opt ("TCPTIMEOUT", 50); 50ms timeout.  Virtually could be down to about 25 depending on network speed... ;)
TCPShutdown ()
For $i = 49152 To 65535 Step 1
    If TCPConnect ("123.123.122.123", $i) <> -1 Then ExitLoop
Next
MsgBox(0, "Port Number", "Port: " & $i)

Share this post


Link to post
Share on other sites

The TCPConnect also takes about half a second per, even with the timeout. Maybe I'm doing something wrong.

Oh well. I'm starting to think nmap is my only real option, I can get through the port range in a little over a minute if I get the settings right. Still, I'd rather do it in autoit.

Share this post


Link to post
Share on other sites

The TCPConnect also takes about half a second per, even with the timeout. Maybe I'm doing something wrong.

Oh well. I'm starting to think nmap is my only real option, I can get through the port range in a little over a minute if I get the settings right. Still, I'd rather do it in autoit.

nmap can be called over the command line, you could still do it in AutoIt. Have AutoIt control nmap, read the results of open ports, and only try those ports for your data.

Jarvis


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

nmap uses a whole different strategy. It scans ports on a fire and forget basis (I think), this means it can scan hundreds of ports at once, all going into a timeout while nmap is already working on trying to establish the next connection. Unfortunately, you can't do a number of things with AutoIt (because it was designed that way). One of them is threading, another is establishing only the first half of the TCP connection.

As for a solution, JSThePatriot is right on the money. : )

Edited by Manadar

Share this post


Link to post
Share on other sites

nmap uses a whole different strategy. It scans ports on a fire and forget basis (I think), this means it can scan hundreds of ports at once, all going into a timeout while nmap is already working on trying to establish the next connection. Unfortunately, you can't do a number of things with AutoIt (because it was designed that way). One of them is threading, another is establishing only the first half of the TCP connection.

As for a solution, JSThePatriot is right on the money. : )

Why thank you sir!

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
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
Sign in to follow this  
Followers 0