Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mongodb dbnames #332

Merged
merged 2 commits into from
Jul 1, 2022
Merged

Add mongodb dbnames #332

merged 2 commits into from
Jul 1, 2022

Conversation

dabdine
Copy link
Contributor

@dabdine dabdine commented Oct 21, 2021

Adds the ability to retrieve database names & sizes from MongoDB.

How to Test

for MONGO_VERSION in "2.4" "2.6" "3.2" "3.6" "4.1" "4.2" "4.4" "5.0"; do { CID=$(docker run --rm --name test-mongo -d -p 1111:27017 mongo:$MONGO_VERSION) && sleep 1 && echo -n "127.0.0.1,," | ./zgrab2 mongodb -p 1111 | jq . && docker kill $CID; } done;

Notes & Caveats

Example output:

{
  "ip": "127.0.0.1",
  "data": {
    "mongodb": {
      "status": "success",
      "protocol": "mongodb",
      "result": {
        "is_master": {
          "is_master": true,
          "max_wire_version": 2,
          "max_bson_object_size": 16777216,
          "max_write_batch_size": 1000,
          "max_message_size_bytes": 48000000,
          "read_only": false
        },
        "build_info": {
          "version": "2.6.12",
          "git_version": "d73c92b1c85703828b55c2916a5dd4ad46535f6a",
          "sys_info": "Linux build5.ny.cbi.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49",
          "loader_flags": "-fPIC -pthread -Wl,-z,now -rdynamic",
          "compiler_flags": "-Wnon-virtual-dtor -Woverloaded-virtual -fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -pipe -Werror -O3 -Wno-unused-function -Wno-deprecated-declarations -fno-builtin-memcmp",
          "allocator": "tcmalloc",
          "bits": 64,
          "max_bson_object_size": 16777216,
          "javascript_engine": "V8",
          "build_environment": {}
        },
        "database_info": {
          "databases": [
            {
              "name": "local",
              "size_on_disk": 83886080,
              "empty": false
            },
            {
              "name": "admin",
              "size_on_disk": 1,
              "empty": true
            }
          ],
          "total_size": 83886080
        }
      },
      "timestamp": "2021-10-21T10:31:42-07:00"
    }
  }
}

// programmer error
log.Fatalf("Invalid BSON: %v", err)
}
query_msg := getOpQuery("admin.$cmd", query)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go naming way it use camelCase -> queryMsg

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming here follows the convention used elsewhere in the file. I can update those, but it may be best to instead separate coding standards compliance into a separate PR alongside some enforcement built within the git pipeline.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I agree with you

@dadrian dadrian merged commit 48f15ef into zmap:master Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants