HTB Starting Point: Mongod
好的,我现在需要帮用户总结一篇文章的内容,控制在100字以内。首先,我得仔细阅读用户提供的文章内容,理解其主要信息。 这篇文章主要讲的是MongoDB的基础知识,包括如何通过Nmap扫描发现MongoDB服务,然后连接到数据库。接着介绍了SQL和NoSQL的区别,以及如何使用MongoDB的命令行工具进行操作,比如列出数据库、集合和查询特定文档。最后提到了获取root flag的过程,并强调了数据库操作在渗透测试中的重要性。 接下来,我需要将这些要点浓缩成一段简短的文字。要确保涵盖主要内容:任务、Nmap扫描、MongoDB连接、基本命令和敏感信息提取。同时要注意字数限制,不超过100字。 可能会遇到的问题是如何在有限的字数内准确传达所有关键点。可能需要删减一些细节,比如具体的命令或步骤,只保留核心内容。 最后,确保语言简洁明了,避免使用复杂的术语或结构。这样用户就能快速理解文章的主要内容。 </think> 文章介绍了如何通过NMAP扫描发现MongoDB服务并连接到目标数据库。通过基础命令如`show dbs`、`use`和`db.flag.find()`等操作,成功提取了敏感信息并获取root flag。 2025-11-9 09:18:25 Author: infosecwriteups.com(查看原文) 阅读量:41 收藏

KarmicDragoon92

Getting Familiar with MongoDB

Moving onto our next Starting Point machine we have this bad boy. A quick look at the tasks associated with guy shows that we’re going to need to be brushing up on our MongoDB knowledge. Truthfully, I don’t have a ton of experience with this so this will be good for all of us. After connecting to HTB’s environment through either their pwnbox or OpenVPN let’s go ahead and spawn our target and then get started with this first task.

Task 1 and 2

Press enter or click to view image in full size

We’re gonna knock out these first two tasks with an NMAP scan, we’re not wasting any time today.

Press enter or click to view image in full size

Here you see me run

sudo nmap -sV -p- 10.129.16.91

which the -sV flag is for a service scan and -p- specifies I want to scan all ports, not just the top 10,000. So based off of the output here, we see that there are two TCP ports open and mongodb is the service running on port 27017 go figure. Let’s go ahead and plug all these answers in and then move right along.

Task 3

Press enter or click to view image in full size

You see here, sometimes HTB spoils its answer a tiny bit by giving us the character count. However, let’s not make this too easy, let’s actually understand the difference between a SQL vs NoSQL database. There’s a good article here from IBM that goes into some detail, but long story short it has to deal with how the data is stored. It doesn’t mean NoSQL databases don’t use SQL or a kind of SQL to perform your queries. In SQL databases everything is stored in tables and rows, what is referred to as relational databases. NoSQL just allows us more flexibility in how we want our data stored and is considered better equipped to handle large amount of unstructured data. If you’re curious about the details, feel free to give that article a look, otherwise let’s just answer the question here ‘NoSQL’ and keep moving right along.

Task 4

Press enter or click to view image in full size

I actually don’t have the foggiest idea, like I said I’m kinda in the trenches with yall on this one. Let’s go to yee old googles and see what we get. From GeeksforGeeks

Press enter or click to view image in full size

Well here we see the command in question and also the syntax for connecting to a remote database, perfect we’ll need that in a second. Actually, before we submit our answer, let’s actually attempt to connect to the database. We aren’t given any credentials so let’s just specify the host and see what happens.

Press enter or click to view image in full size

Huh, well that seems off. To keep this brief, this is some issue with the pwnbox’s nodejs version or something (per the HTB Forums) and the fix was actually only in the official writeup. Gasp, using the official writeup in a writeup? Yeah I know, sometimes you gotta do what you gotta do.

Press enter or click to view image in full size

Alright let’s just run these command verbatim and connect to the database.

Press enter or click to view image in full size

Bam connected. Just for ease of following along the necessary commands are provided below.

curl -O https://downloads.mongodb.com/compass/mongosh-2.3.2-linux-x64.tgz
tar xvf mongosh-2.3.2-linux-x64.tgz
cd mongosh-2.3.2-linux-x64/bin
./mongosh mongodb://[IP_Address]

Okay now after we’ve done all that, let’s go ahead and actually answer the question.

Task 5

Press enter or click to view image in full size

Well luckily I still have the GeeksforGeeks article up which actually provides us with most of what we need. The show dbs command will be what we need here.

Press enter or click to view image in full size

So from our MongoDB shell here we run that command and see 5 databases here. For task 5 we have our answer, let’s move onto our next tasks.

Task 6 and 7

Press enter or click to view image in full size

Alright we’re gonna go for both of these at one. One nice feature in the MongoDB CLI is the help command.

Press enter or click to view image in full size

This spits out a lot of useful information and you can also run it as help <command> in order to get more info on a specific command. Here though we can actually see the command we need to run. The show collections command will probably do it. We need to place ourselves into a database first with the use command.

From the list of DB’s here, sensitive_information sounds interesting. We can jump into that DB and run show collections to see a collection called flag. Well how about that? Now, this next part took me a little longer than I care to admin, but to answer task 7 we need to leverage the db command which is a massive tool when it comes to interacting with the CLI. After playing around though the command to run is

db.flag.find()

This command queries the flag collection for all documents, and in this case we only see one with a value called flag:. So if we submit that for our root flag...

Root Flag and Conclusion

Press enter or click to view image in full size

Being able to interact with DB’s of all kinds in an extremely necessary skill when it comes to enumerating our targets. Being able to pillage valid credentials or just sensitive information in general is kinda a big deal in red team operations. In also just good for us blue teamers to know because the more we know the better we can just do our jobs. Thank you for sticking around for this one and as always, see you in the next one!


文章来源: https://infosecwriteups.com/htb-starting-point-mongod-29281b2887ff?source=rss----7b722bfd1b8d---4
如有侵权请联系:admin#unsafe.sh