Sign in to follow this  
Followers 0
kjmarket

Remote connection with PC with a router

18 posts in this topic

I have a remote connection prog I've been working on and I want to be able to allow someone to connect to a PC that is using a router. As is it just tries to connect to the same port as the server is listening on. I was looking around and found a thread discussing how to find a port on a pc with a router, but i am not sure how to go about this. I have a friend who is helping me test the prog, and she has a router. Obviously, as is, I cannot connect to her PC and would like to know the steps to enable my prog to do so. If a person has three computers in the house using a router, how do you go about making a connection to a specific PC in the house...as an example. Connect to the router's IP, so to speak, then what? Sorry for the ignorance, and perhaps stupid question, but I've never dealt with routers before. I'm using the TCP functions, btw.


Pink Floyd - The Wall

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I have a remote connection prog I've been working on and I want to be able to allow someone to connect to a PC that is using a router. As is it just tries to connect to the same port as the server is listening on. I was looking around and found a thread discussing how to find a port on a pc with a router, but i am not sure how to go about this. I have a friend who is helping me test the prog, and she has a router. Obviously, as is, I cannot connect to her PC and would like to know the steps to enable my prog to do so. If a person has three computers in the house using a router, how do you go about making a connection to a specific PC in the house...as an example. Connect to the router's IP, so to speak, then what? Sorry for the ignorance, and perhaps stupid question, but I've never dealt with routers before. I'm using the TCP functions, btw.

If they are the client and you have the server, and the client is calling you and not vice versa, you shouldn't have an issue.

BTW, mentioning a female friend and talking about routing her ports... Are we sure you are in the right forum? :whistle:

Edit:

I noticed you were saying "Home" with computers... Had you tried @IPAdress*?

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

HAHA. What I was saying was her being the server, and my pc the client trying to connect to her.... Get your mind out of the gutter, there, Smoke! LOL.

I can connect fine if the other person ha sno router..what i want is for the prog to be abnle to connect to a PC witha router if they have one/

Edited by kjmarket

Pink Floyd - The Wall

Share this post


Link to post
Share on other sites

HAHA. What I was saying was her being the server, and my pc the client trying to connect to her.... Get your mind out of the gutter, there, Smoke! LOL.

I can connect fine if the other person ha sno router..what i want is for the prog to be abnle to connect to a PC witha router if they have one/

Ha, my mind stays in the gutter! :whistle:

As I was stating though, if you set the Server Script PC as Server, the client script PC's can contact that PC (the server) regardless of router.

If you are just looking to do it regardless if it's a server pc or a client, then Port Forwarding I'm sure is going to be involved, and with me just getting into TCP myself, I'm afraid that's a bit over my head.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Well, I do appreciate the advice and help. Maybe someone else will know more, and at least be able to point me in the right direction. I understand general port forwarding...if no port is forwarded, then they cant play games or anything...so Im assuming her port is already forwarded...I jsut dont know much about making a tcp connection to a forwarded port...

I feel like what Im wanting isnt what you guys are thinking so Im gonna try and say this one more time. I can connect if there is no router...but can it be coded in a way that it will connect if there is a router? How do you connect to a PC if it has a router?

Thanks, Smoke...I couldn't even type that first paragraph without laughing....

Meanwhile...time to rout her ports....

Edited by kjmarket

Pink Floyd - The Wall

Share this post


Link to post
Share on other sites

Crash course on internal/external connections:

You always connect to an external IP address. If this external IP address is bound to a computer network adapter (for instance the network adapter in a machine that is directly connected to a simple cable modem), the connection will arrive at the computer itself.

BUT in this case there is not a computer LAN adapter that has the external IP-address, but instead a router that has the external IP-address. All computers 'behind' that router received an INTERNAL ip-address from the router. Since TCP allows you to connect to <some ip-address> on <some port>, there is no way for the client (the one that attempts to connect from outside) to tell a router which INTERNAL ip-address to connect to.

So you need to tell the router for instance that when an incoming connection attempt is found on for instance port 5900 (which is used by VNC), it needs to be forwarded to INTERNAL address 192.168.0.100 for instance.

My own situation might show the concept better:

In my home I have a router with an external IP-address received from my ISP (in my case 24.132.xxx.xxx in the Dutch Chello cable network), and three or four computers (depending on whether or not I misplaced my laptop again :whistle:) that received an internal IP address from my router. These are in my case 192.168.0.100 to 192.168.0.103.

Now, when I'm in my office I want to use VNC to control my LAN server at home (which has internal IP-address 192.168.0.100). So I need my VNC viewer connect to my home, for which I need to use the EXTERNAL 24.132.xxx.xxx address, on some port I use for my VNC server (you can set it in VNC). I use 5999 for this to avoid automated exploit bots connecting to the default port of 5900. So my router gets an incoming connection on port 5999. But now my router has no idea which internal computer the incoming connection needs to reach. So I need to tell that to my router. So I tell my router to forward incoming connections on port 5999 to internal ip-address 192.168.0.100.

But now I also have a test mail server running in my home lan, which is on one of the other computers, and that listens on port 110 (POP3). When I need to remotely contact that pop-server, i ALSO need to connect to 24.132.xxx.xxx, BUT I need to go to another INTERNAL computer then. So I tell my router to forward incoming connections on port 110 to internal ip-address 192.168.0.101.

To go short: you just cannot tell a tcp connection that you start, which machine inside a remote network to access. You can ONLY tell it which external IP-address to connect to. The remote network needs to know which machines to forward which connections to. So you NEED router port forwarding for this. Normally you can set this for a normal, home-use router by going to the router ip-address (in my case: 192.168.0.1) in a browser, and then you can set your router settings.

