How to determine whether client and server are on the same host

Chris Angelico rosuav at gmail.com
Tue Nov 26 07:26:26 EST 2013


On Tue, Nov 26, 2013 at 11:13 PM, Malte Forkel <malte.forkel at berlin.de> wrote:
> That is a clever idea. While I can't modify the server, I could look at
> the files on the host running the application and try to determine if
> they fit to information from the server about its files. If both match,
> I could then conclude that application host and server host probably are
> the same. But, I still couldn't be sure.

If you deliberately create a file with a random name, the chances of
one existing with the same name on the client are infinitesimal unless
someone's deliberately trying to confuse things... in which case I
wouldn't worry about it.

> Isn't there anything in telnetlib that can differentiate between a local
> connection and a remote connection?

No, because there's no such thing as a "local connection". For
instance, I have two internet connections at my house, and I can
telnet out on one of them and back in on the other - but both
connections are NATted, so the machine itself doesn't have an IP that
matches what I'm talking about here. I could have a socket connection
from w.x.y.z port 12345 to a.b.c.d port 80, and there's no way
telnetlib would recognize that as coming back to the same computer,
because this computer's IP addresses are all RFC 1918 ones (127.0.0.1,
192.168.0.19, 192.168.2.2).

> Or may be some unique property of
> each host that I could use?

That's what I was intending the file to be. You could also look for
some kind of signature, like the MAC address of the first network
interface, but that's going to be no more reliable and potentially a
lot harder to recognize.

ChrisA



More information about the Python-list mailing list