diff --git a/README.md b/README.md index 69abca4..d59af80 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,25 @@ -# gutterbox -## setup -Install the dependancies +# Gutterbox +This tool was intened to make looking at large nmap scans easier. -specify the correct version for sqlite3 +## Importing Scans +Gutterbox currently loosly supports xml nmap scans. Suggested usage is as follows... +```bash +nmap -O -oX scan.xml 192.168.1.0/24 ``` -sudo apt update -sudo apt install php libapache2-mod-php php-mysql -sudo apt install php7.0-sqlite3 +After the scan has been completed, the parse must be ran to convert the xml to sqlite3... +```bash +python3 parser.py -x scan.xml ``` -## Use it! -Run the scan -``` -nmap -O -oX /var/www/html/gutterbox/scans/scan.xml 192.168.1.0/24 +## Using the tool +Really the meat and potatoes is that you now have an sqlite3 file! So fun! There is also a super powerful hyper intesive webserver that can view the database easier... +```bash +python3 run.py ``` -Feed the parser -``` -./parser.py -x scans/scan.xml +## Contributing +Yeah, so this tool isn't the best right now. My original intention was to make an easy way to filter nmap scans and that didn't exist when this was first created. This also allows output to be concatenated. So maybe multiple scans are ran at once and then all the output files could be imported with... +```bash +for i in *.xml;do python3 parser.py -x $i;done ``` +With that spirit in mind, feel free to contribute! There are a lot of things that need fixing and updating for this project and I don't mind the help or feature ideas! diff --git a/app/__init__.py b/app/__init__.py new file mode 100644 index 0000000..edc5bf8 --- /dev/null +++ b/app/__init__.py @@ -0,0 +1,14 @@ +from flask import Flask +from flask_sqlalchemy import SQLAlchemy +import os + +basedir = os.path.abspath(os.path.dirname(__file__)) + +app = Flask(__name__) +app.config['SECRET_KEY'] = 'super secret key' +#app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///scanned.db' +app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'scanned.db') +db = SQLAlchemy(app) + +app.config.from_object(__name__) +from app import views diff --git a/app/__pycache__/__init__.cpython-310.pyc b/app/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..023c0b7 Binary files /dev/null and b/app/__pycache__/__init__.cpython-310.pyc differ diff --git a/app/__pycache__/__init__.cpython-311.pyc b/app/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..6e8839d Binary files /dev/null and b/app/__pycache__/__init__.cpython-311.pyc differ diff --git a/app/__pycache__/models.cpython-310.pyc b/app/__pycache__/models.cpython-310.pyc new file mode 100644 index 0000000..2fde41a Binary files /dev/null and b/app/__pycache__/models.cpython-310.pyc differ diff --git a/app/__pycache__/models.cpython-311.pyc b/app/__pycache__/models.cpython-311.pyc new file mode 100644 index 0000000..90ae140 Binary files /dev/null and b/app/__pycache__/models.cpython-311.pyc differ diff --git a/app/__pycache__/views.cpython-310.pyc b/app/__pycache__/views.cpython-310.pyc new file mode 100644 index 0000000..0e20457 Binary files /dev/null and b/app/__pycache__/views.cpython-310.pyc differ diff --git a/app/__pycache__/views.cpython-311.pyc b/app/__pycache__/views.cpython-311.pyc new file mode 100644 index 0000000..3473022 Binary files /dev/null and b/app/__pycache__/views.cpython-311.pyc differ diff --git a/app/models.py b/app/models.py new file mode 100644 index 0000000..8d860e5 --- /dev/null +++ b/app/models.py @@ -0,0 +1,18 @@ +from app import db + +class target(db.Model): + __tablename__ = 'targets' + id = db.Column(db.Integer, primary_key = True) + os = db.Column(db.String()) + hostname = db.Column(db.String()) + address = db.Column(db.String()) + ports = db.Column(db.String()) + + def __init__(self, os, hostname, address, ports): + self.os = os + self.hostname = hostname + self.address = address + self.ports = ports + + def __repr__(self): + return '
' % self.address diff --git a/style.css b/app/static/css/style.css old mode 100644 new mode 100755 similarity index 89% rename from style.css rename to app/static/css/style.css index 16f4886..a2019f9 --- a/style.css +++ b/app/static/css/style.css @@ -26,6 +26,9 @@ tr{ td{ padding:5px; } +tr td:last-child{ + text-align: left; +} .table-header{ border-bottom:10px solid white; font-weight: bold; diff --git a/app/static/js/table.js b/app/static/js/table.js new file mode 100644 index 0000000..828f4a3 --- /dev/null +++ b/app/static/js/table.js @@ -0,0 +1,16 @@ +function filter_ports(filter) { + let portCol = document.querySelectorAll("tbody tr td:last-child"); + portCol.forEach((item) => { + if(!new RegExp(filter).test(item.innerText)){ + item.parentNode.style.display = "none"; + } else { + item.parentNode.style.display = "table-row"; + } + }); +} + +document.querySelector("#ports").addEventListener("keyup", (event) => { + if (event.key === "Enter") { + filter_ports(event.srcElement.value); + } +}); \ No newline at end of file diff --git a/media/linux.png b/app/static/media/linux.png similarity index 100% rename from media/linux.png rename to app/static/media/linux.png diff --git a/media/unsure.png b/app/static/media/unsure.png similarity index 100% rename from media/unsure.png rename to app/static/media/unsure.png diff --git a/media/windows.png b/app/static/media/windows.png similarity index 100% rename from media/windows.png rename to app/static/media/windows.png diff --git a/app/templates/.base.html.swp b/app/templates/.base.html.swp new file mode 100644 index 0000000..e64c759 Binary files /dev/null and b/app/templates/.base.html.swp differ diff --git a/app/templates/404.html b/app/templates/404.html new file mode 100644 index 0000000..ec83c23 --- /dev/null +++ b/app/templates/404.html @@ -0,0 +1,28 @@ +{% extends "base.html" %} + +{% block title %}Page Not Found{% endblock %} + +{% block css %} + +{% endblock %} + +{% block main %} +