Hope this long story explained a bit.


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Ok, I made a post then realized there was a reply after I submitted it.....

Thanks for the info. I understand the basics of it now, but still wonder, is there some way to connect to the external IP, then say find out which ports are open ( forwarded)? Like using the code from http://www.autoitscript.com/forum/index.ph...;hl=router+port and then detect which open port has the server listening? Or which ports belong to which PC's behind the router?

Edited by kjmarket

Pink Floyd - The Wall

Share this post


Link to post
Share on other sites

Ok, I made a post then realized there was a reply after I submitted it.....

Thanks for the info. I understand the basics of it now, but still wonder, is there some way to connect to the external IP, then say find out which ports are open ( forwarded)? Like using the code from http://www.autoitscript.com/forum/index.ph...;hl=router+port and then detect which open port has the server listening? Or which ports belong to which PC's behind the router?

Well you can connect to the external IP-address in question on different ports, and see what kind of error is returned (or wether none is returned and the connection is accepted). This is called a portscan. There are many tools that can be used and it is not that hard to make something yourself if you go into tcp transmissions a bit, and know what kind of response you expect from some open connection, and just going through a set of ports and wait if/when that response will come up.

IF you connected to the machine you want to through the port you want to, you can do whatever you want, provided that the server in question is programmed to be able to deliver the requested information.

There is a catch though: many network worms/viruses and hackers and bots etc. intended for malicious use, run portscans on random or semi-random IP-ranges to scan for open security leaks to abuse (so they use essentially the same concept you would like to use, or so it seems), and to catch that, many corporate networks and ISP's have implemented security against this, like blocking or blacklisting your IP-address after some number of failed attempts on different ports. Make sure that if you want to run such a portscan, you are not running into any automated anti-portscan security.


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

Interesting. Thanks for th einfo, man. Guess its not really a good idea.


Pink Floyd - The Wall

Share this post


Link to post
Share on other sites

An the answer is Port forwarding.

In the router tou have to grand all ip's to get into the port and redirect that port to the right workstation.

Ex:

All ip addresses grant comm to 80 port.

All 80 port comm goes to workstation1 (192.168.xxx.xxx)

Cheers


Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites

An the answer is Port forwarding.

In the router tou have to grand all ip's to get into the port and redirect that port to the right workstation.

Ex:

All ip addresses grant comm to 80 port.

All 80 port comm goes to workstation1 (192.168.xxx.xxx)

Cheers

If you want the full, extended version of this explanation, read my previous two posts in this thread about port forwarding and port scanning... :whistle:


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

If you want the full, extended version of this explanation, read my previous two posts in this thread about port forwarding and port scanning... :whistle:

How can you port scan when the router dont know where to go and deliver the package?

Even with port scan the router has to know where to deliver what!

Just a wild guess :P

LOL

Cheers m8


Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites

How can you port scan when the router dont know where to go and deliver the package?

Even with port scan the router has to know where to deliver what!

Just a wild guess :D

LOL

Cheers m8

You can portscan routers by portscanning the public IP that they use. If the router has been told to block (almost) everything like most default setups, the portscan will just fail miserably (if the router is protected well enough that is). But if the router has been set to forward some ports your portscan will have more result if one of the internal IP-addresses to which the port is forwarded returns something that you expect. BUT if you were a automated exploit-searching bot looking for instance for open VNC, IRC, MSN, FTP, whatever kind of server to use as a unintentional kiddieporn/illegal software download relay or DDOS attack base or anything, you could scan a router on often-used ports for those servers and cross your fingers and hope that you happen to find a victim that was stupid enough to have it router forward ports to internal machines without protecting the internal machines then.

But ofcourse you cannot portscan a machine inside a remote network when the router doesn't forward the scanned ports (if you rule out any holes in the router security :P). That was what I was also trying to explain. I think we mean the same thing :whistle:


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

You can portscan routers by portscanning the public IP that they use. If the router has been told to block (almost) everything like most default setups, the portscan will just fail miserably (if the router is protected well enough that is). But if the router has been set to forward some ports your portscan will have more result if one of the internal IP-addresses to which the port is forwarded returns something that you expect. BUT if you were a automated exploit-searching bot looking for instance for open VNC, IRC, MSN, FTP, whatever kind of server to use as a unintentional kiddieporn/illegal software download relay or DDOS attack base or anything, you could scan a router on often-used ports for those servers and cross your fingers and hope that you happen to find a victim that was stupid enough to have it router forward ports to internal machines without protecting the internal machines then.

But ofcourse you cannot portscan a machine inside a remote network when the router doesn't forward the scanned ports (if you rule out any holes in the router security :P). That was what I was also trying to explain. I think we mean the same thing :whistle:

Yeap :lmao:

Indeed the say thing... :D

Cheers


Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites

Ha, my mind stays in the gutter! :whistle:

...

Stick to pool - don't take up bowling. :-)

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Stick to pool - don't take up bowling. :-)

218 league average ... Non-Handicap for bowling :whistle:

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

218 league average ... Non-Handicap for bowling :whistle:

i always wondered why hacking was so popular.. theres tons of ports to play with. one of them is sure to let you in..


Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

ya'll IT people have your noses so far up your computers .........ports. eehheheh that ya'll don't see anything else. :whistle:

You're just mad were not talking about your ports... :P

And what are you doing out of chat?! GET IN THE BOX!

Lord what am i doing...

Edited by D-Generation X

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