local interpreter remote machines

H

hokieghal99

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
 
P

Paul Rubin

hokieghal99 said:
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.
 
I

Irmen de Jong

hokieghal99 said:
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.
 
H

hokiegal99

Irmen said:
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!
 
I

Irmen de Jong

hokiegal99 said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top