404

+

That page doesn't even exist.

+

Why don't you just go back home?

+{% endblock %} \ No newline at end of file diff --git a/app/templates/base.html b/app/templates/base.html new file mode 100644 index 0000000..eaae93d --- /dev/null +++ b/app/templates/base.html @@ -0,0 +1,20 @@ + + + + + + + + Gutterbox + + + + + {% block css %} {% endblock%} + + + {% block main %}{% endblock %} + {% block js %} {% endblock%} + + + \ No newline at end of file diff --git a/app/templates/home.html b/app/templates/home.html new file mode 100644 index 0000000..458e3de --- /dev/null +++ b/app/templates/home.html @@ -0,0 +1,39 @@ +{% extends "base.html" %} + +{% block main %} +

This might help

+

- d4rkr41n

+ + + + + + + + + + + {% for target in targets %} + + {% if target.os == "Windows" %} + + {% elif target.os == "Linux" %} + + {% else %} + + {% endif %} + + + + + + {% endfor %} + + + +
OS + HOSTNAME + ADDRESS + +
{{ target.hostname }}{{ target.address }}{{ target.ports }}
+{% endblock %} diff --git a/app/views.py b/app/views.py new file mode 100644 index 0000000..fd48a6f --- /dev/null +++ b/app/views.py @@ -0,0 +1,52 @@ +""" +Flask Documentation: http://flask.pocoo.org/docs/ +Jinja2 Documentation: http://jinja.pocoo.org/2/documentation/ +Werkzeug Documentation: http://werkzeug.pocoo.org/documentation/ +This file creates your application. +""" + +from app import app, db +from flask import render_template, request, redirect, url_for, flash +from app.models import target +# import sqlite3 + +### +# Routing for your application. +### + +@app.route('/') +def home(): + """Render website's home page.""" + targets = db.session.query(target).all() + return render_template('home.html', targets=targets) + +### +# The functions below should be applicable to all Flask apps. +### + +@app.route('/.txt') +def send_text_file(file_name): + """Send your static text file.""" + file_dot_text = file_name + '.txt' + return app.send_static_file(file_dot_text) + + +@app.after_request +def add_header(response): + """ + Add headers to both force latest IE rendering engine or Chrome Frame, + and also to cache the rendered page for 10 minutes. + """ + response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1' + response.headers['Cache-Control'] = 'public, max-age=600' + return response + + +@app.errorhandler(404) +def page_not_found(error): + """Custom 404 page.""" + return render_template('404.html'), 404 + + +if __name__ == '__main__': + app.run(debug=True,host="0.0.0.0",port="8080") diff --git a/index.php b/index.php deleted file mode 100644 index 0811155..0000000 --- a/index.php +++ /dev/null @@ -1,49 +0,0 @@ - - - GutterBox - - - - - - -

