after commands, close channel, don't kill session directly

This commit is contained in:
Michel Oosterhof 2015-03-31 12:11:50 +00:00
parent aa11c54140
commit 347056a03d
2 changed files with 12 additions and 4 deletions

View File

@ -81,15 +81,15 @@ class HoneyPotShell(object):
elif self.interactive:
self.showPrompt()
else:
# transport.lostConnection is a bit overzealous. maybe close session?
self.honeypot.terminal.transport.loseConnection()
self.honeypot.terminal.transport.session.sendEOF()
self.honeypot.terminal.transport.session.sendClose()
if not len(self.cmdpending):
if self.interactive:
self.showPrompt()
else:
# transport.lostConnection is a bit overzealous. maybe close session?
self.honeypot.terminal.transport.loseConnection()
self.honeypot.terminal.transport.session.sendEOF()
self.honeypot.terminal.transport.session.sendClose()
return
line = self.cmdpending.pop(0)

View File

@ -279,6 +279,14 @@ class HoneyPotSSHSession(session.SSHSession):
def closed(self):
session.SSHSession.closed(self)
# utility function to request to send EOF for this session
def sendEOF(self):
self.conn.sendEOF(self)
# utility function to request to send close for this session
def sendClose(self):
self.conn.sendClose(self)
def loseConnection(self):
self.conn.sendRequest(self, 'exit-status', "\x00"*4)
session.SSHSession.loseConnection(self)