Fix the interact feature to correctly handle line returns when using windows

telnet or putty


git-svn-id: https://kippo.googlecode.com/svn/trunk@218 951d7100-d841-11de-b865-b3884708a8e2
This commit is contained in:
desaster 2012-04-13 05:46:16 +00:00
parent 0eaf51c48e
commit f756438e51
1 changed files with 2 additions and 6 deletions

View File

@ -6,7 +6,6 @@ import time
class Interact(telnet.Telnet): class Interact(telnet.Telnet):
def connectionMade(self): def connectionMade(self):
print 'Connected'
self.interacting = None self.interacting = None
self.cmdbuf = '' self.cmdbuf = ''
self.honeypotFactory = self.factory.honeypotFactory self.honeypotFactory = self.factory.honeypotFactory
@ -20,22 +19,20 @@ class Interact(telnet.Telnet):
self.cmd_help() self.cmd_help()
def connectionLost(self, reason): def connectionLost(self, reason):
print 'Connection lost'
if self.interacting != None: if self.interacting != None:
self.interacting.delInteractor(self) self.interacting.delInteractor(self)
def enableRemote(self, option): def enableRemote(self, option):
print 'enableRemote', repr(option)
return option == telnet.LINEMODE return option == telnet.LINEMODE
def disableRemote(self, option): def disableRemote(self, option):
print 'disableRemote', repr(option) pass
def applicationDataReceived(self, bytes): def applicationDataReceived(self, bytes):
# in command mode, we want to echo characters and buffer the input # in command mode, we want to echo characters and buffer the input
if not self.interacting: if not self.interacting:
self.transport.write(bytes) self.transport.write(bytes)
if bytes == '\r': if bytes in ('\r', '\n'):
self.transport.write('\n') self.transport.write('\n')
pieces = self.cmdbuf.split(' ', 1) pieces = self.cmdbuf.split(' ', 1)
self.cmdbuf = '' self.cmdbuf = ''
@ -45,7 +42,6 @@ class Interact(telnet.Telnet):
try: try:
func = getattr(self, 'cmd_' + cmd) func = getattr(self, 'cmd_' + cmd)
except AttributeError: except AttributeError:
print 'Unknown command: %s' % (cmd,)
self.transport.write('** Unknown command.\r\n') self.transport.write('** Unknown command.\r\n')
return return
func(args) func(args)