From 4bc14263fc844eb2e00b3db5b0435f79ffa96fb1 Mon Sep 17 00:00:00 2001 From: Translator Date: Tue, 8 Jul 2025 19:36:49 +0000 Subject: [PATCH] Translated ['src/pentesting-web/nosql-injection.md'] to it --- src/pentesting-web/nosql-injection.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/pentesting-web/nosql-injection.md b/src/pentesting-web/nosql-injection.md index b7c0bf690..2520e72dc 100644 --- a/src/pentesting-web/nosql-injection.md +++ b/src/pentesting-web/nosql-injection.md @@ -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}}