3 # Remote python server.
4 # Execute Python commands remotely and send output back.
5 # WARNING: This version has a gaping security hole -- it accepts requests
6 # from any host on the Internet!
18 port
= int(eval(sys
.argv
[1]))
21 s
= socket(AF_INET
, SOCK_STREAM
)
25 conn
, (remotehost
, remoteport
) = s
.accept()
26 print 'connected by', remotehost
, remoteport
29 data
= conn
.recv(BUFSIZE
)
32 request
= request
+ data
33 reply
= execute(request
)
40 sys
.stdout
= sys
.stderr
= fakefile
= StringIO
.StringIO()
43 exec request
in {}, {}
46 traceback
.print_exc(100)
50 return fakefile
.getvalue()