From 60bcf2b0e1a60e8b7d23d5609c20f3f750e51586 Mon Sep 17 00:00:00 2001 From: Michel Oosterhof Date: Fri, 6 Sep 2019 16:39:49 +0100 Subject: [PATCH 1/4] better error (#1203) --- src/cowrie/shell/protocol.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cowrie/shell/protocol.py b/src/cowrie/shell/protocol.py index 22094828..adc94559 100644 --- a/src/cowrie/shell/protocol.py +++ b/src/cowrie/shell/protocol.py @@ -167,7 +167,7 @@ class HoneyPotBaseProtocol(insults.TerminalProtocol, TimeoutMixin): if path in self.commands: return self.commands[path] - log.msg("Can't find command {}".format(path)) + log.msg("Can't find command {}".format(cmd)) return None def lineReceived(self, line): From b44b9077432939110695b7c2598ccab6c6cae36e Mon Sep 17 00:00:00 2001 From: Michel Oosterhof Date: Fri, 6 Sep 2019 16:52:35 +0100 Subject: [PATCH 2/4] remove exceptions (#1204) --- src/cowrie/commands/tftp.py | 49 +++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/src/cowrie/commands/tftp.py b/src/cowrie/commands/tftp.py index 3817226c..ce06387c 100644 --- a/src/cowrie/commands/tftp.py +++ b/src/cowrie/commands/tftp.py @@ -88,35 +88,32 @@ class command_tftp(HoneyPotCommand): parser.add_argument("-p") parser.add_argument("-r") - try: - args = parser.parse_args(self.args) - if args.c: - if len(args.c) > 1: - self.file_to_get = args.c[1] - if args.hostname is None: - self.exit() - self.hostname = args.hostname + args = parser.parse_args(self.args) + if args.c: + if len(args.c) > 1: + self.file_to_get = args.c[1] + if args.hostname is None: + self.exit() + return + self.hostname = args.hostname + elif args.r: + self.file_to_get = args.r + self.hostname = args.g + else: + parser.print_usage() + self.exit() + return - elif args.r: - self.file_to_get = args.r - self.hostname = args.g - else: - parser.print_usage() - self.exit() + if self.hostname is None: + self.exit() + return - if self.hostname is None: - self.exit() - - if self.hostname.find(':') != -1: - host, port = self.hostname.split(':') - self.hostname = host - self.port = int(port) - - self.makeTftpRetrieval() - - except Exception as err: - log.err(str(err)) + if self.hostname.find(':') != -1: + host, port = self.hostname.split(':') + self.hostname = host + self.port = int(port) + self.makeTftpRetrieval() self.exit() From 126d3b34f1ab3b201034646bbd788db56d0de91a Mon Sep 17 00:00:00 2001 From: Michel Oosterhof Date: Mon, 9 Sep 2019 22:22:44 +0100 Subject: [PATCH 3/4] Mysql retry (#1205) * log message was on wrong branch --- src/cowrie/output/mysql.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cowrie/output/mysql.py b/src/cowrie/output/mysql.py index 1ac188b2..46760dd9 100644 --- a/src/cowrie/output/mysql.py +++ b/src/cowrie/output/mysql.py @@ -33,8 +33,8 @@ class ReconnectingConnectionPool(adbapi.ConnectionPool): self, interaction, *args, **kw) except MySQLdb.OperationalError as e: if e[0] not in (2003, 2006, 2013): - log.msg("RCP: got error {0}, retrying operation".format(e)) raise e + log.msg("RCP: got error {0}, retrying operation".format(e)) conn = self.connections.get(self.threadID()) self.disconnect(conn) # Try the interaction again From 1f564c380345e7856f63c34f99924134083a1a3f Mon Sep 17 00:00:00 2001 From: Michel Oosterhof Date: Thu, 12 Sep 2019 08:22:55 +0100 Subject: [PATCH 4/4] more py versions (#1206) * py versions * allow failure for nightly/dev --- .travis.yml | 5 +++++ tox.ini | 2 ++ 2 files changed, 7 insertions(+) diff --git a/.travis.yml b/.travis.yml index 72ccc720..193ff71e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,11 @@ python: - '3.5' - '3.6' - '3.7' + - '3.7-dev' - '3.8-dev' - 'nightly' + - 'pypy' + - 'pypy3' before_install: - sudo apt-get -qq update install: @@ -33,3 +36,5 @@ notifications: matrix: allow_failures: - python: '3.8-dev' + - python: '3.7-dev' + - python: 'nightly' diff --git a/tox.ini b/tox.ini index 9e2619a1..d8d119e6 100644 --- a/tox.ini +++ b/tox.ini @@ -11,6 +11,8 @@ python = 3.6: py36 3.7: py37, lint, docs 3.8-dev: py38 + pypy: pypy + pypy3: pypy3 [testenv] setenv =