prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  /etc/shadow file contents are incorrect
  **Describe the bug**
  In the latest honeypot from master branch, a “cat /etc/shadow“ outputs a readme file instead of password contents. It looks the commit 937402ece56a4d272713ea38be32c6dc4191390a replaced the file contents.
  
  **To Reproduce**
  - enter honeypot as root
  - Run: cat /etc/shadow
  
  **Expected behavior**
  Exoecting a shadow file format output, not readme
  
  **Server (please complete the following information):**
   - Using the docker image built on 14 may 2021
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `setup.py`
  Content:
  ```
  1 #!/usr/bin/env python
  2 
  3 from setuptools import setup
  4 
  5 setup(
  6     name="Cowrie",
  7     description="Cowrie SSH/Telnet Honeypot.",
  8     long_description="Cowrie SSH/Telnet Honeypot.",
  9     author="Michel Oosterhof",
  10     author_email="michel@oosterhof.net",
  11     maintainer="Michel Oosterhof",
  12     maintainer_email="michel@oosterhof.net",
  13     keywords="ssh telnet honeypot",
  14     platforms="Unix, Mac OSX",
  15     license="BSD",
  16     url="https://www.cowrie.org/",
  17     packages=["cowrie", "twisted"],
  18     include_package_data=True,
  19     package_dir={"": "src"},
  20     package_data={"": ["*.md"]},
  21     use_incremental=True,
  22     python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4",
  23     scripts=["bin/fsctl", "bin/asciinema", "bin/cowrie", "bin/createfs", "bin/playlog"],
  24     classifiers=[
  25         "Development Status :: 5 - Production/Stable",
  26         "Environment :: No Input/Output (Daemon)",
  27         "Framework :: Twisted",
  28         "Intended Audience :: Developers",
  29         "Intended Audience :: System Administrators",
  30         "License :: OSI Approved :: BSD License",
  31         "Operating System :: MacOS :: MacOS X",
  32         "Operating System :: POSIX :: Linux",
  33         "Operating System :: POSIX",
  34         "Programming Language :: Python",
  35         "Topic :: Security",
  36     ],
  37     setup_requires=["incremental", "click"],
  38     install_requires=[
  39         "twisted>=17.1.0",
  40         "cryptography>=0.9.1",
  41         "configparser",
  42         "pyopenssl",
  43         "pyparsing",
  44         "incremental",
  45         "packaging",
  46         "appdirs>=1.4.0",
  47         "python-dateutil",
  48         "service_identity>=14.0.0",
  49     ],
  50     extras_require={
  51         "csirtg": ["csirtgsdk>=0.0.0a17"],
  52         "dshield": ["requests"],
  53         "elasticsearch": ["pyes"],
  54         "mysql": ["mysqlclient"],
  55         "mongodb": ["pymongo"],
  56         "rethinkdblog": ["rethinkdb"],
  57         "s3": ["botocore"],
  58         "slack": ["slackclient"],
  59         "influxdb": ["influxdb"],
  60     },
  61 )
  62
  ```
  
  Path: `src/cowrie/output/csirtg.py`
  Content:
  ```
  1 import os
  2 from datetime import datetime
  3 
  4 from csirtgsdk.client import Client
  5 from csirtgsdk.indicator import Indicator
  6 
  7 from twisted.python import log
  8 
  9 import cowrie.core.output
  10 from cowrie.core.config import CowrieConfig
  11 
  12 USERNAME = os.environ.get("CSIRTG_USER")
  13 FEED = os.environ.get("CSIRTG_FEED")
  14 TOKEN = os.environ.get("CSIRG_TOKEN")
  15 DESCRIPTION = os.environ.get("CSIRTG_DESCRIPTION", "random scanning activity")
  16 
  17 
  18 class Output(cowrie.core.output.Output):
  19     """
  20     csirtg output
  21     """
  22 
  23     def start(
  24         self,
  25     ):
  26         self.user = CowrieConfig.get("output_csirtg", "username") or USERNAME
  27         self.feed = CowrieConfig.get("output_csirtg", "feed") or FEED
  28         self.token = CowrieConfig.get("output_csirtg", "token") or TOKEN
  29         self.description = CowrieConfig.get(
  30             "output_csirtg", "description", fallback=DESCRIPTION
  31         )
  32         self.context = {}
  33         self.client = Client(token=self.token)
  34 
  35     def stop(self):
  36         pass
  37 
  38     def write(self, e):
  39         peerIP = e["src_ip"]
  40         ts = e["timestamp"]
  41         system = e.get("system", None)
  42 
  43         if system not in [
  44             "cowrie.ssh.factory.CowrieSSHFactory",
  45             "cowrie.telnet.transport.HoneyPotTelnetFactory",
  46         ]:
  47             return
  48 
  49         today = str(datetime.now().date())
  50 
  51         if not self.context.get(today):
  52             self.context = {}
  53             self.context[today] = set()
  54 
  55         key = ",".join([peerIP, system])
  56 
  57         if key in self.context[today]:
  58             return
  59 
  60         self.context[today].add(key)
  61 
  62         tags = "scanner,ssh"
  63         port = 22
  64         if e["system"] == "cowrie.telnet.transport.HoneyPotTelnetFactory":
  65             tags = "scanner,telnet"
  66             port = 23
  67 
  68         i = {
  69             "user": self.user,
  70             "feed": self.feed,
  71             "indicator": peerIP,
  72             "portlist": port,
  73             "protocol": "tcp",
  74             "tags": tags,
  75             "firsttime": ts,
  76             "lasttime": ts,
  77             "description": self.description,
  78         }
  79 
  80         ret = Indicator(self.client, i).submit()
  81         log.msg("logged to csirtg {} ".format(ret["location"]))
  82
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/setup.py b/setup.py
  --- a/setup.py
  +++ b/setup.py
  @@ -36,7 +36,7 @@
       ],
       setup_requires=["incremental", "click"],
       install_requires=[
  -        "twisted>=17.1.0",
  +        "twisted==21.1.0",
           "cryptography>=0.9.1",
           "configparser",
           "pyopenssl",
  @@ -48,7 +48,7 @@
           "service_identity>=14.0.0",
       ],
       extras_require={
  -        "csirtg": ["csirtgsdk>=0.0.0a17"],
  +        "csirtg": ["csirtgsdk==1.1.5"],
           "dshield": ["requests"],
           "elasticsearch": ["pyes"],
           "mysql": ["mysqlclient"],
  diff --git a/src/cowrie/output/csirtg.py b/src/cowrie/output/csirtg.py
  --- a/src/cowrie/output/csirtg.py
  +++ b/src/cowrie/output/csirtg.py
  @@ -1,41 +1,50 @@
   import os
   from datetime import datetime
   
  -from csirtgsdk.client import Client
  -from csirtgsdk.indicator import Indicator
  -
   from twisted.python import log
   
   import cowrie.core.output
   from cowrie.core.config import CowrieConfig
   
  -USERNAME = os.environ.get("CSIRTG_USER")
  -FEED = os.environ.get("CSIRTG_FEED")
  -TOKEN = os.environ.get("CSIRG_TOKEN")
  -DESCRIPTION = os.environ.get("CSIRTG_DESCRIPTION", "random scanning activity")
  +token = CowrieConfig.get("output_csirtg", "token", fallback="a1b2c3d4")
  +if token == "a1b2c3d4":
  +    log.msg("output_csirtg: token not found in configuration file")
  +    exit(1)
  +
  +os.environ["CSIRTG_TOKEN"] = token
  +import csirtgsdk  # noqa: E402
   
   
   class Output(cowrie.core.output.Output):
       """
  -    csirtg output
  +    CSIRTG output
       """
   
  -    def start(
  -        self,
  -    ):
  -        self.user = CowrieConfig.get("output_csirtg", "username") or USERNAME
  -        self.feed = CowrieConfig.get("output_csirtg", "feed") or FEED
  -        self.token = CowrieConfig.get("output_csirtg", "token") or TOKEN
  -        self.description = CowrieConfig.get(
  -            "output_csirtg", "description", fallback=DESCRIPTION
  -        )
  +    def start(self):
  +        """
  +        Start the output module.
  +        Note that csirtsdk is imported here because it reads CSIRTG_TOKEN on import
  +        Cowrie sets this environment variable.
  +        """
  +        self.user = CowrieConfig.get("output_csirtg", "username")
  +        self.feed = CowrieConfig.get("output_csirtg", "feed")
  +        self.debug = CowrieConfig.getboolean("output_csirtg", "debug", fallback=False)
  +        self.description = CowrieConfig.get("output_csirtg", "description")
  +
           self.context = {}
  -        self.client = Client(token=self.token)
  +        # self.client = csirtgsdk.client.Client()
   
       def stop(self):
           pass
   
       def write(self, e):
  +        """
  +        Only pass on connection events
  +        """
  +        if e["eventid"] == "cowrie.session.connect":
  +            self.submitIp(e)
  +
  +    def submitIp(self, e):
           peerIP = e["src_ip"]
           ts = e["timestamp"]
           system = e.get("system", None)
  @@ -77,5 +86,12 @@
               "description": self.description,
           }
   
  -        ret = Indicator(self.client, i).submit()
  -        log.msg("logged to csirtg {} ".format(ret["location"]))
  +        if self.debug is True:
  +            log.msg(f"output_csirtg: Submitting {i!r} to CSIRTG")
  +
  +        ind = csirtgsdk.indicator.Indicator(i).submit()
  +
  +        if self.debug is True:
  +            log.msg(f"output_csirtg: Submitted {ind!r} to CSIRTG")
  +
  +        log.msg("output_csirtg: submitted to csirtg at {} ".format(ind["location"]))
  
verification_info: {"golden_diff": "diff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -36,7 +36,7 @@\n     ],\n     setup_requires=[\"incremental\", \"click\"],\n     install_requires=[\n-        \"twisted>=17.1.0\",\n+        \"twisted==21.1.0\",\n         \"cryptography>=0.9.1\",\n         \"configparser\",\n         \"pyopenssl\",\n@@ -48,7 +48,7 @@\n         \"service_identity>=14.0.0\",\n     ],\n     extras_require={\n-        \"csirtg\": [\"csirtgsdk>=0.0.0a17\"],\n+        \"csirtg\": [\"csirtgsdk==1.1.5\"],\n         \"dshield\": [\"requests\"],\n         \"elasticsearch\": [\"pyes\"],\n         \"mysql\": [\"mysqlclient\"],\ndiff --git a/src/cowrie/output/csirtg.py b/src/cowrie/output/csirtg.py\n--- a/src/cowrie/output/csirtg.py\n+++ b/src/cowrie/output/csirtg.py\n@@ -1,41 +1,50 @@\n import os\n from datetime import datetime\n \n-from csirtgsdk.client import Client\n-from csirtgsdk.indicator import Indicator\n-\n from twisted.python import log\n \n import cowrie.core.output\n from cowrie.core.config import CowrieConfig\n \n-USERNAME = os.environ.get(\"CSIRTG_USER\")\n-FEED = os.environ.get(\"CSIRTG_FEED\")\n-TOKEN = os.environ.get(\"CSIRG_TOKEN\")\n-DESCRIPTION = os.environ.get(\"CSIRTG_DESCRIPTION\", \"random scanning activity\")\n+token = CowrieConfig.get(\"output_csirtg\", \"token\", fallback=\"a1b2c3d4\")\n+if token == \"a1b2c3d4\":\n+    log.msg(\"output_csirtg: token not found in configuration file\")\n+    exit(1)\n+\n+os.environ[\"CSIRTG_TOKEN\"] = token\n+import csirtgsdk  # noqa: E402\n \n \n class Output(cowrie.core.output.Output):\n     \"\"\"\n-    csirtg output\n+    CSIRTG output\n     \"\"\"\n \n-    def start(\n-        self,\n-    ):\n-        self.user = CowrieConfig.get(\"output_csirtg\", \"username\") or USERNAME\n-        self.feed = CowrieConfig.get(\"output_csirtg\", \"feed\") or FEED\n-        self.token = CowrieConfig.get(\"output_csirtg\", \"token\") or TOKEN\n-        self.description = CowrieConfig.get(\n-            \"output_csirtg\", \"description\", fallback=DESCRIPTION\n-        )\n+    def start(self):\n+        \"\"\"\n+        Start the output module.\n+        Note that csirtsdk is imported here because it reads CSIRTG_TOKEN on import\n+        Cowrie sets this environment variable.\n+        \"\"\"\n+        self.user = CowrieConfig.get(\"output_csirtg\", \"username\")\n+        self.feed = CowrieConfig.get(\"output_csirtg\", \"feed\")\n+        self.debug = CowrieConfig.getboolean(\"output_csirtg\", \"debug\", fallback=False)\n+        self.description = CowrieConfig.get(\"output_csirtg\", \"description\")\n+\n         self.context = {}\n-        self.client = Client(token=self.token)\n+        # self.client = csirtgsdk.client.Client()\n \n     def stop(self):\n         pass\n \n     def write(self, e):\n+        \"\"\"\n+        Only pass on connection events\n+        \"\"\"\n+        if e[\"eventid\"] == \"cowrie.session.connect\":\n+            self.submitIp(e)\n+\n+    def submitIp(self, e):\n         peerIP = e[\"src_ip\"]\n         ts = e[\"timestamp\"]\n         system = e.get(\"system\", None)\n@@ -77,5 +86,12 @@\n             \"description\": self.description,\n         }\n \n-        ret = Indicator(self.client, i).submit()\n-        log.msg(\"logged to csirtg {} \".format(ret[\"location\"]))\n+        if self.debug is True:\n+            log.msg(f\"output_csirtg: Submitting {i!r} to CSIRTG\")\n+\n+        ind = csirtgsdk.indicator.Indicator(i).submit()\n+\n+        if self.debug is True:\n+            log.msg(f\"output_csirtg: Submitted {ind!r} to CSIRTG\")\n+\n+        log.msg(\"output_csirtg: submitted to csirtg at {} \".format(ind[\"location\"]))\n", "issue": "/etc/shadow file contents are incorrect\n**Describe the bug**\r\nIn the latest honeypot from master branch, a \u201ccat /etc/shadow\u201c outputs a readme file instead of password contents. It looks the commit 937402ece56a4d272713ea38be32c6dc4191390a replaced the file contents.\r\n\r\n**To Reproduce**\r\n- enter honeypot as root\r\n- Run: cat /etc/shadow\r\n\r\n**Expected behavior**\r\nExoecting a shadow file format output, not readme\r\n\r\n**Server (please complete the following information):**\r\n - Using the docker image built on 14 may 2021\r\n\n", "before_files": [{"content": "#!/usr/bin/env python\n\nfrom setuptools import setup\n\nsetup(\n    name=\"Cowrie\",\n    description=\"Cowrie SSH/Telnet Honeypot.\",\n    long_description=\"Cowrie SSH/Telnet Honeypot.\",\n    author=\"Michel Oosterhof\",\n    author_email=\"michel@oosterhof.net\",\n    maintainer=\"Michel Oosterhof\",\n    maintainer_email=\"michel@oosterhof.net\",\n    keywords=\"ssh telnet honeypot\",\n    platforms=\"Unix, Mac OSX\",\n    license=\"BSD\",\n    url=\"https://www.cowrie.org/\",\n    packages=[\"cowrie\", \"twisted\"],\n    include_package_data=True,\n    package_dir={\"\": \"src\"},\n    package_data={\"\": [\"*.md\"]},\n    use_incremental=True,\n    python_requires=\">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4\",\n    scripts=[\"bin/fsctl\", \"bin/asciinema\", \"bin/cowrie\", \"bin/createfs\", \"bin/playlog\"],\n    classifiers=[\n        \"Development Status :: 5 - Production/Stable\",\n        \"Environment :: No Input/Output (Daemon)\",\n        \"Framework :: Twisted\",\n        \"Intended Audience :: Developers\",\n        \"Intended Audience :: System Administrators\",\n        \"License :: OSI Approved :: BSD License\",\n        \"Operating System :: MacOS :: MacOS X\",\n        \"Operating System :: POSIX :: Linux\",\n        \"Operating System :: POSIX\",\n        \"Programming Language :: Python\",\n        \"Topic :: Security\",\n    ],\n    setup_requires=[\"incremental\", \"click\"],\n    install_requires=[\n        \"twisted>=17.1.0\",\n        \"cryptography>=0.9.1\",\n        \"configparser\",\n        \"pyopenssl\",\n        \"pyparsing\",\n        \"incremental\",\n        \"packaging\",\n        \"appdirs>=1.4.0\",\n        \"python-dateutil\",\n        \"service_identity>=14.0.0\",\n    ],\n    extras_require={\n        \"csirtg\": [\"csirtgsdk>=0.0.0a17\"],\n        \"dshield\": [\"requests\"],\n        \"elasticsearch\": [\"pyes\"],\n        \"mysql\": [\"mysqlclient\"],\n        \"mongodb\": [\"pymongo\"],\n        \"rethinkdblog\": [\"rethinkdb\"],\n        \"s3\": [\"botocore\"],\n        \"slack\": [\"slackclient\"],\n        \"influxdb\": [\"influxdb\"],\n    },\n)\n", "path": "setup.py"}, {"content": "import os\nfrom datetime import datetime\n\nfrom csirtgsdk.client import Client\nfrom csirtgsdk.indicator import Indicator\n\nfrom twisted.python import log\n\nimport cowrie.core.output\nfrom cowrie.core.config import CowrieConfig\n\nUSERNAME = os.environ.get(\"CSIRTG_USER\")\nFEED = os.environ.get(\"CSIRTG_FEED\")\nTOKEN = os.environ.get(\"CSIRG_TOKEN\")\nDESCRIPTION = os.environ.get(\"CSIRTG_DESCRIPTION\", \"random scanning activity\")\n\n\nclass Output(cowrie.core.output.Output):\n    \"\"\"\n    csirtg output\n    \"\"\"\n\n    def start(\n        self,\n    ):\n        self.user = CowrieConfig.get(\"output_csirtg\", \"username\") or USERNAME\n        self.feed = CowrieConfig.get(\"output_csirtg\", \"feed\") or FEED\n        self.token = CowrieConfig.get(\"output_csirtg\", \"token\") or TOKEN\n        self.description = CowrieConfig.get(\n            \"output_csirtg\", \"description\", fallback=DESCRIPTION\n        )\n        self.context = {}\n        self.client = Client(token=self.token)\n\n    def stop(self):\n        pass\n\n    def write(self, e):\n        peerIP = e[\"src_ip\"]\n        ts = e[\"timestamp\"]\n        system = e.get(\"system\", None)\n\n        if system not in [\n            \"cowrie.ssh.factory.CowrieSSHFactory\",\n            \"cowrie.telnet.transport.HoneyPotTelnetFactory\",\n        ]:\n            return\n\n        today = str(datetime.now().date())\n\n        if not self.context.get(today):\n            self.context = {}\n            self.context[today] = set()\n\n        key = \",\".join([peerIP, system])\n\n        if key in self.context[today]:\n            return\n\n        self.context[today].add(key)\n\n        tags = \"scanner,ssh\"\n        port = 22\n        if e[\"system\"] == \"cowrie.telnet.transport.HoneyPotTelnetFactory\":\n            tags = \"scanner,telnet\"\n            port = 23\n\n        i = {\n            \"user\": self.user,\n            \"feed\": self.feed,\n            \"indicator\": peerIP,\n            \"portlist\": port,\n            \"protocol\": \"tcp\",\n            \"tags\": tags,\n            \"firsttime\": ts,\n            \"lasttime\": ts,\n            \"description\": self.description,\n        }\n\n        ret = Indicator(self.client, i).submit()\n        log.msg(\"logged to csirtg {} \".format(ret[\"location\"]))\n", "path": "src/cowrie/output/csirtg.py"}], "after_files": [{"content": "#!/usr/bin/env python\n\nfrom setuptools import setup\n\nsetup(\n    name=\"Cowrie\",\n    description=\"Cowrie SSH/Telnet Honeypot.\",\n    long_description=\"Cowrie SSH/Telnet Honeypot.\",\n    author=\"Michel Oosterhof\",\n    author_email=\"michel@oosterhof.net\",\n    maintainer=\"Michel Oosterhof\",\n    maintainer_email=\"michel@oosterhof.net\",\n    keywords=\"ssh telnet honeypot\",\n    platforms=\"Unix, Mac OSX\",\n    license=\"BSD\",\n    url=\"https://www.cowrie.org/\",\n    packages=[\"cowrie\", \"twisted\"],\n    include_package_data=True,\n    package_dir={\"\": \"src\"},\n    package_data={\"\": [\"*.md\"]},\n    use_incremental=True,\n    python_requires=\">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4\",\n    scripts=[\"bin/fsctl\", \"bin/asciinema\", \"bin/cowrie\", \"bin/createfs\", \"bin/playlog\"],\n    classifiers=[\n        \"Development Status :: 5 - Production/Stable\",\n        \"Environment :: No Input/Output (Daemon)\",\n        \"Framework :: Twisted\",\n        \"Intended Audience :: Developers\",\n        \"Intended Audience :: System Administrators\",\n        \"License :: OSI Approved :: BSD License\",\n        \"Operating System :: MacOS :: MacOS X\",\n        \"Operating System :: POSIX :: Linux\",\n        \"Operating System :: POSIX\",\n        \"Programming Language :: Python\",\n        \"Topic :: Security\",\n    ],\n    setup_requires=[\"incremental\", \"click\"],\n    install_requires=[\n        \"twisted==21.1.0\",\n        \"cryptography>=0.9.1\",\n        \"configparser\",\n        \"pyopenssl\",\n        \"pyparsing\",\n        \"incremental\",\n        \"packaging\",\n        \"appdirs>=1.4.0\",\n        \"python-dateutil\",\n        \"service_identity>=14.0.0\",\n    ],\n    extras_require={\n        \"csirtg\": [\"csirtgsdk==1.1.5\"],\n        \"dshield\": [\"requests\"],\n        \"elasticsearch\": [\"pyes\"],\n        \"mysql\": [\"mysqlclient\"],\n        \"mongodb\": [\"pymongo\"],\n        \"rethinkdblog\": [\"rethinkdb\"],\n        \"s3\": [\"botocore\"],\n        \"slack\": [\"slackclient\"],\n        \"influxdb\": [\"influxdb\"],\n    },\n)\n", "path": "setup.py"}, {"content": "import os\nfrom datetime import datetime\n\nfrom twisted.python import log\n\nimport cowrie.core.output\nfrom cowrie.core.config import CowrieConfig\n\ntoken = CowrieConfig.get(\"output_csirtg\", \"token\", fallback=\"a1b2c3d4\")\nif token == \"a1b2c3d4\":\n    log.msg(\"output_csirtg: token not found in configuration file\")\n    exit(1)\n\nos.environ[\"CSIRTG_TOKEN\"] = token\nimport csirtgsdk  # noqa: E402\n\n\nclass Output(cowrie.core.output.Output):\n    \"\"\"\n    CSIRTG output\n    \"\"\"\n\n    def start(self):\n        \"\"\"\n        Start the output module.\n        Note that csirtsdk is imported here because it reads CSIRTG_TOKEN on import\n        Cowrie sets this environment variable.\n        \"\"\"\n        self.user = CowrieConfig.get(\"output_csirtg\", \"username\")\n        self.feed = CowrieConfig.get(\"output_csirtg\", \"feed\")\n        self.debug = CowrieConfig.getboolean(\"output_csirtg\", \"debug\", fallback=False)\n        self.description = CowrieConfig.get(\"output_csirtg\", \"description\")\n\n        self.context = {}\n        # self.client = csirtgsdk.client.Client()\n\n    def stop(self):\n        pass\n\n    def write(self, e):\n        \"\"\"\n        Only pass on connection events\n        \"\"\"\n        if e[\"eventid\"] == \"cowrie.session.connect\":\n            self.submitIp(e)\n\n    def submitIp(self, e):\n        peerIP = e[\"src_ip\"]\n        ts = e[\"timestamp\"]\n        system = e.get(\"system\", None)\n\n        if system not in [\n            \"cowrie.ssh.factory.CowrieSSHFactory\",\n            \"cowrie.telnet.transport.HoneyPotTelnetFactory\",\n        ]:\n            return\n\n        today = str(datetime.now().date())\n\n        if not self.context.get(today):\n            self.context = {}\n            self.context[today] = set()\n\n        key = \",\".join([peerIP, system])\n\n        if key in self.context[today]:\n            return\n\n        self.context[today].add(key)\n\n        tags = \"scanner,ssh\"\n        port = 22\n        if e[\"system\"] == \"cowrie.telnet.transport.HoneyPotTelnetFactory\":\n            tags = \"scanner,telnet\"\n            port = 23\n\n        i = {\n            \"user\": self.user,\n            \"feed\": self.feed,\n            \"indicator\": peerIP,\n            \"portlist\": port,\n            \"protocol\": \"tcp\",\n            \"tags\": tags,\n            \"firsttime\": ts,\n            \"lasttime\": ts,\n            \"description\": self.description,\n        }\n\n        if self.debug is True:\n            log.msg(f\"output_csirtg: Submitting {i!r} to CSIRTG\")\n\n        ind = csirtgsdk.indicator.Indicator(i).submit()\n\n        if self.debug is True:\n            log.msg(f\"output_csirtg: Submitted {ind!r} to CSIRTG\")\n\n        log.msg(\"output_csirtg: submitted to csirtg at {} \".format(ind[\"location\"]))\n", "path": "src/cowrie/output/csirtg.py"}]}