audit-labs/audit-tools

A collection of scripts, queries, and other goodies you can use in an audit.

clone: git clone https://gitbay.org/audit-labs/audit-tools.git

v1.0.0: databases/mongo/README.md · raw

  1# `admins.py`
  2
  3Dependency:
  4
  5``` shell
  6pip install pymongo
  7```
  8
  9``` python
 10python ./admins.py
 11```
 12
 13Example output:
 14
 15``` json
 16[
 17  {
 18    "_id": "admin.admin",
 19    "user": "admin",
 20    "db": "admin",
 21    "roles": [
 22      {
 23        "role": "userAdminAnyDatabase",
 24        "db": "admin"
 25      },
 26      {
 27        "role": "readWriteAnyDatabase",
 28        "db": "admin"
 29      },
 30      {
 31        "role": "dbAdminAnyDatabase",
 32        "db": "admin"
 33      },
 34      {
 35        "role": "clusterAdmin",
 36        "db": "admin"
 37      }
 38    ],
 39    "credentials": {
 40      "SCRAM-SHA-1": {
 41        "iterationCount": 10000,
 42        "salt": "abc123",
 43        "storedKey": "storedKeyHash",
 44        "serverKey": "serverKeyHash"
 45      },
 46      "SCRAM-SHA-256": {
 47        "iterationCount": 15000,
 48        "salt": "def456",
 49        "storedKey": "storedKeyHash256",
 50        "serverKey": "serverKeyHash256"
 51      }
 52    }
 53  },
 54  {
 55    "_id": "test.user1",
 56    "user": "user1",
 57    "db": "test",
 58    "roles": [
 59      {
 60        "role": "readWrite",
 61        "db": "test"
 62      }
 63    ],
 64    "credentials": {
 65      "SCRAM-SHA-1": {
 66        "iterationCount": 10000,
 67        "salt": "ghi789",
 68        "storedKey": "storedKeyHashUser1",
 69        "serverKey": "serverKeyHashUser1"
 70      }
 71    }
 72  },
 73  {
 74    "_id": "test.ldapUser",
 75    "user": "ldapUser",
 76    "db": "test",
 77    "roles": [
 78      {
 79        "role": "read",
 80        "db": "test"
 81      }
 82    ],
 83    "userSource": "ldap"
 84  },
 85  {
 86    "_id": "admin.x509User",
 87    "user": "x509User",
 88    "db": "$external",
 89    "roles": [
 90      {
 91        "role": "readWrite",
 92        "db": "admin"
 93      }
 94    ],
 95    "credentials": {
 96      "MONGODB-X509": {
 97        "subject": "CN=x509User,OU=OrgUnit,O=Org,L=City,ST=State,C=Country"
 98      }
 99    }
100  }
101]
102```