#Richard Albert Nichols III (http://www.gate.net/~inhahe) #WConio functions arent really necessary import socket, os, WConio, thread password = "" s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(('', 23 )) s.listen(1) #need to make a class to ensure stopping of old threads #see if twisted speeds it up #try twisted's process class #make a line input function def send(x): conn.send(x.replace('\xff','\xff\xff').replace('\n','\r\n')) def recv(): try: x = conn.recv(1024).replace('\xff\xff','') y = x.find('\xff') if y>-1: x = x[:y]+x[y+3:] return x except socket.timeout: return '' def listen(): global stop while not stop: try: output = out.read(1) WConio.cputs(output) send(output) except: stop = True while 1: stop = False try: conn, addr = s.accept() except: continue conn.settimeout(.001) print "connected:",addr # conn.send("\x1b[m\xff\xfe\x01") conn.send("\x1b[m") send("Enter password: ") st=" " while st[-1]!="\n": try: st+=recv() except socket.timeout: pass print "password:",repr(st[1:-2]) if st[1:-2]!=password: conn.close() continue send("Enter command: ") st=" " while st[-1]!="\n": try: st+=recv() except socket.timeout: pass print "command:",st[1:-1] n, out = os.popen4(st[1:]) # n, out = os.popen4("python.exe -u ttt.py") thread.start_new_thread(listen, ()) while not stop: try: try: x = recv() if x: n.write(x) except socket.timeout: pass except: stop = True conn.close()