diff --git a/.gitignore b/.gitignore index bc5ae94..62be209 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ app/scanned.db *.xml **/*.pyc +**/*.swp diff --git a/app/static/css/style.css b/app/static/css/style.css index a2019f9..c4cece9 100755 --- a/app/static/css/style.css +++ b/app/static/css/style.css @@ -41,6 +41,9 @@ tbody tr:hover td { cursor: pointer; } +tbody tr.active td { + background-color: #FFEFC6; +} table tr:last-child td:first-child { border-bottom-left-radius: 10px; diff --git a/app/static/js/table.js b/app/static/js/table.js index b327d01..283e159 100644 --- a/app/static/js/table.js +++ b/app/static/js/table.js @@ -1,20 +1,9 @@ -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); - } -}); - function count_rows() { return document.querySelectorAll('tr:not([style*="display:none"]):not([style*="display: none"])').length; -} \ No newline at end of file +} + +document.querySelectorAll("tbody tr").forEach(function(elem) { + elem.addEventListener("click", function() { + elem.classList.toggle('active'); + }); +}); \ No newline at end of file diff --git a/app/templates/.base.html.swp b/app/templates/.base.html.swp deleted file mode 100644 index e64c759..0000000 Binary files a/app/templates/.base.html.swp and /dev/null differ diff --git a/app/templates/404.html b/app/templates/404.html index ec83c23..ca65a3d 100644 --- a/app/templates/404.html +++ b/app/templates/404.html @@ -24,5 +24,5 @@ {% block main %}

404

That page doesn't even exist.

-

Why don't you just go back home?

+

Why don't you just go back home?

{% endblock %} \ No newline at end of file diff --git a/app/templates/home.html b/app/templates/home.html index 28d3709..e5c12c6 100644 --- a/app/templates/home.html +++ b/app/templates/home.html @@ -7,26 +7,26 @@ - + + + + - - {% for target in targets %} - + {% endfor %} -
OS - HOSTNAME - ADDRESS - +
+ +
{{ target.hostname }} {{ target.address }}{{ target.ports }}{{ target.ports[1:-1]|replace('|', ', ') }}
{% endblock %} diff --git a/app/views.py b/app/views.py index e0ad64a..1e58303 100644 --- a/app/views.py +++ b/app/views.py @@ -1,13 +1,41 @@ -from app import app, db from flask import render_template, request, redirect, url_for, flash +from sqlalchemy import select from app.models import target +from sqlalchemy import func +from app import app, db -@app.route('/') -def home(): +@app.route('/', methods=['GET']) +def get_home(): """Render website's home page.""" targets = db.session.query(target).all() return render_template('home.html', targets=targets) +@app.route('/', methods=['POST']) +def post_home(): + """Render website's home page with applied filters.""" + targets = db.session.query(target) + + os = request.form.get("os") + if os: + targets = targets.where(target.os == os) + + hostname = request.form.get("hostname") + if hostname: + targets = targets.where(target.hostname == hostname) + + address = request.form.get("address") + if address: + targets = targets.where(target.address == address) + + ports = request.form.get("ports") + if ports: + for port in ports.replace(' ','').split(','): + targets = targets.filter(target.ports.like('%|'+port+'|%')) + + + return render_template('home.html', targets=targets.all(), os=os,hostname=hostname,address=address,ports=ports) + + @app.after_request def add_header(response): """