Commands should be decoded as utf8 (#1477)

Co-authored-by: Michel Oosterhof <micheloosterhof@users.noreply.github.com>
This commit is contained in:
Sereysethy Touch 2021-04-26 15:52:14 +02:00 committed by GitHub
parent a79d6bc0ca
commit dddde1850a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 12 deletions

View File

@ -40,11 +40,13 @@ class ExecTerm(base_protocol.BaseProtocol):
def __init__(self, uuid, channelName, ssh, channelId, command):
super().__init__(uuid, channelName, ssh)
log.msg(
eventid="cowrie.command.input",
input=command.decode("ascii"),
format="CMD: %(input)s",
)
try:
log.msg(eventid='cowrie.command.input',
input=command.decode('utf8'),
format='CMD: %(input)s')
except UnicodeDecodeError:
log.err("Unusual execcmd: {}".format(repr(command)))
self.transportId = ssh.server.transportId
self.channelId = channelId

View File

@ -115,14 +115,16 @@ class Term(base_protocol.BaseProtocol):
self.command += b"^C"
self.data = self.data[1:]
if self.command != b"":
log.msg(
eventid="cowrie.command.input",
input=self.command.decode("ascii"),
format="CMD: %(input)s",
)
try:
if self.command != b'':
log.msg(eventid='cowrie.command.input',
input=self.command.decode('utf8'),
format='CMD: %(input)s')
except UnicodeDecodeError:
log.err("Unusual execcmd: {}".format(repr(self.command)))
self.command = b""
self.command = b''
self.pointer = 0
# If Home Pressed
elif self.data[:3] == b"\x1b\x4f\x48":