HTB - Mongod

HTB - Mongod

OS: Linux | Difficulty: Very Easy 操作系统:Linux | 难度:非常简单

After doing nmap enumeration, we will see one TCP port 27017 which refers to MongoDB. Whenever we see such port open, we can try to connect to it and access the database via mongosh aka MongoDB Shell. 在进行 nmap 枚举后,我们会看到一个 TCP 27017 端口,这指向 MongoDB 服务。每当我们看到该端口开放时,都可以尝试连接它,并通过 mongosh(即 MongoDB Shell)访问数据库。

You can download MongoDB Shell here: 你可以从此处下载 MongoDB Shell:

Unzip it: 解压它: dpkg-deb -x mongodb-mongosh_2.10.0_amd64.deb --extract <directory that you want>

Go to the bin folder and execute the mongo shell command: 进入 bin 文件夹并执行 mongo shell 命令: ./mongosh mongodb://10.129.228.30:27017

For syntax, you can check in mongosh --help. 关于语法,你可以查看 mongosh --help

Once connected, you can interact with following commands: 连接成功后,你可以使用以下命令进行交互:

  • show dbs -> Show all databases (显示所有数据库)
  • use <dbs name> -> Choose database (选择数据库)
  • show collections -> Show all collections in the chosen database (显示所选数据库中的所有集合)
  • db.<collection>.find() -> Dump the content of all the documents within the collection named to find the flag (转储指定集合中所有文档的内容以查找 flag)

We get to learn how to identify MongoDB service as well as connecting to the database from this machine. 通过这台机器,我们学习了如何识别 MongoDB 服务以及如何连接到数据库。