By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,993 Members | 1,947 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,993 IT Pros & Developers. It's quick & easy.

local interpreter remote machines

P: n/a
This may not be possible, but I thought I'd ask anyway. Could I get the
below code to run on a Python server where other machines would connect
to it (say thru the Web) and get details of *their* system instead of
the system details of the machine that the interpreter is running on?
Any ideas?

Thanks!!!

import os
import socket

x = os.uname()
y = socket.gethostbyaddr(x[1])
print
print "This is the connecting machine's os:", x[0]
print "This is the connecting machine's os version:", x[2]
print "This is the connecting machine's IP address:", y[2]
print

Jul 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
hokieghal99 <ho********@hotmail.com> writes:
This may not be possible, but I thought I'd ask anyway. Could I get
the below code to run on a Python server where other machines would
connect to it (say thru the Web) and get details of *their* system
instead of the system details of the machine that the interpreter is
running on? Any ideas?


In general, what you're asking for is called OS fingerprinting. It's
an active topic in security research. Figuring out a remote system's
OS is the first step towards breaking into it, so there's a slow but
growing effort among OS implementers to thwart attempts at
fingerprinting.

In simple cases, though, you can do stuff like connect to the remote
IP address's port 80 and see if you can get any HTTP server headers to
examine, and stuff like that.

OS's also leave inadvertent fingerprints, like the "randomly
generated" TCP sequence numbers which have detectable statistical
patterns on some systems. If you can detect such a pattern, that
often lets you identify the remote OS.
Jul 18 '05 #2

P: n/a
hokieghal99 wrote:
This may not be possible, but I thought I'd ask anyway. Could I get the
below code to run on a Python server where other machines would connect
to it (say thru the Web) and get details of *their* system instead of
the system details of the machine that the interpreter is running on?
Any ideas?


If you also have Python running on the other machine,
you can do this very easily with Pyro: http://pyro.sourceforge.net
(no network programming necessary at all).

Essentially you create an object on the remote machine that contains
a method with the code you want to execute, and you call that object
-using Pyro- as if it was located on your own computer.

But this only works if you have a supported Python version running
on the remote machine, and that you are allowed to connect to that
machine over the network.

You can even create some python code on your local machine, and
actually submit that to the other machine, let it deal with it,
and then get the results back.
But only do this if you know that no unauthorised user can do this,
because this is a security risk.

--Irmen de Jong.
Jul 18 '05 #3

P: n/a
Irmen de Jong wrote:
hokieghal99 wrote:
This may not be possible, but I thought I'd ask anyway. Could I get
the below code to run on a Python server where other machines would
connect to it (say thru the Web) and get details of *their* system
instead of the system details of the machine that the interpreter is
running on? Any ideas?

If you also have Python running on the other machine,
you can do this very easily with Pyro: http://pyro.sourceforge.net
(no network programming necessary at all).

Essentially you create an object on the remote machine that contains
a method with the code you want to execute, and you call that object
-using Pyro- as if it was located on your own computer.

But this only works if you have a supported Python version running
on the remote machine, and that you are allowed to connect to that
machine over the network.

You can even create some python code on your local machine, and
actually submit that to the other machine, let it deal with it,
and then get the results back.
But only do this if you know that no unauthorised user can do this,
because this is a security risk.

--Irmen de Jong.


Thank you, this is exactly what I was looking for!

Jul 18 '05 #4

P: n/a
hokiegal99 wrote:
Irmen de Jong wrote:
[...about Pyro...]
Thank you, this is exactly what I was looking for!


While Pyro may be of help (I'm sure it will be ;-) you
should not forget that there are many other ways to do
what you want.
For instance, you could also create a simple web server
application on the remote machine that has a page on which
those data about the remote machine are written.
You can then get the data from the web page using the
urllib module.

For really good advice you will have to tell a lot
more about what you want exactly (and how it should work)...

Good luck!

--Irmen
Jul 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.