MongoDB-Cowboys / Monalize

Monaliza is a tool for scanning and analyzing MongoDB database for any performance issues, which lead to high CPU consumption.
GNU General Public License v3.0
28 stars 6 forks source link

Permission Denied when grabbing inprog #1

Closed jaitaiwan closed 1 year ago

jaitaiwan commented 3 years ago

When attempting to download the inprog by directly calling the mongo shell from the command line via go, if there are special characters in the passwords the shell call will fail because the password is not escaped correctly.

ku9nov commented 3 years ago

Hello @jaitaiwan can you tell me what symbols are we talking about? i tried this:

❯ docker run -d --name some-mongo \
-e MONGO_INITDB_ROOT_USERNAME=mongoadmin \
-e MONGO_INITDB_ROOT_PASSWORD=sec#$ret \
mongo
6e17e1b661f358d28e54e562fb981d5601dec9168ff9af971e3a5a7f38ee7d87
❯ docker exec -it some-mongo bash
root@6e17e1b661f3:/# mongo --username mongoadmin --password sec#$ret --authenticationDatabase admin
MongoDB shell version v4.4.6
> show dbs;
admin   0.000GB
config  0.000GB
local   0.000GB
> exit
bye
root@6e17e1b661f3:/# exit
❯ ./monalize --db_uri "mongodb://mongoadmin:sec#$ret@172.17.0.2:27017/?&authSource=admin"
0- Database: admin
--- Collection: system.version Count: 2
{_id:1}
--- Collection: system.users Count: 1
{_id:1}
{db:1},user:1}
1- Database: config
--- Collection: system.sessions Count: 0
{_id:1}
{lastUse:1}
2- Database: local
--- Collection: startup_log Count: 2
{_id:1}
Search slow query...
angelbulas commented 3 years ago

I have similar issue, this is the error I'm getting:

monalize --db_uri "mongodb://root:5xOFFmF)5xOFFmF5xOFFmF5xOFFmF@127.0.0.1:27017/?&authSource=admin" 2021/06/24 13:29:07 Connect to MongoDB is impossible. Check if it works and the entered data.

I suspect is because of the ")" sign

ku9nov commented 3 years ago

Hey @angelbulas FYI use https://www.url-encode-decode.com/ for password Example:

❯ docker run -d --name some-mongo \
-e MONGO_INITDB_ROOT_USERNAME=mongoadmin \
-e MONGO_INITDB_ROOT_PASSWORD=sec#$re)t \
zsh: parse error near `)'
❯ docker run -d --name some-mongo \
-e MONGO_INITDB_ROOT_USERNAME=mongoadmin \
-e MONGO_INITDB_ROOT_PASSWORD='sec#$re)t' \
> mongo 

Go to encode site and encode you password to url format. After:

./monalize --db_uri "mongodb://mongoadmin:sec%23%24re%29t@172.17.0.2:27017/?&authSource=admin"

should works. I will deal with this in the near future in app. Thanks. Best regards.