-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4c6ed50
Showing
21 changed files
with
1,566 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Django Recommended | ||
*.egg-info | ||
*.pot | ||
*.py[co] | ||
__pycache__ | ||
MANIFEST | ||
dist/ | ||
docs/_build/ | ||
docs/locale/ | ||
node_modules/ | ||
tests/coverage_html/ | ||
tests/.coverage | ||
build/ | ||
tests/report/ | ||
|
||
# Sensitive Data | ||
credentials.py | ||
credentials.pyc | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
django-env/ | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
assets/ # The directory set as STATIC_ROOT where Apache creates new static files on live web servers. | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*,cover | ||
.hypothesis/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django | ||
*.log | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
#Ipython Notebook | ||
.ipynb_checkpoints |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# WebMap |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
from django.shortcuts import render | ||
from django.http import HttpResponse | ||
import xmltodict, json, html, os, hashlib, re | ||
from collections import OrderedDict | ||
|
||
def rmNotes(request, hashstr): | ||
scanfilemd5 = hashlib.md5(str(request.session['scanfile']).encode('utf-8')).hexdigest() | ||
if re.match('^[a-f0-9]{32,32}$', hashstr) is not None: | ||
os.remove('/opt/notes/'+scanfilemd5+'_'+hashstr+'.notes') | ||
res = {'ok':'notes removed'} | ||
else: | ||
res = {'error':'invalid format'} | ||
|
||
return HttpResponse(json.dumps(res), content_type="application/json") | ||
|
||
def saveNotes(request): | ||
if request.method == "POST": | ||
scanfilemd5 = hashlib.md5(str(request.session['scanfile']).encode('utf-8')).hexdigest() | ||
|
||
if re.match('^[a-f0-9]{32,32}$', request.POST['hashstr']) is not None: | ||
f = open('/opt/notes/'+scanfilemd5+'_'+request.POST['hashstr']+'.notes', 'w') | ||
f.write(request.POST['notes']) | ||
f.close() | ||
res = {'ok':'notes saved'} | ||
else: | ||
res = {'error': request.method } | ||
|
||
return HttpResponse(json.dumps(res), content_type="application/json") | ||
|
||
def rmlabel(request, objtype, hashstr): | ||
types = { | ||
'host':True, | ||
'port':True | ||
} | ||
|
||
scanfilemd5 = hashlib.md5(str(request.session['scanfile']).encode('utf-8')).hexdigest() | ||
|
||
if re.match('^[a-f0-9]{32,32}$', hashstr) is not None: | ||
os.remove('/opt/notes/'+scanfilemd5+'_'+hashstr+'.'+objtype+'.label') | ||
res = {'ok':'label removed'} | ||
return HttpResponse(json.dumps(res), content_type="application/json") | ||
|
||
def label(request, objtype, label, hashstr): | ||
labels = { | ||
'Vulnerable':True, | ||
'Critical':True, | ||
'Warning':True, | ||
'Checked':True | ||
} | ||
|
||
types = { | ||
'host':True, | ||
'port':True | ||
} | ||
|
||
scanfilemd5 = hashlib.md5(str(request.session['scanfile']).encode('utf-8')).hexdigest() | ||
|
||
if label in labels and objtype in types: | ||
if re.match('^[a-f0-9]{32,32}$', hashstr) is not None: | ||
f = open('/opt/notes/'+scanfilemd5+'_'+hashstr+'.'+objtype+'.label', 'w') | ||
f.write(label) | ||
f.close() | ||
res = {'ok':'label set', 'label':str(label)} | ||
return HttpResponse(json.dumps(res), content_type="application/json") | ||
|
||
def port_details(request, address, portid): | ||
r = {} | ||
oo = xmltodict.parse(open('/opt/xml/'+request.session['scanfile'], 'r').read()) | ||
r['out'] = json.dumps(oo['nmaprun'], indent=4) | ||
o = json.loads(r['out']) | ||
|
||
for i in o['host']: | ||
if '@addr' in i['address']: | ||
saddress = i['address']['@addr'] | ||
elif type(i['address']) is list: | ||
for ai in i['address']: | ||
if ai['@addrtype'] == 'ipv4': | ||
saddress = ai['@addr'] | ||
|
||
if str(saddress) == address: | ||
for pobj in i['ports']['port']: | ||
if type(pobj) is dict: | ||
p = pobj | ||
else: | ||
p = i['ports']['port'] | ||
|
||
if p['@portid'] == portid: | ||
return HttpResponse(json.dumps(p, indent=4), content_type="application/json") | ||
|
||
def genPDF(request): | ||
if 'scanfile' in request.session: | ||
pdffile = hashlib.md5(str(request.session['scanfile']).encode('utf-8')).hexdigest() | ||
if os.path.exists('/opt/nmapdashboard/nmapreport/static/'+pdffile+'.pdf'): | ||
os.remove('/opt/nmapdashboard/nmapreport/static/'+pdffile+'.pdf') | ||
|
||
os.popen('/opt/wkhtmltox/bin/wkhtmltopdf --cookie sessionid '+request.session._session_key+' --enable-javascript --javascript-delay 6000 http://127.0.0.1:8000/view/pdf/ /opt/nmapdashboard/nmapreport/static/'+pdffile+'.pdf') | ||
res = {'ok':'PDF created', 'file':'/static/'+pdffile+'.pdf'} | ||
return HttpResponse(json.dumps(res), content_type="application/json") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class NmapreportConfig(AppConfig): | ||
name = 'nmapreport' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
def labelToMargin(label): | ||
labels = { | ||
'Vulnerable':'10px', | ||
'Critical':'22px', | ||
'Warning':'28px', | ||
'Checked':'28px' | ||
} | ||
|
||
if label in labels: | ||
return labels[label] | ||
|
||
def labelToColor(label): | ||
labels = { | ||
'Vulnerable':'red', | ||
'Critical':'black', | ||
'Warning':'orange', | ||
'Checked':'blue' | ||
} | ||
|
||
if label in labels: | ||
return labels[label] | ||
|
||
def fromOSTypeToFontAwesome(ostype): | ||
icons = { | ||
'windows':'fab fa-windows', | ||
'solaris':'fab fa-linux', # there isn't a better icon on fontawesome :( | ||
'unix':'fab fa-linux', # same here... | ||
'linux':'fab fa-linux', | ||
} | ||
|
||
if ostype.lower() in icons: | ||
return str(icons[ostype.lower()]) | ||
else: | ||
return 'fas fa-question' |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.db import models | ||
|
||
# Create your models here. |
Oops, something went wrong.