Skip to content

Commit

Permalink
Merge pull request #8 from theMiddleBlue/v2/master
Browse files Browse the repository at this point in the history
V2/master
  • Loading branch information
Rev3rseSecurity authored Oct 26, 2018
2 parents b6d7b36 + 0ddee16 commit 9a528d0
Show file tree
Hide file tree
Showing 11 changed files with 224 additions and 20 deletions.
26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ A Web Dashbord for Nmap XML Report
- [Video](#video)
- [Features](#features)
- [XML Filenames](#xml-filenames)
- [CVE and Exploits](#cve-and-exploits)
- [Third Parts](#third-parts)
- [Security Issues](#security-issues)
- [Contributors](#contributors)
Expand All @@ -28,13 +29,18 @@ $ docker run -d \
-h webmap \
-p 8000:8000 \
-v /tmp/webmap:/opt/xml \
rev3rse/webmap /run.sh
rev3rse/webmap

$ # now you can run Nmap and save the XML Report on /tmp/webmap
$ nmap -sT -A -T4 -oX /tmp/webmap/myscan.xml 192.168.1.0/24
```
Now point your browser to http://localhost:8000

### Quick and Dirty
```bash
$ curl -sL http://bit.ly/webmapsetup | bash
```

## Video
-- coming soon...

Expand All @@ -46,28 +52,40 @@ Now point your browser to http://localhost:8000
- Insert notes for a specific host
- Create a PDF Report with charts, details, labels and notes
- Copy to clipboard as Nikto, Curl or Telnet commands
- Search for CVE and Exploits based on CPE collected by Nmap

## XML Filenames
When creating the PDF version of the Nmap XML Report, the XML filename is used as document title on the first page. WebMap will replace some parts of the filename as following:
When creating the PDF version of the Nmap XML Report, the XML filename is used as document title on the first page.
WebMap will replace some parts of the filename as following:

- `_` will replaced by a space (` `)
- `.xml` will be removed

Example: `ACME_Ltd..xml`<br>
PDF title: `ACME Ltd.`

## CVE and Exploits
thanks to the amazing API services by circl.lu, WebMap is able to looking for CVE and Exploits for each CPE collected by Nmap.
Not all CPE are checked over the circl.lu API, but only when a specific version is specified
(for example: `cpe:/a:microsoft:iis:7.5` and not `cpe:/o:microsoft:windows`).

## Third Parts
- [Django](https://www.djangoproject.com)
- [Materialize CSS](https://materializecss.com)
- [Clipboard.js](https://clipboardjs.com)
- [Chart.js](https://www.chartjs.org)
- [Wkhtmltopdf](https://wkhtmltopdf.org)
- [API cve.circl.lu](https://cve.circl.lu)

## Security Issues
This app is not intended to be exposed on the internet. Please, **DO NOT expose** this app to the internet, use your localhost or, in case you can't do it, take care to filter who and what can access to WebMap with a firewall rule or something like that. Exposing this app to the whole internet could lead not only to a stored XSS but also to a leakage of sensitive/critical/private informations about your port scan. Please, be smart.
This app is not intended to be exposed on the internet. Please, **DO NOT expose** this app to the internet, use your localhost or,
in case you can't do it, take care to filter who and what can access to WebMap with a firewall rule or something like that.
Exposing this app to the whole internet could lead not only to a stored XSS but also to a leakage of sensitive/critical/private
informations about your port scan. Please, be smart.

## Contributors
This project is currently a beta, and I'm not super skilled on Django so, every type of contribution is appreciated. I'll mention all contributors in this section of the README file.
This project is currently a beta, and I'm not super skilled on Django so, every type of contribution is appreciated.
I'll mention all contributors in this section of the README file.

### Contributors List
- s3th_0x [@adubaldo](https://github.com/adubaldo) (bug on single host report)
Expand Down
41 changes: 41 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# WebMap
# -
# https://github.com/Rev3rseSecurity/WebMap
# Rev3rse Security: https://www.youtube.com/rev3rsesecurity
# Author: theMiddle
# -
# Usage:
# $ cd /opt
# $ git clone https://github.com/Rev3rseSecurity/WebMap.git
# $ cd WebMap/docker
# $ docker build -t webmap:latest .
# $ docker run -d -v /opt/WebMap/docker/xml:/opt/xml -p 8000:8000 webmap:latest
#
# Nmap Example:
# $ nmap -sT -A -oX /tmp/myscan.xml 192.168.1.0/24
# $ mv /tmp/myscan.xml /opt/WebMap/docker/xml
#
# Now you can point your browser to http://localhost:8000

FROM ubuntu:latest

RUN apt-get update && apt-get install -y --allow-downgrades --allow-remove-essential --allow-change-held-packages \
python3 python3-pip curl wget git wkhtmltopdf libssl1.0-dev

RUN mkdir /opt/xml && mkdir /opt/notes && \
wget -P /opt/ https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz && \
cd /opt/ && tar -xvf /opt/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz

RUN pip3 install Django requests xmltodict && \
cd /opt/ && django-admin startproject nmapdashboard && cd /opt/nmapdashboard && \
git clone https://github.com/Rev3rseSecurity/WebMap.git && \
mv WebMap nmapreport && cd nmapreport && git checkout v2/master

COPY settings.py /opt/nmapdashboard/nmapdashboard/
COPY urls.py /opt/nmapdashboard/nmapdashboard/

RUN cd /opt/nmapdashboard && python3 manage.py migrate

EXPOSE 8000

ENTRYPOINT ["python3", "/opt/nmapdashboard/manage.py", "runserver", "0:8000"]
113 changes: 113 additions & 0 deletions docker/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'rev3rse-notes:_you_should-change_this..._but_webmap_should_run_on_localhost_only..._so_no_problem_here.'
# ^^^ -> yes, not safe for production. This is the why you shouldn't expose this app on the internet.


# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
# ^^^ leave it active for better understand issues and bug
# ^^^ (again, this is a good reason to not expose this app on the internet)

ALLOWED_HOSTS = ['*']
# ^ keep in mind that this app is not designed to be exposed on the internet. Please don't do it.

# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'nmapreport',
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'nmapdashboard.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'nmapdashboard.wsgi.application'


# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': '/opt/nmapdashboard/db.sqlite3',
}
}


# Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]


# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/

STATIC_URL = '/static/'
9 changes: 9 additions & 0 deletions docker/setup.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
echo -e "\n[+] Starting WebMap docker setup"
echo "[+] Creating required dirs"
mkdir /tmp/webmap
echo "[+] Docker run webmap"
docker run -d --name webmap -h webmap -p 8000:8000 -v /tmp/webmap:/opt/xml rev3rse/webmap
echo "[+] Done"
echo -e "\nNow you can point your browser to http://localhost:8000"
echo "Please, take few seconds to support this project on GitHub"
echo -e "https://github.com/Rev3rseSecurity/WebMap\n"
8 changes: 8 additions & 0 deletions docker/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.contrib import admin
from django.urls import include, path

urlpatterns = [
path('', include('nmapreport.urls')),
path('report/', include('nmapreport.urls')),
path('admin/', admin.site.urls),
]
Empty file added docker/xml/empty.txt
Empty file.
2 changes: 1 addition & 1 deletion pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def reportPDFView(request):
' <table><thead><tr><th>Protocol / Port</th><th>Port State</th><th>Product / Version</th></tr></thead><tbody>'+\
hostdetails_html_tr+\
'</tbody></table></div>'+\
'<div class="">'+portdetails_html_tr+'</div>'+\
'<div style="page-break-before: always;"><h3>NSE Scripts for '+saddress+':</h3>'+portdetails_html_tr+'</div>'+\
notesout+\
cveout_html

Expand Down
2 changes: 2 additions & 0 deletions static/report.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ h1 {
padding:10px;
margin-bottom:10px;
font-family:monospace;
border-radius:4px;
background-color:#eee;
}

.extratitle {
Expand Down
Binary file added static/rev3rse_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion templates/nmapreport/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<script src="{% static "/async.js" %}"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js"></script>
<script src="https://buttons.github.io/buttons.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>

Expand All @@ -19,7 +20,10 @@
<div class="navbar-fixed">
<nav style="background-color:rgba(0,0,0,0.8);">
<div class="nav-wrapper">
<div class="left scantitle" id="scantitle"></div>
<div class="left scantitle" id="scantitle">
<div style="margin-top:-22px;" class="hide-on-med-and-down"><a class="github-button" href="https://github.com/Rev3rseSecurity/WebMap/" data-icon="octicon-star" data-size="small" data-show-count="true" aria-label="Star Rev3rseSecurity/WebMap on GitHub">WebMap Star</a> &nbsp;
<a class="github-button" href="https://github.com/Rev3rseSecurity/WebMap/subscription" data-icon="octicon-eye" data-size="small" data-show-count="true" aria-label="Watch Rev3rseSecurity/WebMap on GitHub">WebMap Watch</a></div>
</div>
<a href="/" class="brand-logo center"><img src="/static/logo.png" style="height:28px;" /></a>
<ul class="right hide-on-med-and-down">
<li><a href="/setscanfile/unset">Scan List</a></li>
Expand Down
37 changes: 23 additions & 14 deletions views.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,39 +270,47 @@ def index(request, filterservice="", filterportid=""):
# no file selected
xmlfiles = os.listdir('/opt/xml')

r['table'] = '<div class="" style="border-top:solid #444 1px;"><br>'+\
r['table'] = '<div class="card" style="background-color:#3e3e3e;"><div class="card-content">'+\
' Put your Nmap XML files in <span class="tmlabel grey-text" style="background-color:transparent;">/opt/xml/</span> directory, example:<br><br>'+\
' <div class="tmlabel black grey-text" style="padding:10px;font-size:14px;">nmap -A -T4 -oX myscan.xml 192.168.1.0/24<br>'+\
' mv myscan.xml &lt;docker webmap xml dir&gt;<br><br>'+\
' # or you can copy myscan.xml to the webmap container:<br>'+\
' docker cp myscan.xml webmap:/opt/xml/</div>'+\
'</div>'+\
'<script async defer src="https://buttons.github.io/buttons.js"></script>'
'</div></div>'

r['table'] += '<div class="row" style="margin-top:60px;">'+\
r['table'] += '<div class="row hide-on-med-and-down" style="margin-top:60px;padding:10px;border-top:solid #444 1px;">'+\
' <div class="col s4" style="text-align:center;">'+\
' <img src="/static/logo.png" style="width:300px;" /><br>'+\
' <span style="color:#999;">Made with <i class="fas fa-heart red-text"></i> by Andrea <b><a href="https://twitter.com/Menin_TheMiddle">theMiddle</a></b> Menin</span>'+\
' <img src="/static/logo.png" style="width:320px;" /><br>'+\
' <span style="color:#999;">Made with <i class="fas fa-heart red-text"></i> by Andrea <b><a href="https://twitter.com/Menin_TheMiddle">theMiddle</a></b> Menin</span><br><br>'+\
' </div>'+\
' <div class="col s3" style="color:#999;"><b>GitHub:</b><br><br>'+\
' <a class="github-button" href="https://github.com/theMiddleBlue" data-size="large" data-show-count="true" aria-label="Follow theMiddle on GitHub">Follow theMiddle</a><br>'+\
' <div class="col s4" style="color:#999;text-align:center;">'+\
' <img src="/static/rev3rse_logo.png" style="width:180px;" /><br>'+\
' <span style="color:#999;">A Rev3rse Security Project</span>'+\
' <!-- <a class="github-button" href="https://github.com/theMiddleBlue" data-size="large" data-show-count="true" aria-label="Follow theMiddle on GitHub">Follow theMiddle</a><br>'+\
' <a class="github-button" href="https://github.com/Rev3rseSecurity/WebMap/subscription" data-icon="octicon-eye" data-size="large" data-show-count="true" aria-label="Watch Rev3rseSecurity/WebMap on GitHub">Watch</a><br>'+\
' <a class="github-button" href="https://github.com/Rev3rseSecurity/WebMap/" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star Rev3rseSecurity/WebMap on GitHub">Star</a>'+\
' <a class="github-button" href="https://github.com/Rev3rseSecurity/WebMap/" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star Rev3rseSecurity/WebMap on GitHub">Star</a> -->'+\
' </div>'+\
' <div class="col s5" style="color:#999;"><b>Follow me:</b><br><br>'+\
' <a href="https://twitter.com/Menin_TheMiddle?ref_src=twsrc%5Etfw" class="twitter-follow-button" data-size="large" data-show-count="true">Follow @Menin_TheMiddle</a><script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script><br>'+\
' <script src="https://apis.google.com/js/platform.js"></script><div class="g-ytsubscribe" data-channelid="UCzvJStjySZVvOBsPl-Vgj0g" data-layout="default" data-theme="dark" data-count="default"></div>'+\
' <div class="col s4" style="color:#999;text-align:left;">'+\
' <div style="color:#999;margin-bottom:10px;">Support us &amp; Follow us</div>'+\
' <a href="https://github.com/Rev3rseSecurity/WebMap/" class="white-text"><i class="fab fa-github fa-1x white-text"></i> WebMap on GitHub</a><br>'+\
' <a href="https://twitter.com/rev3rsesecurity" class="white-text"><i class="fab fa-twitter fa-1x blue-text" style=""></i> <b>Rev3rse Security</b> on Twitter</a><br>'+\
' <a href="https://www.youtube.com/rev3rsesecurity" class="white-text"><i class="fab fa-youtube fa-1x red-text" style=""></i> <b>Rev3rse Security</b> on YouTube</a><br>'+\
' <!-- <a href="https://twitter.com/Menin_TheMiddle?ref_src=twsrc%5Etfw" class="twitter-follow-button" data-size="large" data-show-count="true">Follow @Menin_TheMiddle</a><script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script><br>'+\
' <script src="https://apis.google.com/js/platform.js"></script><div class="g-ytsubscribe" data-channelid="UCzvJStjySZVvOBsPl-Vgj0g" data-layout="default" data-theme="dark" data-count="default"></div> -->'+\
' </div>'+\
'</div>'

r['scaninfo'] = '<span class="card-title">Select a Nmap XML file</span><p>Nmap XML files: '+ str(len(xmlfiles)) +'</p>'

r['trhost'] = ''
r['trhead'] = '<tr><th>Filename</th><th>Scan Start Time</th><th>Hosts</th><th>&nbsp;</th></tr>'

xmlfilescount = 0
for i in xmlfiles:
if re.search('\.xml$', i) is None:
continue

xmlfilescount = (xmlfilescount + 1)

oo = xmltodict.parse(open('/opt/xml/'+i, 'r').read())
r['out2'] = json.dumps(oo['nmaprun'], indent=4)
o = json.loads(r['out2'])
Expand All @@ -327,7 +335,8 @@ def index(request, filterservice="", filterportid=""):
' <td><a href="'+viewhref+'" class="btn blue right">view</a></td>'+\
'</tr>'

# r['out'] = os.listdir('/opt/xml')
r['scaninfo'] = '<span class="card-title">Select a Nmap XML file</span><p>Nmap XML files: '+ str(xmlfilescount) +'</p>'

return render(request, 'nmapreport/index.html', r)

scanmd5 = hashlib.md5(str(request.session['scanfile']).encode('utf-8')).hexdigest()
Expand Down

0 comments on commit 9a528d0

Please sign in to comment.