mirror of
https://github.com/cowrie/cowrie.git
synced 2025-07-01 18:07:27 -04:00
send unicode to shlex
This commit is contained in:
@ -141,6 +141,7 @@ class HoneyPotCommand(object):
|
|||||||
"""
|
"""
|
||||||
log.msg('QUEUED INPUT: {}'.format(line))
|
log.msg('QUEUED INPUT: {}'.format(line))
|
||||||
# FIXME: naive command parsing, see lineReceived below
|
# FIXME: naive command parsing, see lineReceived below
|
||||||
|
line=unicode(line)
|
||||||
self.protocol.cmdstack[0].cmdpending.append(shlex.split(line))
|
self.protocol.cmdstack[0].cmdpending.append(shlex.split(line))
|
||||||
|
|
||||||
|
|
||||||
@ -184,6 +185,7 @@ class HoneyPotShell(object):
|
|||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
log.msg(eventid='cowrie.command.input', input=line, format='CMD: %(input)s')
|
log.msg(eventid='cowrie.command.input', input=line, format='CMD: %(input)s')
|
||||||
|
line=unicode(line)
|
||||||
self.lexer = shlex.shlex(instream=line, punctuation_chars=True)
|
self.lexer = shlex.shlex(instream=line, punctuation_chars=True)
|
||||||
tokens = []
|
tokens = []
|
||||||
while True:
|
while True:
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import re
|
|||||||
import sys
|
import sys
|
||||||
from collections import deque
|
from collections import deque
|
||||||
|
|
||||||
from io import StringIO, BytesIO
|
from io import StringIO
|
||||||
|
|
||||||
__all__ = ["shlex", "split", "quote"]
|
__all__ = ["shlex", "split", "quote"]
|
||||||
|
|
||||||
@ -22,8 +22,8 @@ class shlex:
|
|||||||
"A lexical analyzer class for simple shell-like syntaxes."
|
"A lexical analyzer class for simple shell-like syntaxes."
|
||||||
def __init__(self, instream=None, infile=None, posix=False,
|
def __init__(self, instream=None, infile=None, posix=False,
|
||||||
punctuation_chars=False):
|
punctuation_chars=False):
|
||||||
if isinstance(instream, str):
|
if isinstance(instream, basestring):
|
||||||
instream = BytesIO(instream)
|
instream = StringIO(instream)
|
||||||
if instream is not None:
|
if instream is not None:
|
||||||
self.instream = instream
|
self.instream = instream
|
||||||
self.infile = infile
|
self.infile = infile
|
||||||
@ -82,7 +82,7 @@ class shlex:
|
|||||||
def push_source(self, newstream, newfile=None):
|
def push_source(self, newstream, newfile=None):
|
||||||
"Push an input source onto the lexer's input source stack."
|
"Push an input source onto the lexer's input source stack."
|
||||||
if isinstance(newstream, str):
|
if isinstance(newstream, str):
|
||||||
newstream = BytesIO(newstream)
|
newstream = StringIO(newstream)
|
||||||
self.filestack.appendleft((self.infile, self.instream, self.lineno))
|
self.filestack.appendleft((self.infile, self.instream, self.lineno))
|
||||||
self.infile = newfile
|
self.infile = newfile
|
||||||
self.instream = newstream
|
self.instream = newstream
|
||||||
|
|||||||
Reference in New Issue
Block a user