diff options
author | Kevin Lange <k@dakko.us> | 2011-11-30 17:12:57 -0600 |
---|---|---|
committer | Kevin Lange <k@dakko.us> | 2011-11-30 17:12:57 -0600 |
commit | f78de8320de533094e20e32e9f3f408905956e34 (patch) | |
tree | cdbaea67b32678700a92612cc37a79583c2ee4c2 /nyancat.py | |
parent | 7d0c23406b3d58bdeb467025198d89f5efea884d (diff) | |
download | nyancat-f78de8320de533094e20e32e9f3f408905956e34.tar.gz |
Telnet server
Diffstat (limited to '')
-rwxr-xr-x | nyancat.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/nyancat.py b/nyancat.py new file mode 100755 index 0000000..ebeb303 --- /dev/null +++ b/nyancat.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python +import SocketServer +from subprocess import Popen, PIPE +from telnetsrvlib import TelnetHandler + +class TNS(SocketServer.TCPServer): + allow_reuse_address = True + +class TNH(TelnetHandler): + def handle(self): + print self.TERM + p = Popen(["./nyancat"], shell=False, stdout=PIPE, stdin=PIPE, bufsize=0) + if (self.TERM.lower().find("xterm") != -1): + p.stdin.write("1\n") + elif (self.TERM.lower().find("linux") != -1): + p.stdin.write("3\n") + elif (self.TERM.lower().find("fallback") != -1): + p.stdin.write("4\n") + else: + p.stdin.write("2\n") + while 1: + s = p.stdout.read(1) + try: + self.write(s) + except: + p.kill() + return + +tns = TNS(("0.0.0.0", 23), TNH) +tns.serve_forever() |