Skip to content

Commit 9502b8c

Browse files
authored
Merge pull request #128 from VanTekken/master
Dockerized Included Vulnerable Web Application
2 parents b199389 + a32e49c commit 9502b8c

17 files changed

+266
-181
lines changed

README.md

+40-17
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,73 @@
1-
NoSQLMap
2-
========
3-
[![Python 2.6|2.7](https://img.shields.io/badge/python-2.6|2.7-yellow.svg)](https://www.python.org/)
1+
# NoSQLMap
2+
3+
[![Python 2.6|2.7](https://img.shields.io/badge/python-2.6|2.7-yellow.svg)](https://www.python.org/)
44
[![License](https://img.shields.io/badge/license-GPLv3-red.svg)](https://github.com/codingo/NoSQLMap/blob/master/COPYING)
55
[![Twitter](https://img.shields.io/badge/twitter-@codingo__-blue.svg)](https://twitter.com/codingo_)
66

77
NoSQLMap is an open source Python tool designed to audit for as well as automate injection attacks and exploit default configuration weaknesses in NoSQL databases and web applications using NoSQL in order to disclose or clone data from the database.
88

9-
Originally authored by [@tcsstool](https://twitter.com/tcstoolHax0r) and now maintained by [@codingo_](https://twitter.com/codingo_) NoSQLMap is named as a tribute to Bernardo Damele and Miroslav's Stampar's popular SQL injection tool [sqlmap](http://sqlmap.org). Its concepts are based on and extensions of Ming Chow's excellent presentation at Defcon 21, ["Abusing NoSQL Databases"](https://www.defcon.org/images/defcon-21/dc-21-presentations/Chow/DEFCON-21-Chow-Abusing-NoSQL-Databases.pdf).
10-
9+
Originally authored by [@tcsstool](https://twitter.com/tcstoolHax0r) and now maintained by [@codingo\_](https://twitter.com/codingo_) NoSQLMap is named as a tribute to Bernardo Damele and Miroslav's Stampar's popular SQL injection tool [sqlmap](http://sqlmap.org). Its concepts are based on and extensions of Ming Chow's excellent presentation at Defcon 21, ["Abusing NoSQL Databases"](https://www.defcon.org/images/defcon-21/dc-21-presentations/Chow/DEFCON-21-Chow-Abusing-NoSQL-Databases.pdf).
1110

1211
## NoSQLMap MongoDB Management Attack Demo.
1312

14-
<a href="http://www.youtube.com/watch?feature=player_embedded&v=xSFi-jxOBwM" target="_blank"><img src="http://img.youtube.com/vi/xSFi-jxOBwM/0.jpg" alt="NoSQLMap MongoDB Management Attack Demo" width="240" height="180" border="10" /></a>
13+
<a href="http://www.youtube.com/watch?feature=player_embedded&v=xSFi-jxOBwM" target="_blank"><img src="http://img.youtube.com/vi/xSFi-jxOBwM/0.jpg" alt="NoSQLMap MongoDB Management Attack Demo" width="240" height="180" border="10" /></a>
1514

1615
## Screenshots
16+
1717
![NoSQLMap](https://github.com/codingo/NoSQLMap/blob/master/screenshots/NoSQLMap-v0-5.jpg)
1818

1919
# Summary
20+
2021
## What is NoSQL?
22+
2123
A NoSQL (originally referring to "non SQL", "non relational" or "not only SQL") database provides a mechanism for storage and retrieval of data which is modeled in means other than the tabular relations used in relational databases. Such databases have existed since the late 1960s, but did not obtain the "NoSQL" moniker until a surge of popularity in the early twenty-first century, triggered by the needs of Web 2.0 companies such as Facebook, Google, and Amazon.com. NoSQL databases are increasingly used in big data and real-time web applications. NoSQL systems are also sometimes called "Not only SQL" to emphasize that they may support SQL-like query languages.
2224

2325
## DBMS Support
26+
2427
Presently the tool's exploits are focused around MongoDB, and CouchDB but additional support for other NoSQL based platforms such as Redis, and Cassandra are planned in future releases.
2528

26-
## Requirements
27-
On a Debian or Red Hat based system, the setup.sh script may be run as root to automate the installation of NoSQLMap's dependencies.
29+
## Requirements
30+
31+
On a Debian or Red Hat based system, the setup.sh script may be run as root to automate the installation of NoSQLMap's dependencies.
2832

2933
Varies based on features used:
30-
- Metasploit Framework,
31-
- Python with PyMongo,
32-
- httplib2,
33-
- and urllib available.
34-
- A local, default MongoDB instance for cloning databases to. Check [here](http://docs.mongodb.org/manual/installation/) for installation instructions.
3534

36-
There are some various other libraries required that a normal Python installation should have readily available. Your milage may vary, check the script.
35+
- Metasploit Framework,
36+
- Python with PyMongo,
37+
- httplib2,
38+
- and urllib available.
39+
- A local, default MongoDB instance for cloning databases to. Check [here](http://docs.mongodb.org/manual/installation/) for installation instructions.
40+
41+
There are some various other libraries required that a normal Python installation should have readily available. Your milage may vary, check the script.
3742

3843
## Setup
44+
3945
```
4046
python setup.py install
4147
```
48+
4249
Alternatively you can build a Docker image by changing to the docker directory and entering:
50+
4351
```
4452
docker build -t nosqlmap .
4553
```
4654

4755
or you can use Docker-compose to run Nosqlmap:
56+
4857
```
4958
docker-compose build
5059
docker-compose run nosqlmap
5160
```
61+
5262
## Usage Instructions
63+
5364
Start with
65+
5466
```
5567
python NoSQLMap
5668
```
5769

58-
NoSQLMap uses a menu based system for building attacks. Upon starting NoSQLMap you are presented with with the main menu:
70+
NoSQLMap uses a menu based system for building attacks. Upon starting NoSQLMap you are presented with with the main menu:
5971

6072
```
6173
1-Set options (do this first)
@@ -66,11 +78,12 @@ x-Exit
6678
```
6779

6880
Explanation of options:
81+
6982
```
7083
1. Set target host/IP-The target web server (i.e. www.google.com) or MongoDB server you want to attack.
7184
2. Set web app port-TCP port for the web application if a web application is the target.
7285
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).
73-
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.
86+
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.
7487
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.
7588
6. Set shell listener port-If opening Meterpreter shells, specify the port.
7689
7. Load options file-Load a previously saved set of settings for 1-6.
@@ -79,4 +92,14 @@ Explanation of options:
7992
x. Back to main menu-Use this once the options are set to start your attacks.
8093
```
8194

82-
Once options are set head back to the main menu and select DB access attacks or web app attacks as appropriate for whether you are attacking a NoSQL management port or web application. The rest of the tool is "wizard" based and fairly self explanatory, but send emails to codingo@protonmail.com or find me on Twitter [@codingo_](https://twitter.com/codingo_) if you have any questions or suggestions.
95+
Once options are set head back to the main menu and select DB access attacks or web app attacks as appropriate for whether you are attacking a NoSQL management port or web application. The rest of the tool is "wizard" based and fairly self explanatory, but send emails to codingo@protonmail.com or find me on Twitter [@codingo\_](https://twitter.com/codingo_) if you have any questions or suggestions.
96+
97+
## Vulnerable Applications
98+
99+
This repo also includes an intentionally vulnerable web application to test NoSQLMap with. To run this application, you need Docker installed. Then you can run the following commands from the /vuln_apps directory.
100+
101+
```
102+
docker-compose build && docker-compose up
103+
```
104+
105+
Once that is complete, you should be able to access the vulnerable application by visiting: https://127.0.0.1/index.html

vuln_apps/acct.php

-39
This file was deleted.

vuln_apps/cust.html

-21
This file was deleted.

vuln_apps/docker-compose.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
version: "3.8"
2+
services:
3+
apache:
4+
container_name: apache
5+
build: ./docker/apache
6+
links:
7+
- php
8+
ports:
9+
- "80:80"
10+
volumes:
11+
- ./src:/usr/local/apache2/htdocs
12+
php:
13+
container_name: php
14+
build: ./docker/php
15+
ports:
16+
- "9000:9000"
17+
volumes:
18+
- ./src:/usr/local/apache2/htdocs
19+
working_dir: /usr/local/apache2/htdocs
20+
mongo:
21+
container_name: mongo
22+
environment:
23+
MONGO_INITDB_ROOT_USERNAME: root
24+
MONGO_INITDB_ROOT_PASSWORD: prisma
25+
build: ./docker/mongo
26+
ports:
27+
- "27017:27017"

vuln_apps/docker/apache/Dockerfile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM httpd:2.4.51
2+
3+
COPY apache.conf /usr/local/apache2/conf/apache.conf
4+
5+
RUN echo "Include /usr/local/apache2/conf/apache.conf" \
6+
>> /usr/local/apache2/conf/httpd.conf

vuln_apps/docker/apache/apache.conf

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
LoadModule deflate_module /usr/local/apache2/modules/mod_deflate.so
2+
LoadModule proxy_module /usr/local/apache2/modules/mod_proxy.so
3+
LoadModule proxy_fcgi_module /usr/local/apache2/modules/mod_proxy_fcgi.so
4+
5+
<VirtualHost *:80>
6+
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://php:9000/usr/local/apache2/htdocs/$1
7+
8+
DocumentRoot /usr/local/apache2/htdocs
9+
10+
<Directory /usr/local/apache2/htdocs>
11+
Options -Indexes +FollowSymLinks
12+
DirectoryIndex index.php
13+
AllowOverride All
14+
Require all granted
15+
</Directory>
16+
</VirtualHost>

vuln_apps/docker/mongo/Dockerfile

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM mongo:latest
2+
3+
ADD ./mongo.nosql /tmp/mongo.nosql
4+
ADD ./import.sh /tmp/import.sh
5+
RUN chmod +x /tmp/import.sh

vuln_apps/docker/mongo/import.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
cat /tmp/mongo.nosql | mongosh "mongodb://root:prisma@mongo:27017"

vuln_apps/mongo.nosql renamed to vuln_apps/docker/mongo/mongo.nosql

-2
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ db.orders.insert({"id":"1","name":"Robin","item":"Music gift cards","quantity":"
55
db.orders.insert({"id":"1001","name":"Moses","item":"Miami Heat tickets","quantity":"1000"})
66
db.orders.insert({"id":"66","name":"Rick","item":"Black hoodie","quantity":"1"})
77
db.orders.insert({"id":"0","name":"Nobody","item":"Nothing","quantity":"0"})
8-
98
use customers
109
db.paymentinfo.insert({"name":"Adrien","id":"42","cc":"5555123456789999","cvv2":"1234"})
1110
db.paymentinfo.insert({"name":"Justin","id":"99","cc":"5555123456780000","cvv2":"4321"})
1211
db.paymentinfo.insert({"name":"Robin","id":"1","cc":"3333444455556666","cvv2":"2222"})
1312
db.paymentinfo.insert({"name":"Moses","id":"2","cc":"4444555566667777","cvv2":"3333"})
1413
db.paymentinfo.insert({"name":"Rick","id":"3","cc":"5555666677778888","cvv2":"5678"})
1514
db.paymentinfo.insert({"name":"Nobody","id":"0","cc":"45009876543215555","cvv2":"9999"})
16-
1715
use appUserData
1816
db.users.insert({"name":"Adrien","username":"adrien","email":"adrien@sec642.org"})
1917
db.users.insert({"name":"Justin","username":"justin","email":"justin@sec642.org"})

vuln_apps/docker/php/Dockerfile

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM php:8.1-fpm
2+
3+
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
4+
RUN echo "extension=mongodb.so" >> "$PHP_INI_DIR/php.ini"
5+
6+
RUN apt-get update \
7+
&& apt-get install -y libcurl4-openssl-dev pkg-config libssl-dev \
8+
&& apt-get install -y git zip unzip \
9+
&& pecl install mongodb \
10+
&& php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
11+
&& php composer-setup.php --install-dir=/usr/local/bin --filename=composer \
12+
&& rm composer-setup.php \
13+
&& composer require mongodb/mongodb

vuln_apps/orderdata.php

-51
This file was deleted.

vuln_apps/src/acct.php

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<html>
2+
3+
<head>
4+
<title>Payment information</title>
5+
</head>
6+
7+
<body>
8+
<?php
9+
try {
10+
$conn = new MongoDB\Driver\Manager('mongodb://root:prisma@mongo:27017');
11+
12+
$options = [
13+
'projection' => [],
14+
];
15+
$filter = ['id' => $_GET['acctid']];
16+
$query = new MongoDB\Driver\Query($filter, $options);
17+
18+
$cursor = $conn->executeQuery('customers.paymentinfo', $query);
19+
$counter = 0;
20+
21+
foreach ($cursor as $obj) {
22+
$counter++;
23+
echo 'Name: ' . $obj->name . '<br/>';
24+
echo 'Customer ID: ' . $obj->id . '<br/>';
25+
echo 'Card Number: ' . $obj->cc . '<br/>';
26+
echo 'CVV2 Code: ' . $obj->cvv2 . '<br/>';
27+
echo '<br/>';
28+
}
29+
30+
echo $counter . ' document(s) found. <br/>';
31+
32+
} catch (MongoConnectionException $e) {
33+
die('Error connecting to MongoDB server : ' . $e->getMessage());
34+
} catch (MongoException $e) {
35+
die('Error: ' . $e->getMessage());
36+
}
37+
?>
38+
39+
40+
</body>
41+
42+
</html>

vuln_apps/src/index.html

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<html>
2+
<head>
3+
<title>Customer Info</title>
4+
</head>
5+
6+
<body>
7+
<h1>Customer Information</h1>
8+
<h3>Enter your customer ID to show your account information:</h3>
9+
10+
<form method="get" action="acct.php">
11+
Customer ID:
12+
<input type="text" name="acctid" value="" />
13+
<br />
14+
<input type="submit" />
15+
</form>
16+
</body>
17+
</html>

0 commit comments

Comments
 (0)