错误:未授权使用cuckoo(DB名称)执行命令(使用mongoDB进行cuckoo)

时间:2016-12-17 19:53:54

标签: mongodb

我正在尝试使用带有布谷鸟的mongoDB,但我收到此错误消息:

2016-12-16 06:58:01,632 [lib.cuckoo.core.plugins] ERROR: Failed to run the reporting module "MongoDB":
Traceback (most recent call last):
  File "/home/ziv/Documents/cuckoo/lib/cuckoo/core/plugins.py", line 533, in process
    current.run(self.results)
  File "/home/ziv/Documents/cuckoo/modules/reporting/mongodb.py", line 89, in run
    if "cuckoo_schema" in self.db.collection_names():
  File "/usr/lib/python2.7/dist-packages/pymongo/database.py", line 520, in collection_names
    results = self._list_collections(sock_info, slave_okay)
  File "/usr/lib/python2.7/dist-packages/pymongo/database.py", line 492, in _list_collections
    cursor = self._command(sock_info, cmd, slave_okay)["cursor"]
  File "/usr/lib/python2.7/dist-packages/pymongo/database.py", line 393, in _command
    allowable_errors)
  File "/usr/lib/python2.7/dist-packages/pymongo/pool.py", line 211, in command
    read_concern)
  File "/usr/lib/python2.7/dist-packages/pymongo/network.py", line 100, in command
    helpers._check_command_response(response_doc, msg, allowable_errors)
  File "/usr/lib/python2.7/dist-packages/pymongo/helpers.py", line 196, in _check_command_response
    raise OperationFailure(msg % errmsg, code, response)
OperationFailure: command SON([('listCollections', 1), ('cursor', {})]) on namespace cuckoo.$cmd failed: not authorized on cuckoo to execute command { listCollections: 1, cursor: {} }

这是我的DB:

 show dbs 
    admin   0.078GB 
    cuckoo  0.078GB 
    local   0.078GB

我使用本指南安装mongo db https://www.howtoforge.com/tutorial/install-mongodb-on-ubuntu-16.04/

我使用本指南安装杜鹃 http://mostlyaboutsecurity.com/?p=15&i=1

更新

ithink我没有权限,但我不知道如何设置我需要的, 这是使用mongo DB的布谷鸟代码:  (在这一行“self.db.collection_names():”)

 def run(self, results):
        """Writes report.
        @param results: analysis results dictionary.
        @raise CuckooReportError: if fails to connect or write to MongoDB.
        """
        if not HAVE_MONGO:
            raise CuckooDependencyError(
                "Unable to import pymongo (install with "
                "`pip install pymongo`)"
            )

        self.connect()

        # Set mongo schema version.
        # TODO: This is not optimal becuase it run each analysis. Need to run
        # only one time at startup.
        if "cuckoo_schema" in self.db.collection_names():
            if self.db.cuckoo_schema.find_one()["version"] != self.SCHEMA_VERSION:
                CuckooReportError("Mongo schema version not expected, check data migration tool")
        else:
            self.db.cuckoo_schema.save({"version": self.SCHEMA_VERSION})

 def connect(self):
        """Connects to Mongo database, loads options and set connectors.
        @raise CuckooReportError: if unable to connect.
        """
        host = self.options.get("host", "127.0.0.1")
        port = int(self.options.get("port", 27017))
        db = self.options.get("db", "cuckoo")

        try:
            self.conn = MongoClient(host, port)
            self.db = self.conn[db]
            self.fs = GridFS(self.db)
        except TypeError:
            raise CuckooReportError("Mongo connection port must be integer")
        except ConnectionFailure:
            raise CuckooReportError("Cannot connect to MongoDB")

我不想编辑此代码(向其添加连接字符串)

我有一个干净的MongoDB安装,我如何创建一个名为cuckoo的数据库 这段代码可以使用吗?

我在所有阅读的指南中找不到任何参考资料。就像它应该自动工作但它没有

1 个答案:

答案 0 :(得分:0)

错误消息是:

OperationFailure: command SON([('listCollections', 1), ('cursor', {})]) on namespace cuckoo.$cmd failed: not authorized on cuckoo to execute command { listCollections: 1, cursor: {} }

这表示您的应用正在尝试在没有权限的MongoDB数据库中执行命令。

  • 您的数据库连接字符串是否包含身份验证凭据(用户名/密码)?
  • 此用户是否具有执行此命令的必要权限?