codingo/NoSQLMap

GitHub: codingo/NoSQLMap

NoSQLMap 是一款自动化 NoSQL 数据库枚举与 Web 应用注入攻击利用工具,帮助安全测试人员发现并利用 NoSQL 环境中的安全漏洞。

Stars: 3332 | Forks: 625

# NoSQLMap [![Python 2.6|2.7](https://img.shields.io/badge/python-2.6|2.7-yellow.svg)](https://www.python.org/) [![License](https://img.shields.io/badge/license-GPLv3-red.svg)](https://github.com/codingo/NoSQLMap/blob/master/COPYING) [![Twitter](https://img.shields.io/badge/twitter-@codingo__-blue.svg)](https://twitter.com/codingo_) NoSQLMap 是一款开源的 Python 工具,旨在审计并自动化注入攻击,利用 NoSQL 数据库以及使用 NoSQL 的 Web 应用程序中的默认配置漏洞,从而泄露或克隆数据库中的数据。 NoSQLMap 最初由 [@tcsstool](https://twitter.com/tcstoolHax0r) 编写,目前由 [@codingo\_](https://twitter.com/codingo_) 维护。其命名是为了向 Bernardo Damele 和 Miroslav Stampar 广受欢迎的 SQL 注入工具 [sqlmap](http://sqlmap.org) 致敬。它的概念基于 Ming Chow 在 Defcon 21 上的精彩演讲 [“滥用 NoSQL 数据库”](https://www.defcon.org/images/defcon-21/dc-21-presentations/Chow/DEFCON-21-Chow-Abusing-NoSQL-Databases.pdf) 并在此基础上进行了扩展。 ## NoSQLMap MongoDB 管理攻击演示。 NoSQLMap MongoDB 管理攻击演示 ## 截图 ![NoSQLMap](https://github.com/codingo/NoSQLMap/blob/master/screenshots/NoSQLMap-v0-5.jpg) # 概述 ## 什么是 NoSQL? NoSQL(最初指的是“非 SQL”、“非关系型”或“不仅仅是 SQL”)数据库提供了一种用于存储和检索数据的机制,这些数据的建模方式不同于关系型数据库中使用的表格关系。此类数据库早在 20 世纪 60 年代末就已存在,但直到 21 世纪初,由于 Facebook、Google 和 Amazon.com 等 Web 2.0 公司的需求推动而大受欢迎时,才获得了“NoSQL”的称号。NoSQL 数据库越来越多地被用于大数据和实时 Web 应用程序。NoSQL 系统有时也被称为“不仅仅是 SQL”,以强调它们可能支持类似 SQL 的查询语言。 ## DBMS 支持 目前,该工具的攻击利用主要集中在 MongoDB 和 CouchDB 上,但在未来的版本中计划增加对其他基于 NoSQL 的平台(如 Redis 和 Cassandra)的支持。 ## 要求 在基于 Debian 或 Red Hat 的系统上,可以以 root 用户身份运行 setup.sh 脚本,以自动安装 NoSQLMap 的依赖项。 具体要求取决于所使用的功能: - Metasploit Framework, - 带有 PyMongo 的 Python, - httplib2, - 以及可用的 urllib。 - 一个用于克隆数据库的本地默认 MongoDB 实例。查看[此处](http://docs.mongodb.org/manual/installation/)获取安装说明。 还需要一些其他常规 Python 安装中应该已有的库。具体情况可能有所不同,请查看脚本。 ## 安装说明 ``` python setup.py install ``` 或者,你可以通过输入以下命令来构建 Docker 镜像: ``` docker build -t nosqlmap . ``` 或者你可以使用 Docker-compose 来运行 Nosqlmap: ``` docker-compose build docker-compose run nosqlmap ``` ## 使用说明 使用以下命令启动 ``` python NoSQLMap ``` NoSQLMap 使用基于菜单的系统来构建攻击。启动 NoSQLMap 后,你会看到主菜单: ``` 1-Set options (do this first) 2-NoSQL DB Access Attacks 3-NoSQL Web App attacks 4-Scan for Anonymous MongoDB Access x-Exit ``` 选项说明: ``` 1. Set target host/IP-The target web server (i.e. www.google.com) or MongoDB server you want to attack. 2. Set web app port-TCP port for the web application if a web application is the target. 3. Set URI Path-The portion of the URI containing the page name and any parameters but NOT the host name (e.g. /app/acct.php?acctid=102). 4. Set HTTP Request Method (GET/POST)-Set the request method to a GET or POST; Presently only GET is implemented but working on implementing POST requests exported from Burp. 5. Set my local Mongo/Shell IP-Set this option if attacking a MongoDB instance directly to the IP of a target Mongo installation to clone victim databases to or open Meterpreter shells to. 6. Set shell listener port-If opening Meterpreter shells, specify the port. 7. Load options file-Load a previously saved set of settings for 1-6. 8. Load options from saved Burp request-Parse a request saved from Burp Suite and populate the web application options. 9. Save options file-Save settings 1-6 for future use. x. Back to main menu-Use this once the options are set to start your attacks. ``` 设置好选项后,返回主菜单,根据你是在攻击 NoSQL 管理端口还是 Web 应用程序,选择数据库访问攻击或 Web 应用程序攻击。该工具的其余部分采用“向导”模式,非常直观,但如果你有任何问题或建议,请发送电子邮件至 codingo@protonmail.com 或在 Twitter 上找到我 [@codingo\_](https://twitter.com/codingo_)。 ## 易受攻击的应用程序 此仓库还包含一个故意设计为易受攻击的 Web 应用程序,用于测试 NoSQLMap。要运行此应用程序,你需要安装 Docker。然后你可以在 /vuln_apps 目录中运行以下命令。 ``` docker-compose build && docker-compose up ``` 一旦完成,你应该能够通过访问以下地址访问该易受攻击的应用程序:https://127.0.0.1:8080/index.html ## 脚本编写 cli 也可以进行脚本化。以下是使用 NoSQLMap 检测 vuln_apps 中漏洞的示例脚本: ``` $ echo "1. Account Lookup (acct.php)" $ docker-compose run --remove-orphans nosqlmap \ --attack 2 \ --victim host.docker.internal \ --webPort 8080 \ --uri "/acct.php?acctid=test" \ --httpMethod GET \ --params 1 \ --injectSize 4 \ --injectFormat 2 \ --doTimeAttack n $ echo "2. User Data Lookup (userdata.php) - JavaScript Injection" $ docker-compose run --remove-orphans nosqlmap \ --attack 2 \ --victim host.docker.internal \ --webPort 8080 \ --uri "/userdata.php?usersearch=test" \ --httpMethod GET \ --params 1 \ --injectSize 4 \ --injectFormat 2 \ --doTimeAttack n $ echo "3. Order Data Lookup (orderdata.php) - JavaScript Injection" $ docker-compose run --remove-orphans nosqlmap \ --attack 2 \ --victim host.docker.internal \ --webPort 8080 \ --uri "/orderdata.php?ordersearch=test" \ --httpMethod GET \ --params 1 \ --injectSize 4 \ --injectFormat 2 \ --doTimeAttack n ```
标签:CISA项目, NoSQL注入, Python, 无后门, 版权保护, 请求拦截, 逆向工具