This might help

-

- d4rkr41n

- - - - - - - -query("SELECT os,hostname,address,ports FROM targets"); - foreach($targets as $tar) - { - echo "\t\n"; - if(strtolower($tar['os']) == "windows"){ - echo "\t\t\n"; - }else if(strtolower($tar['os']) == "linux"){ - echo "\t\t\n"; - }else{ - echo "\t\t\n"; - } - echo "\t\t\n"; - echo "\t\t\n"; - echo "\t\t\n"; - echo "\t\n"; - } -?> - - -
OS - HOSTNAME - ADDRESS - PORTS -
".$tar['hostname']."".$tar['address']."".$tar['ports']."
- - diff --git a/parser.py b/parser.py old mode 100644 new mode 100755 index b4cd099..7aa510b --- a/parser.py +++ b/parser.py @@ -7,7 +7,7 @@ import re parser = argparse.ArgumentParser(description='Convert your nmap scans into a sqlite database!') -parser.add_argument('-d', type=str, help='The database file to use',default='scanned.db') +parser.add_argument('-d', type=str, help='The database file to use',default='app/scanned.db') parser.add_argument('-x', type=str, help='The xml file to read from, please use -oX with nmap') args = parser.parse_args() @@ -67,6 +67,7 @@ def main(): conn = create_connection(database) if conn is None: raise("Could not connect to database") + exit() """ Create the table if it isn't there """ targetTableCreate = """ CREATE TABLE IF NOT EXISTS targets ( @@ -109,6 +110,7 @@ def main(): # Write the targets to the database for tar in targets: tar.add(conn) + print(tar.ptarg()) # Close the database connection conn.commit() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..7d4905b --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +Flask +Flask_SQLAlchemy diff --git a/run.py b/run.py new file mode 100644 index 0000000..f0580de --- /dev/null +++ b/run.py @@ -0,0 +1,3 @@ +#! /usr/bin/env python +from app import app +app.run(debug=True,host="127.0.0.1",port=8080) \ No newline at end of file diff --git a/scans/scan.xml b/scans/scan.xml deleted file mode 100755 index 8a2b872..0000000 --- a/scans/scan.xml +++ /dev/null @@ -1,576 +0,0 @@ - - - - - - - - - -
-
- - - - - - - - - - - - - - -cpe:/o:freebsd:freebsd:10.1 - - -cpe:/o:freebsd:freebsd:8.1 - - -cpe:/o:openbsd:openbsd:4.3 - - -cpe:/o:openbsd:openbsd:4.0 - - - - - - - - - - -
-
- - - - - - - - - - - - -cpe:/o:linux:linux_kernel:3 -cpe:/o:linux:linux_kernel:4 - - -cpe:/o:linux:linux_kernel:3 -cpe:/o:linux:linux_kernel:4 - - -cpe:/o:linux:linux_kernel:4.4 - - -cpe:/o:linux:linux_kernel:4.10 - - -cpe:/o:linux:linux_kernel:3.10 - - -cpe:/o:linux:linux_kernel:3 -cpe:/o:linux:linux_kernel:4 - - -cpe:/o:linux:linux_kernel:2.6 -cpe:/o:linux:linux_kernel:3 - - -cpe:/o:linux:linux_kernel:2.6 - - -cpe:/a:synology:diskstation_manager:5.2 - - -cpe:/o:linux:linux_kernel:3 - - - - - - - - - - - -
-
- - - - - - - - - - - - - - -cpe:/o:linux:linux_kernel:3 -cpe:/o:linux:linux_kernel:4 - - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - -cpe:/o:linux:linux_kernel:3 -cpe:/o:linux:linux_kernel:4 - - - - - - - - - - -
-
- - - - - - - - - - - - - - -cpe:/o:linux:linux_kernel:3 -cpe:/o:linux:linux_kernel:4 - - - - - - - - - - -
-
- - - - - - - - - - - - - - - -cpe:/o:linux:linux_kernel:3 -cpe:/o:linux:linux_kernel:4 - - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -cpe:/o:microsoft:windows_server_2012:r2 - - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -cpe:/o:microsoft:windows_server_2012:r2 - - - - - - - - - - -
-
- - - - - - - - - - - - - - - -cpe:/o:microsoft:windows_server_2016 - - -cpe:/o:microsoft:windows_server_2012:r2 - - -cpe:/o:microsoft:windows_10:1511 - - -cpe:/o:microsoft:windows_vista::sp1:home_premium -cpe:/o:microsoft:windows_7 -cpe:/o:microsoft:windows_server_2008 - - -cpe:/o:microsoft:windows_10:1607 - - -cpe:/o:microsoft:windows_server_2016 - - -cpe:/o:microsoft:windows_10 - - -cpe:/o:microsoft:windows_7::sp1 - - -cpe:/o:microsoft:windows_server_2012:-cpe:/o:microsoft:windows_server_2012:r2 - - -cpe:/o:microsoft:windows_8 - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - -cpe:/o:microsoft:windows_vista::sp1:home_premium -cpe:/o:microsoft:windows_7 -cpe:/o:microsoft:windows_server_2008 - - -cpe:/o:microsoft:windows_7::sp1 - - -cpe:/o:microsoft:windows_8 - - -cpe:/o:microsoft:windows_vista:::enterprise - - -cpe:/o:microsoft:windows_7::sp1 -cpe:/o:microsoft:windows_server_2008::sp2 - - -cpe:/o:microsoft:windows_10:1511 - - -cpe:/o:microsoft:windows_server_2012:r2 - - -cpe:/o:microsoft:windows_8.1 - - -cpe:/o:microsoft:windows_7::sp1 -cpe:/o:microsoft:windows_server_2008:r2:sp1 -cpe:/o:microsoft:windows_8.1 - - -cpe:/o:microsoft:windows_7::sp1 - - - - - - - - - - - -
-
- - - - - - - - - - - - - - -cpe:/o:microsoft:windows_10:1511 - - -cpe:/o:microsoft:windows_10:1703 - - -cpe:/o:microsoft:windows_vista::sp1:home_premium -cpe:/o:microsoft:windows_7 -cpe:/o:microsoft:windows_server_2008 - - -cpe:/o:microsoft:windows_10:1607 - - -cpe:/o:microsoft:windows_10 - - -cpe:/o:microsoft:windows_server_2016 - - -cpe:/o:microsoft:windows_7::sp1 - - -cpe:/o:microsoft:windows_8 - - -cpe:/o:microsoft:windows_vista:::enterprise - - -cpe:/o:microsoft:windows_server_2012:r2 - - - - - - - - - - - -
-
- - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - - -cpe:/o:microsoft:windows_server_2008:r2 -cpe:/o:microsoft:windows_8.1 - - -cpe:/o:microsoft:windows_7::-:professional -cpe:/o:microsoft:windows_8 - - -cpe:/o:microsoft:windows_7 - - -cpe:/o:microsoft:windows - - -cpe:/o:microsoft:windows_vista::-cpe:/o:microsoft:windows_vista::sp1 -cpe:/o:microsoft:windows_server_2008::sp1 -cpe:/o:microsoft:windows_7 - - -cpe:/o:microsoft:windows_vista::sp2 -cpe:/o:microsoft:windows_7::sp1 -cpe:/o:microsoft:windows_server_2008 - - - - - - - - - - -
- - - - - - - - - - - -cpe:/o:linux:linux_kernel:3 - - - - - - - - - - - -