From 0732efbe54f5bbc81082650ddef2ecf34a0cf473 Mon Sep 17 00:00:00 2001 From: Bernhard Geisberger Date: Mon, 2 Nov 2020 05:41:38 +0100 Subject: [PATCH 1/6] add nsq output plugin --- requirements-output.txt | 3 +++ src/cowrie/output/nsq.py | 48 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 src/cowrie/output/nsq.py diff --git a/requirements-output.txt b/requirements-output.txt index 5b5b77aa40..d28b3d0d89 100644 --- a/requirements-output.txt +++ b/requirements-output.txt @@ -43,3 +43,6 @@ wokkel==18.0.0 pymisp==2.4.128; python_version >= '3.0' pymisp==2.4.121.1; python_version < '3.0' pathlib==1.0.1; python_version < '3.0' + +# nsq +gnsq==1.0.2 \ No newline at end of file diff --git a/src/cowrie/output/nsq.py b/src/cowrie/output/nsq.py new file mode 100644 index 0000000000..a9f0ac4c14 --- /dev/null +++ b/src/cowrie/output/nsq.py @@ -0,0 +1,48 @@ +from __future__ import absolute_import, division + +import json +from configparser import NoOptionError + +from gnsq import Producer + +import cowrie.core.output +from cowrie.core.config import CowrieConfig + + +class Output(cowrie.core.output.Output): + """ + nsq output + """ + + def start(self): + host = CowrieConfig().get('output_nsq', 'host') + + try: + port = CowrieConfig().getint('output_nsq', 'port') + except NoOptionError: + port = 4150 + + try: + auth_secret = CowrieConfig().get('output_nsq', 'auth_secret') + except NoOptionError: + auth_secret = None + + try: + tls = CowrieConfig().getboolean('output_nsq', 'use_tls') + except NoOptionError: + tls = False + + self.producer = Producer(host + ":" + str(port), auth_secret=auth_secret, tls_v1=tls) + self.topic = CowrieConfig().get('output_nsq', 'topic') + self.producer.start() + + def stop(self): + self.producer.close() + + def write(self, logentry): + for i in list(logentry.keys()): + # Remove twisted 15 legacy keys + if i.startswith('log_'): + del logentry[i] + + self.producer.publish(self.topic, json.dumps(logentry).encode("utf-8")) From a95865a1f0b3d0d0011f270442e838c6bbd12965 Mon Sep 17 00:00:00 2001 From: Steve Freegard Date: Wed, 11 Nov 2020 22:18:26 +0000 Subject: [PATCH 2/6] Add tls_options --- src/cowrie/output/nsq.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cowrie/output/nsq.py b/src/cowrie/output/nsq.py index a9f0ac4c14..2e94e919d9 100644 --- a/src/cowrie/output/nsq.py +++ b/src/cowrie/output/nsq.py @@ -32,7 +32,7 @@ def start(self): except NoOptionError: tls = False - self.producer = Producer(host + ":" + str(port), auth_secret=auth_secret, tls_v1=tls) + self.producer = Producer(host + ":" + str(port), auth_secret=auth_secret, tls_v1=tls, tls_options={}) self.topic = CowrieConfig().get('output_nsq', 'topic') self.producer.start() From 543c3c5a311e825ccf22ea23e65b8db7b92398b9 Mon Sep 17 00:00:00 2001 From: Christian Wahl Date: Thu, 17 Aug 2023 15:19:21 +0200 Subject: [PATCH 3/6] fix linting errors --- src/cowrie/output/nsq.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/cowrie/output/nsq.py b/src/cowrie/output/nsq.py index 2e94e919d9..a3a72a06e5 100644 --- a/src/cowrie/output/nsq.py +++ b/src/cowrie/output/nsq.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division - import json from configparser import NoOptionError @@ -15,25 +13,25 @@ class Output(cowrie.core.output.Output): """ def start(self): - host = CowrieConfig().get('output_nsq', 'host') + host = CowrieConfig().get("output_nsq", "host") try: - port = CowrieConfig().getint('output_nsq', 'port') + port = CowrieConfig().getint("output_nsq", "port") except NoOptionError: port = 4150 try: - auth_secret = CowrieConfig().get('output_nsq', 'auth_secret') + auth_secret = CowrieConfig().get("output_nsq", "auth_secret") except NoOptionError: auth_secret = None try: - tls = CowrieConfig().getboolean('output_nsq', 'use_tls') + tls = CowrieConfig().getboolean("output_nsq", "use_tls") except NoOptionError: tls = False self.producer = Producer(host + ":" + str(port), auth_secret=auth_secret, tls_v1=tls, tls_options={}) - self.topic = CowrieConfig().get('output_nsq', 'topic') + self.topic = CowrieConfig().get("output_nsq", "topic") self.producer.start() def stop(self): @@ -42,7 +40,7 @@ def stop(self): def write(self, logentry): for i in list(logentry.keys()): # Remove twisted 15 legacy keys - if i.startswith('log_'): + if i.startswith("log_"): del logentry[i] self.producer.publish(self.topic, json.dumps(logentry).encode("utf-8")) From 22bbed998cc0ab2732b22676478232fbdfebaa9d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Sep 2023 21:16:07 +0000 Subject: [PATCH 4/6] Bump cryptography from 41.0.3 to 41.0.4 Bumps [cryptography](https://github.com/pyca/cryptography) from 41.0.3 to 41.0.4. - [Changelog](https://github.com/pyca/cryptography/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pyca/cryptography/compare/41.0.3...41.0.4) --- updated-dependencies: - dependency-name: cryptography dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index cec2e783e7..3289ac1845 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ appdirs==1.4.4 attrs==23.1.0 bcrypt==4.0.1 configparser==6.0.0 -cryptography==41.0.3 +cryptography==41.0.4 packaging==23.1 pyasn1_modules==0.3.0 pyparsing==3.1.0 From c02b6cfc23e79d865dfeacc12716145e5d8ec6c2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Nov 2023 16:09:43 +0000 Subject: [PATCH 5/6] Bump twisted from 22.10.0 to 23.10.0 Bumps [twisted](https://github.com/twisted/twisted) from 22.10.0 to 23.10.0. - [Release notes](https://github.com/twisted/twisted/releases) - [Changelog](https://github.com/twisted/twisted/blob/trunk/NEWS.rst) - [Commits](https://github.com/twisted/twisted/compare/twisted-22.10.0...twisted-23.10.0) --- updated-dependencies: - dependency-name: twisted dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index be9783fba1..4c9eb4a5b4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,7 @@ classifiers=[ ] dependencies = [ - "Twisted==22.10.0", + "Twisted==23.10.0", ] # "cryptography>=0.9.1", # "configparser", diff --git a/requirements.txt b/requirements.txt index 3289ac1845..60b2ad650c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,4 +10,4 @@ python-dateutil==2.8.2 service_identity==23.1.0 tftpy==0.8.2 treq==22.2.0 -twisted==22.10.0 +twisted==23.10.0 From daca9559da4ab1468d605353120a54a18a6683a3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 29 Nov 2023 00:15:50 +0000 Subject: [PATCH 6/6] Bump cryptography from 41.0.4 to 41.0.6 Bumps [cryptography](https://github.com/pyca/cryptography) from 41.0.4 to 41.0.6. - [Changelog](https://github.com/pyca/cryptography/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pyca/cryptography/compare/41.0.4...41.0.6) --- updated-dependencies: - dependency-name: cryptography dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 3289ac1845..2cac8ac5f4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ appdirs==1.4.4 attrs==23.1.0 bcrypt==4.0.1 configparser==6.0.0 -cryptography==41.0.4 +cryptography==41.0.6 packaging==23.1 pyasn1_modules==0.3.0 pyparsing==3.1.0