diff --git a/cowrie/core/honeypot.py b/cowrie/core/honeypot.py index 505531f..52f442e 100644 --- a/cowrie/core/honeypot.py +++ b/cowrie/core/honeypot.py @@ -136,8 +136,7 @@ class HoneyPotShell(object): """ """ log.msg('CMD: %s' % (line,)) - self.lexer = shlex.shlex(punctuation_chars=True); - self.lexer.push_source(line) + self.lexer = shlex.shlex(instream=line, punctuation_chars=True); tokens = [] while True: try: diff --git a/cowrie/core/shlex.py b/cowrie/core/shlex.py index 4e4ace5..a482d21 100644 --- a/cowrie/core/shlex.py +++ b/cowrie/core/shlex.py @@ -23,8 +23,7 @@ class shlex: def __init__(self, instream=None, infile=None, posix=False, punctuation_chars=False): if isinstance(instream, str): - instream = StringIO(instream) - #instream = BytesIO(instream) + instream = BytesIO(instream) if instream is not None: self.instream = instream self.infile = infile @@ -83,7 +82,6 @@ class shlex: def push_source(self, newstream, newfile=None): "Push an input source onto the lexer's input source stack." if isinstance(newstream, str): - #newstream = StringIO(newstream) newstream = BytesIO(newstream) self.filestack.appendleft((self.infile, self.instream, self.lineno)) self.infile = newfile