mirror of
https://github.com/cowrie/cowrie.git
synced 2025-07-01 18:07:27 -04:00
use processended to indicate process ended and send status
This commit is contained in:
@ -10,7 +10,9 @@ import shlex
|
||||
import re
|
||||
import copy
|
||||
|
||||
from twisted.python import log
|
||||
from twisted.python import log, failure
|
||||
|
||||
from twisted.internet import error
|
||||
|
||||
from cowrie.core import fs
|
||||
|
||||
@ -122,13 +124,15 @@ class HoneyPotShell(object):
|
||||
elif self.interactive:
|
||||
self.showPrompt()
|
||||
else:
|
||||
self.protocol.terminal.transport.session.loseConnection()
|
||||
ret = failure.Failure(error.ProcessDone(status=""))
|
||||
self.protocol.terminal.transport.processEnded(ret)
|
||||
|
||||
if not len(self.cmdpending):
|
||||
if self.interactive:
|
||||
self.showPrompt()
|
||||
else:
|
||||
self.protocol.terminal.transport.session.loseConnection()
|
||||
ret = failure.Failure(error.ProcessDone(status=""))
|
||||
self.protocol.terminal.transport.processEnded(ret)
|
||||
return
|
||||
|
||||
line = self.cmdpending.pop(0)
|
||||
|
@ -10,10 +10,12 @@ import time
|
||||
import socket
|
||||
import hashlib
|
||||
|
||||
from twisted.python import failure, log
|
||||
from twisted.internet import error
|
||||
from twisted.protocols.policies import TimeoutMixin
|
||||
|
||||
from twisted.conch import recvline
|
||||
from twisted.conch.insults import insults
|
||||
from twisted.python import log
|
||||
from twisted.protocols.policies import TimeoutMixin
|
||||
|
||||
from cowrie.core import honeypot
|
||||
from cowrie.core import ttylog
|
||||
@ -56,6 +58,8 @@ class HoneyPotBaseProtocol(insults.TerminalProtocol, TimeoutMixin):
|
||||
def connectionMade(self):
|
||||
"""
|
||||
"""
|
||||
|
||||
|
||||
transport = self.terminal.transport.session.conn.transport
|
||||
|
||||
self.realClientIP = transport.transport.getPeer().host
|
||||
@ -85,10 +89,11 @@ class HoneyPotBaseProtocol(insults.TerminalProtocol, TimeoutMixin):
|
||||
|
||||
def timeoutConnection(self):
|
||||
"""
|
||||
this logs out when connection times out
|
||||
"""
|
||||
self.writeln( 'timed out waiting for input: auto-logout' )
|
||||
self.terminal.transport.session.sendEOF()
|
||||
self.terminal.transport.session.sendClose()
|
||||
ret = failure.Failure(error.ProcessTerminated(exitCode=1))
|
||||
self.terminal.transport.processEnded(ret)
|
||||
|
||||
|
||||
def eofReceived(self):
|
||||
|
@ -501,13 +501,6 @@ class HoneyPotSSHSession(session.SSHSession):
|
||||
self.conn.sendClose(self)
|
||||
|
||||
|
||||
def loseConnection(self):
|
||||
"""
|
||||
"""
|
||||
self.conn.sendRequest(self, 'exit-status', "\x00"*4)
|
||||
session.SSHSession.loseConnection(self)
|
||||
|
||||
|
||||
def channelClosed(self):
|
||||
"""
|
||||
"""
|
||||
@ -576,13 +569,14 @@ class SSHSessionForCowrieUser:
|
||||
'HOME': self.avatar.home}
|
||||
|
||||
|
||||
def openShell(self, proto):
|
||||
def openShell(self, processprotocol):
|
||||
"""
|
||||
"""
|
||||
log.msg( "openshell: %s" % (repr(processprotocol),) )
|
||||
self.protocol = protocol.LoggingServerProtocol(
|
||||
protocol.HoneyPotInteractiveProtocol, self)
|
||||
self.protocol.makeConnection(proto)
|
||||
proto.makeConnection(session.wrapProtocol(self.protocol))
|
||||
self.protocol.makeConnection(processprotocol)
|
||||
processprotocol.makeConnection(session.wrapProtocol(self.protocol))
|
||||
|
||||
|
||||
def getPty(self, terminal, windowSize, attrs):
|
||||
@ -595,13 +589,13 @@ class SSHSessionForCowrieUser:
|
||||
return None
|
||||
|
||||
|
||||
def execCommand(self, proto, cmd):
|
||||
def execCommand(self, processprotocol, cmd):
|
||||
"""
|
||||
"""
|
||||
self.protocol = protocol.LoggingServerProtocol(
|
||||
protocol.HoneyPotExecProtocol, self, cmd)
|
||||
self.protocol.makeConnection(proto)
|
||||
proto.makeConnection(session.wrapProtocol(self.protocol))
|
||||
self.protocol.makeConnection(processprotocol)
|
||||
processprotocol.makeConnection(session.wrapProtocol(self.protocol))
|
||||
|
||||
|
||||
def closed(self):
|
||||
|
Reference in New Issue
Block a user